对于具有三个未知数的三个非线性方程组,我有以下代码:
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))
方程组看起来非常复杂,但实际上很容易用Mathematica解决。
我收到以下错误:
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
我不知道如何解决这个问题,也许同情不能那样做。是否有类似的情感可以起作用?请帮忙。
答案 0 :(得分:1)
NotImplementedError意味着,没有实现解决方程式所需的算法。
实际上,对我来说,在最新版本的SymPy(0.7.5)中,它能够解决它,所以你应该升级。解决方案有点复杂,但它们就在那里。