Question

I have the following code for a system of three nonlinear equations with three unknowns:

import sympy as sp
from sympy import symbols, cos, sin

v0, a0, f0 = symbols('v0 a0 f0')
v1, a1, f1 = symbols('v1 a1 f1')
w, t = symbols('w t')

g1 = v0 + a0 * w * cos(w*t + f0) - v1 - a1 * w * cos(f1)
g2 = v0**2 + a0**2*w**2 -v1**2 - a1**2*w**2
g3 = a0 * sin(w*t + f0) - a1*sin(f1)

sp.solvers.solve((g1,g2,g3), (a1,v1,f1))

The system of equations looks very complicated but actually it is easily solved with Mathematica.

I get the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 487, in runfile
    execfile(filename, namespace)
  File "/home/estudiante/.spyder2/.temp.py", line 16, in <module>
    a0 * sin(w*t + f0) - sin(f1)), (a1,v1,f1))
  File "/usr/lib/python2.7/dist-packages/sympy/solvers/solvers.py", line 484, in solve
    solution = _solve(f, *symbols, **flags)
  File "/usr/lib/python2.7/dist-packages/sympy/solvers/solvers.py", line 730, in _solve
    raise NotImplementedError()
NotImplementedError

I don't know how to fix that, maybe sympy cannot do that. Is there something like sympy which can work? Please help.

Was it helpful?

Solution

NotImplementedError means just that, that the algorithms needed to solve the equations are not implemented.

Actually, for me, in the latest version of SymPy (0.7.5), it is able to solve it, so you should upgrade. The solutions are a little complicated, but they're there.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top