SymPy:我可以安全地区分 atan2() 吗? [英] SymPy: Can I safely differentiate atan2()?
问题描述
我想获得一个符号表达式,它是 atan2(y,x)
的导数,其中 y
和 x
是一些带有变量 z
的表达式.我可以安全地假设 diff(atan2(y,x),z)
给了我我想要的吗?
I would like to obtain a symbolic expression which is the derivative of atan2(y,x)
, where y
and x
are some expressions with a variable z
. Can I safely assume that diff(atan2(y,x),z)
gives me what I want?
在 math.stackexchange.com 中有证据表明atan2
在 (-pi,pi) 中是连续可微的,但在 SymPy 中是吗?
In math.stackexchange.com there is a proof that atan2
is continuously differentialable in (-pi,pi), but is it in SymPy?
推荐答案
atan2(y, x)
关于 x
和 y 的偏导数
由 SymPy 计算为
The partial derivatives of atan2(y, x)
with respect to x
and y
are computed by SymPy as
-y/(x**2 + y**2)
x/(x**2 + y**2)
并且这些表达式是连续的,只要 x, y
不立即变成零.(当然,假设是实参 x、y - 我认为没有人会在 atan2
中放入复数).
and these expressions are continuous as long as x, y
do not turn into zero at once. (Assuming real arguments x, y, of course - I don't think anyone puts complex numbers in atan2
).
以上公式是硬编码的herea>,所以我们可以非常确定 SymPy 会返回它们.
The above formulas are hardcoded here, so we can be very sure that SymPy will return them.
这篇关于SymPy:我可以安全地区分 atan2() 吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!