Ask Your Question

Differentiating Complex Conjugated Functions

asked 2010-11-30 09:18:04 -0500

updated 2010-11-30 09:26:12 -0500

This is primarily a question of understanding the syntax of some output although there might be a bug hidden underneath. Consider the following code:

sage: var('x,t')
sage: q = function('q',x,t)
sage: f = q*q.conjugate()
sage: print f.derivative(x,1)
q(x, t)*D[0](conjugate)(q(x, t))*D[0](q)(x, t) + conjugate(q(x,t))*D[0](q)(x, t)

The answer is supposed to be $d/dx(q\bar{q}) = q_x \bar{q} + q \bar{q}_x$. The second term in the Sage output is correct but I'm having trouble deciphering the first term. Any thoughts?

I think I can narrow down the differences even further. Check it out:

sage: print q.conjugate().derivative(x,1)
D[0](conjugate)(q(x, t))*D[0](q)(x, t)
sage print q.derivative(x,1).conjugate()
conjugate(D[0](q)(x, t))

The independence of order isn't the issue: $q = u + iv$ means that $q_x = u_x + iv_x$, $\bar{q} = u - iv$. So $\bar{q_x} = u_x - iv_x$ and $(\bar{q})_x = (u - iv)_x = u_x - iv_x$.

edit retag flag offensive close merge delete


Depending on the problem you could just define a new function called qbar as long as you don't expect to conjugate an entire expression. Such is my own case and I got the result I wanted.

cswiercz gravatar imagecswiercz ( 2010-11-30 09:31:45 -0500 )edit

@kcrisman - what does `D[0](conjugate)` mean?

d3banjan gravatar imaged3banjan ( 2012-04-17 17:35:54 -0500 )edit

1 answer

Sort by » oldest newest most voted

answered 2011-01-03 15:36:07 -0500

kcrisman gravatar image

updated 2011-01-04 04:01:42 -0500

It looks like Sage is (incorrectly? naively?) applying the chain rule to conjugate(q(x,t)), since conjugate is a pure symbolic thing in Sage a priori. In fact, the multiple variables are irrelevant:

sage: r = function('r',x)
sage: g = r*r.conjugate()
sage: g.derivative(x)
r(x)*D[0](conjugate)(r(x))*D[0](r)(x) + conjugate(r(x))*D[0](r)(x)

sage: r.conjugate().derivative(x)
sage: r.derivative().conjugate()

Ginac (and hence Pynac) does not appear to support doing this - see this. However, presumably one could implement a trivial conjugation to the fderivative or tderivative ... the problem is that I'm not sure whether we should automatically assume that this makes sense. See, for instance, the convoluted discussion at The Maple equivalent of ask.sagemath. On the other hand, Sympy allows this. If there is a consensus, a ticket should be opened, though!

edit flag offensive delete link more


Thanks for the resources. Looking at the Sage source, it seems like a lot of tests for the built-in symbolic functions use conjugate so I imagine that major changes to its behavior could result in broken doctests. It might also boil down to changing the way function._conjugate_ behaves. If anyone else suggests on ask.sage that this is a major issue then I'll post a ticket.

cswiercz gravatar imagecswiercz ( 2011-01-05 05:51:56 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2010-11-30 09:18:04 -0500

Seen: 1,146 times

Last updated: Jan 04 '11