The documentation on nonlinsolve
gives this example:
from sympy.core.symbol import symbols
from sympy.solvers.solveset import nonlinsolve
x, y, z = symbols('x, y, z', real=True)
nonlinsolve([x*y - 1, 4*x**2 + y**2 - 5], [x, y])
{(-1, -1), (-1/2, -2), (1/2, 2), (1, 1)}
but even in the live shell on their website, that throws an error:
>>> from sympy.solvers.solveset import nonlinsolve
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: cannot import name nonlinsolve
How can I use nonlinsolve
to solve a system of equations numerically? I know I can use ufuncify
to convert the equations into a system that scipy.optimize.fsolve
can solve, but I would rather avoid those couple of lines of boilerplate and just use SymPy directly.
According to the SymPy documentation on solve
, using solve
is not recommended. For nonlinear systems of equations, the documentation recommends sympy.solvers.solveset.nonlinsolve
, which is what I'm trying to use here.
sympy.solve([x*y - 1, 4*x**2 + y**2 - 5], [x, y])
– Sirreverencesolve
is not recommended. I'll add a statement about that to my question. – Lepidus