Python curves intersection with fsolve() and function arguments using numpy
from scipy.optimize import fsolvedef pmix(x): return xdef paera(x, y): return x**2 - y**2def findIntersection(fun1, fun2, x0): return [fsolve(lambda x:fun1(x)-fun2(x, y), x0) for y in range(1, 10)]print findIntersection(pmix, paera, 0)
It seems that in your example you might solve it much easier without fsolve
:
import numpy as nppair = np.array(pair)pmech = np.array(pmech)intersect_x=np.abs(pair-pmech[:,None]).argmin(0)
(fun1(x) - fun2(x,y) for y in range(1,100))
is a generator
[fun1(x) - fun2(x,y) for y in range(1,100)]
is a list. You need the latter.
However, as btel mentions in the other answer, for intersections in arrays, you cannot just reuse code used for finding intersections of functions.