如何从Symphy中的notimplementederror获取值?

icnyk63a  于 2021-09-29  发布在  Java
关注(0)|答案(0)|浏览(246)

我正在使用以下代码:

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),我如何从那里得到这个值?。我在文档中找不到那个部分。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题