我正在使用以下代码:
from sympy.solvers import solve
from sympy import Symbol
x = Symbol('x')
function = input("Insert function: ")
def gx(function,x):
return solve(function,x,dict=True)
print(gx(function,x))
当我写cos(x)+x时,我得到这个错误消息:
Traceback (most recent call last):
File "/home/raulpenate/Documents/pyhton/MetodosNumericos/Tareas/testing.py", line 11, in <module>
print(gx(function,x))
File "/home/raulpenate/Documents/pyhton/MetodosNumericos/Tareas/testing.py", line 9, in gx
return solve(function,x)
File "/home/raulpenate/.local/lib/python3.9/site-packages/sympy/solvers/solvers.py", line 1095, in solve
solution = _solve(f[0], *symbols, **flags)
File "/home/raulpenate/.local/lib/python3.9/site-packages/sympy/solvers/solvers.py", line 1714, in _solve
raise NotImplementedError('\n'.join([msg, not_impl_msg % f]))
NotImplementedError: multiple generators [x, cos(x)]
No algorithms are implemented to solve equation x + cos(x)
我想从
NotImplementedError: multiple generators [x, cos(x)]
特别是cos(x),我如何从那里得到那个值?。我在documentation中找不到那个部分
如果Symphy找不到解析解,将发生
NotImplementedError
。您可以通过数值方式来解决此问题:这个问题不会在初等函数方面不太可能有封闭形式,请参见https://math.stackexchange.com/questions/46934/what-is-the-solution-of-cosx-x/1174794#1174794和https://mathworld.wolfram.com/DottieNumber.html
相关问题 更多 >
编程相关推荐