在将参数 constant/having 保持为固定参数的同时,如何在 sympy 中象征性地采用偏导数?

How do you take a partial derivative symbolically in sympy while holding a parameter constant/having a fixed parameter?

我正在尝试以 here on page 2 in equation 6.1 的形式获得偏导数。该方程中下标的含义是,对其求导的变量所依赖的参数之一保持不变。 Sympy 的 Derivative() 函数中是否有任何参数允许这样做?

到目前为止,这是我的代码:

from sympy import*
init_printing(use_unicode=True)
#Create the variables
s = symbols('s') #x, y, and t
z = symbols('z') #vertical coordinate

#Create the functions that depend on those variables
zeta = Function('zeta')(s,z)
A = Function('A')(s,zeta)

#Here we actually take the derivative
expr = Derivative(A,z)
expr = expr.doit()
#This gives a basic partial derivative, but does not give a partial derivative with one of the parameters held constant

是否有某种类型的 kwargs 可以传递给允许这样做的微分函数?

在 sympy 中没有直接的方法来表示关于“第 n 个参数”的导数,但您可以使用虚拟变量和子变量。类似于:

In [24]: x, y, z = symbols('x, y, z')

In [25]: A = Function('A')

In [26]: f = Function('f')

In [27]: A(x, z).diff(x).subs(z, f(x, y))
Out[27]: 
⎛∂          ⎞│         
⎜──(A(x, z))⎟│         
⎝∂x         ⎠│z=f(x, y)