I am using the scipy optimize.fsolve function for the first time to find the roots of the equation. The problem is that any number that I use as a guess / score value is what I return as my answer (in about 8 decimal places). When using full_output = True, I get exitflag equal to โ1โ, which should mean that โSolution convergesโ, which, as far as I know, should mean that the output is really the root of the equation.
I know that there are a finite number of different roots (which are separated from each other), because when I draw an equation, I see them. Also, fsolve fail (gives an exitflags error) when I enter the start point in a range that should return undefined values โโ(division by zero, the square root of a negative value). But in addition, it always returns the starting point as the root.
I tested fsolve with a very simple equation and it worked fine, so I know that I import everything I need and must use fsolve correctly. I also tried to combine with some input arguments, but I do not understand them very well and nothing has changed).
Below is the corresponding code (E is the only variable, everything else has a nonzero value):
def func(E):
s = sqrt(c_sqr * (1 - E / V_0))
f = s / tan(s) + sqrt(c_sqr - s**2)
return f
guess = 3
fsolve(func, guess)
"3" " ", 2.8 4.7.
- , ( fsolve)?