[英]Derivative of function of vector-functions based on derivative of vectors in sympy
I want to calculate the derivative of a function of vector-functions based on derivative of vectors in Python using sympy.我想使用 sympy 计算基于 Python 中向量导数的向量函数的导数。 For example, if the function is:
例如,如果函数是:
f(g) = g(t) / (gT(t) * g(t)) ^ 0.5
then I want to have:那么我想要:
df/dt = [dg(t) / dt * (gT(t) * g(t)) ^ 0.5 - 0.5 * g(t) * (dgT(t) / dt * g(t) + gT(t) * dg(t) / dt) * (gT(t) * g(t)) ^ (-0.5)] / [gT(t) * g(t)]
In which gT(t) is transpose of the vector function g(t).其中 gT(t) 是向量函数 g(t) 的转置。 How can I do that?
我怎样才能做到这一点?
The derivative can be calculated with导数可以计算为
>>> from sympy.abc import t
>>> g = Function('g', commutative=False)
>>> gT = Function('gT', commutative=False)
>>> f = g(t) / sqrt(gT(t) * g(t))
>>> f.diff(t).simplify()
(-g(t)*(gT(t)*g(t))**(-1/2)*(gT(t)*Derivative(g(t), t) + Derivative(gT(t), t)*g(t))*(gT(t)*g(t))**(-1) + 2*Derivative(g(t), t)*(gT(t)*g(t))**(-1/2))/2
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.