简体   繁体   English

使用 sympy 的偏导数

[英]Partial Derivative using sympy

I am trying to find partial derivative of a multi variate function using sympy but I am encountering the below problem.我正在尝试使用 sympy 找到多元函数的偏导数,但我遇到了以下问题。

Any help would be appreciated.任何帮助,将不胜感激。 Thank you谢谢

My Code:我的代码:

import sympy as sym
x, y = sym.symbols('x y')
sym.diff(x**2 + 10*sin(x) + y**3, x)

Error:错误:

NameError                                 Traceback (most recent call last)
<ipython-input-29-65fb237f8bc8> in <module>
  2 import math
  3 x, y = sym.symbols('x y')
----> 4 sym.diff(x**2 + 10*Sin(x) + y**3, x)

NameError: name 'sin' is not defined

You need to import the sin function from the library:您需要从库中导入sin函数:

from sympy import sin

https://docs.sympy.org/latest/modules/functions/elementary.html#sin https://docs.sympy.org/latest/modules/functions/elementary.html#sin

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM