sympy中共轭的导数 [英] Derivative of a conjugate in sympy

查看:345
本文介绍了sympy中共轭的导数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试使用SymPy区分符号时,得到以下内容

When I try to differentiate a symbol with SymPy I get the following

In : x=Symbol('x')
In : diff(x,x)
Out: 1

当我将符号相对于其共轭进行区分时,结果为

When I differentiate the symbol respect to its conjugate the result is

In [55]: diff(x,x.conjugate())
Out[55]: 0

但是,当我尝试区分符号SymPy的共轭时,<​​/p>

However, when I try to differentiate the conjugate of the symbol SymPy doesn't do it

In : diff(x.conjugate(),x)
Out: Derivative(conjugate(x), x)

这仍然是正确的,但结果应为零.如何使SimPy执行共轭的导数?

This is still correct, but the result should be zero. How can I make SimPy perform the derivative of a conjugate?

推荐答案

我不确定diff(conjugate(x), x)是否应为零. diff(x,x.conjugate())给出零的事实与数学无关(甚至可能被认为是SymPy错误).它给出零仅仅是因为x不包含conjugate(x)(象征性地),因此将其视为相对于它的常量.这可能是错误的,因为x相对于conjugate(x)而言不是常数.实际上,SymPy允许您对定义的函数进行派生的事实可能是一个错误.应该允许使用diff(f(x)**2, f(x))之类的东西,其中f = Function('f')是未定义的函数,但是对于已定义的函数,从数学上来说,这可能是错误的(或者至少不是您期望的).

I'm not sure about the mathematics if diff(conjugate(x), x) should be zero. The fact that diff(x,x.conjugate()) gives zero has nothing to do with mathematics (and might even be considered a SymPy bug). It gives zero simply because x does not contain conjugate(x) (symbolically), so it sees it as a constant with respect to it. This is probably wrong, since x is not a constant with respect to conjugate(x). The fact that SymPy lets you take derivatives with respect to defined functions is probably a bug, actually. It is supposed to allow things like diff(f(x)**2, f(x)), where f = Function('f') is an undefined function, but for defined functions, it is probably mathematically incorrect (or at least not what you expect).

请参见 http://docs .sympy.org/latest/modules/core.html?highlight = derivative#sympy.core.function.Derivative ,尤其是有关非符号衍生工具的部分.换句话说,相对于函数取导数只是一种符号上的方便,而并不代表数学上的链式规则.相反,应该将diff(x, conjugate(x))之类的东西视为diff(x.subs(conjugate(x), dummy), dummy).subs(dummy, conjugate(x))之类的东西.

See http://docs.sympy.org/latest/modules/core.html?highlight=derivative#sympy.core.function.Derivative, particularly the section on derivatives wrt non-Symbols. To paraphrase, taking derivatives with respect to a function is just a notational convenience and does not represent a mathematical chain rule. Rather, something like diff(x, conjugate(x)) should be thought of as something like diff(x.subs(conjugate(x), dummy), dummy).subs(dummy, conjugate(x)).

关于conjugate(x).diff(x),由于未定义共轭的导数,因此给出了未评估的导数.我不确定这里是否有任何封闭形式的答案.这可能是SymPy可能返回的最有用的东西.关于此问题的合理答案,我在任何地方都找不到任何好的答案(您应该要求数学SE以获得更好的答案).

Regarding conjugate(x).diff(x), this gives an unevaluated derivative because no derivative is defined for conjugate. I'm not sure if any closed-form answer is possible here anyway. Probably this is the most useful thing that SymPy could return. I can't find any good answers anywhere as to what a reasonable answer for this should be (you should ask on math SE to get a better answer about it).

这篇关于sympy中共轭的导数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆