|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
我直接copy极客笔记代码到pycharm上,代码出现错误,有没有大佬知道哪里错了
极客笔记代码:
代码:
from sympy import *
x = Symbol('x')
eq = x**2 - 4
solutions = nsolve(eq, x, [-3, -1, 1, 3])
print(solutions)
错误:
E:\phthon\phthon3.11.3\python.exe "D:\python shuju\BKS\PYTHON\O-O-2.py"
Traceback (most recent call last):
File "D:\python shuju\BKS\PYTHON\O-O-2.py", line 6, in <module>
solutions = nsolve(eq, x, [-3, -1, 1, 3])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\phthon\phthon3.11.3\Lib\site-packages\sympy\utilities\decorator.py", line 87, in func_wrapper
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "E:\phthon\phthon3.11.3\Lib\site-packages\sympy\solvers\solvers.py", line 3044, in nsolve
x = sympify(findroot(f, x0, **kwargs))
^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\phthon\phthon3.11.3\Lib\site-packages\mpmath\calculus\optimization.py", line 963, in findroot
iterations = solver(ctx, f, x0, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\phthon\phthon3.11.3\Lib\site-packages\mpmath\calculus\optimization.py", line 84, in __init__
raise ValueError('expected 1 or 2 starting points, got %i' % len(x0))
ValueError: expected 1 or 2 starting points, got 4
|
|