Ask Your Question
1

Differentiating Complex Conjugated Functions

asked 2010-11-30 16:18:04 +0200

updated 2010-11-30 16:26:12 +0200

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

Comments

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 16:31:45 +0200 )edit

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

d3banjan gravatar imaged3banjan ( 2012-04-18 00:35:54 +0200 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2011-01-03 22:36:07 +0200

kcrisman gravatar image

updated 2011-01-04 11:01:42 +0200

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)
D[0](conjugate)(r(x))*D[0](r)(x)
sage: r.derivative().conjugate()
conjugate(D[0](r)(x))

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

Comments

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 12:51:56 +0200 )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

Stats

Asked: 2010-11-30 16:18:04 +0200

Seen: 1,809 times

Last updated: Jan 04 '11