2

当我尝试用 SymPy 区分符号时,我得到以下信息

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

当我区分符号与其共轭时,结果是

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

但是,当我尝试区分符号 SymPy 的共轭时,它并没有做到这一点

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

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

4

1 回答 1

1

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).

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)).

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).

于 2013-07-05T18:59:05.983 回答