This is an archival dump of old wiki content --- see scipy.org for current material.
Please see http://scipy-cookbook.readthedocs.org/

Find the points at which two given functions intersect

Consider the example of finding the intersection of a polynomial and a line:

y1=x1^2
y2=x2+1

   1 from scipy.optimize import fsolve
   2 
   3 import numpy as np
   4 
   5 def f(xy):
   6    x, y = xy
   7    z = np.array([y - x**2, y - x - 1.0])
   8    return z
   9 
  10 fsolve(f, [1.0, 2.0])

The result of this should be:

   1 array([ 1.61803399,  2.61803399])

See also: http://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.fsolve.html#scipy.optimize.fsolve

SciPy: Cookbook/Intersection (last edited 2015-10-24 17:48:24 by anonymous)