Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/342.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 在sympy中替换函数后,求值无法进行直接的求导_Python_Math_Sympy - Fatal编程技术网

Python 在sympy中替换函数后,求值无法进行直接的求导

Python 在sympy中替换函数后,求值无法进行直接的求导,python,math,sympy,Python,Math,Sympy,昨天我一直在为这个问题烦恼。起初我提出了一个问题,但在评论需要一个简化的例子后,我删除了这个问题,最终找到了问题的“来源” 在用表达式替换函数后,我无法计算表达式:下面的示例将向您展示我的意思: xx = sy.Symbol('x',real=True) yy = sy.Symbol('y',real=True) FuncT = sy.Function('F') TestExp= sy.cos(sy.diff(FuncT(xx,yy),xx)+xx+yy*xx+yy) prin

昨天我一直在为这个问题烦恼。起初我提出了一个问题,但在评论需要一个简化的例子后,我删除了这个问题,最终找到了问题的“来源”

在用表达式替换函数后,我无法计算表达式:下面的示例将向您展示我的意思:

xx     = sy.Symbol('x',real=True)
yy     = sy.Symbol('y',real=True)
FuncT  = sy.Function('F')
TestExp= sy.cos(sy.diff(FuncT(xx,yy),xx)+xx+yy*xx+yy)
print(TestExp.subs({FuncT(xx,yy):xx})).subs({xx:1,yy:0.1})
结果是什么


它如何取代dx/dx=1?

只需
doit

>>> TestExp.subs({FuncT(xx,yy):xx}).subs({xx:1,yy:0.1}).doit()
-0.588501117255346
如何知道如何使用
doit

当我打印(不是
pprint
)我看到的表达式时

cos(Subs(Derivative(x, x), x, 1) + 1.2)
我不想要那里的
Subs
,但我对
Subs不太了解,所以我
寻求帮助并阅读以下内容:

>>> help(Subs)
...
There's no automatic expansion - use the method .doit() to effect all
possible substitutions of the object and also of objects inside the
expression.
...

只需
doit

>>> TestExp.subs({FuncT(xx,yy):xx}).subs({xx:1,yy:0.1}).doit()
-0.588501117255346
如何知道如何使用
doit

当我打印(不是
pprint
)我看到的表达式时

cos(Subs(Derivative(x, x), x, 1) + 1.2)
我不想要那里的
Subs
,但我对
Subs不太了解,所以我
寻求帮助并阅读以下内容:

>>> help(Subs)
...
There's no automatic expansion - use the method .doit() to effect all
possible substitutions of the object and also of objects inside the
expression.
...

哇!我应该在哪里找到这个?哇。我应该在哪里找到这个?