I have a system of this type:
a = alpha(x,k)
b = beta(x,k,alpha)
gamma(x,k,a,b) = 0
with x, a, and b as unknowns. Is it correct to set it up/solve like the example below?
k=1.5
def gamma(x,k):
def alpha(x,k):
return (x-k)**3
def beta(x, f1):
return x + f1(x,k)
return x**2 - alpha(x,k) - beta(x, alpha)*x
x, info, flag, msg = fsolve(gamma, 0., args=(k), full_output=True)
print x
print info
xp = np.linspace(-5, 5)
yp = [gamma(xx, k) for xx in xp]
plt.plot(xp, yp, '.-b')
plt.grid()
which prints out:
[1.49999677]
{'qtf': array([-8.8817842e-16]), 'nfev': 44, 'r': array([2.57880614e-10]), 'fjac': array([[-1.]]), 'fvec': array([0.])}
If so, how can I get fsolve
to return both roots, as shown in the graph?
graph of solutions from gamma
Thanks in advance!