0
我有三個非線性方程組的系統有三個未知數下面的代碼:如何使用Python(sympy)來一對一解非線性方程?
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))
方程組看起來很複雜,但實際上它很容易用數學解決。
我得到以下錯誤:
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
我不知道如何解決這個問題,也許sympy不能做到這一點。有沒有像sympy可以工作的東西?請幫忙。