Skip to content Skip to sidebar Skip to footer

Sympy Nsolve Function And Multiple Solutions

I did this little test program in python to see how solve and nsolve work. from sympy import * theta = Symbol('theta') phi = Symbol('phi') def F(theta,phi): return sin(t

Solution 1:

The first call of solve gave me two solutions of the corresponding function. But not the second one. I wonder why?

In general, you cannot solve an equation symbolically and apparently solve does exactly that. In other words: Consider yourself lucky if solve can solve your equation, the typical technical applications don't have analytic solutions, that is, cannot be solved symbolically.

So the fall-back option is to solve the equation numerically, which starts from an initial point. In the general case, there is no guarantee that nsolve will find a solution even if exists one.

Is there a way to get the list all numerical solutions with nsolve or with another function, in just one line?

In general, no. Nevertheless, you can start nsolve from a number of initial guesses and keep track of the solutions found. You might want to distribute your initial guesses uniformly in the interval of interest. This is called multi-start method.


Post a Comment for "Sympy Nsolve Function And Multiple Solutions"