我在 sympy 网站上找到了 lambdify 的文档:http: //docs.sympy.org/dev/modules/utilities/lambdify.html
尝试使用复数的示例似乎分崩离析:
SympyExpression = sympy.parsing.sympy_parser.parse_expr('0.2*exp(1.6*I*pi*x)*log(x - 1.5)')
print "\nSympyExpression.subs(sympy.Symbol('x'), 0.0):"
print SympyExpression.subs(sympy.Symbol('x'), 0.0)
PythonFunction = sympy.lambdify((sympy.Symbol('x')), SympyExpression, "numpy")
print "\nPythonFunction(0.0):"
print PythonFunction(0.0)
>>>> SympyExpression.subs(sympy.Symbol('x'), 0.0):
>>>> 0.0810930216216329 + 0.2*I*pi
>>>> PythonFunction(0.0):
>>>> /usr/lib/python2.7/dist-packages/numpy/__init__.py:1: RuntimeWarning: invalid value encountered in log
>>>> """
>>>> (nan+nan*j)
我做了什么愚蠢的事情还是这是一个错误?