Confirming conservation laws for complex valued functions

Consider the nonlinear Schrödinger equation (I would like to do this for a more complicated set of equations, but to gain understanding I'll consider this simplified case)

$$A_t+iA_{xx}+i|A|^2A =0,$$

where $A=A(x,t)$ is a complex valued function.

One can calculate several conservation laws by looking at the obvious symmetries of its associated action. For instance, we have

$$\frac{\partial |A|^2}{\partial t} +\frac{\partial P}{\partial x} = 0$$

where $$P=i(A^*A_x-AA^*_x)$$

Let's say I wanted to check my variational calculus, and make sure this is in fact true, how would I go about doing this in Mathematica?

$\textbf{EDIT}$: I suppose I'll give some code, to try to provoke some interest.

When solving a simple conservation law $f_t+f_x=0$, the following seems to work

FullSimplify[D[f[x, t], t] + D[f[x, t], x],
Assumptions -> {D[f[x, t], t] == -D[f[x, t], x]}]

However, when I try something comparable for the conservation law given above, e.g.

FullSimplify[
D[u[x, t]^2 + v[x, t]^2, t] -
2 (u[x, t]*D[v[x, t], x] + v[x, t]*D[u[x, t], x]),
Assumptions -> {D[u[x, t],
t] == -(D[u[x, t], x, x] + (u[x, t]^2 + v[x, t]^2)*u[x, t]),
D[v[x, t],
t] == -(D[v[x, t], x, x] + (u[x, t]^2 + v[x, t]^2)*v[x, t])}]

where I've written $A=u+iv$, for $u,v$ real functions. This doesn't yield any type of simplification. In fact it just returns

2 (v[x,t] ((v^(0,1))[x,t]-(u^(1,0))[x,t])+u[x,t] ((u^(0,1))[x,t]-(v^(1,0))
[x,t]))

i.e. no simplification.

$\textbf{Edit 2}$: My algebra was incorrect, this method works in Mathematica using Assumptions.

FullSimplify[
D[u[x, t]^2 + v[x, t]^2, t] -
2 D[(u[x, t]*D[v[x, t], x] - v[x, t]*D[u[x, t], x]), x],
Assumptions -> {D[u[x, t],
t] == (D[v[x, t], x, x] + (u[x, t]^2 + v[x, t]^2)*v[x, t]),
D[v[x, t],
t] == -(D[u[x, t], x, x] + (u[x, t]^2 + v[x, t]^2)*u[x, t])}]
• Congratulations on solving your problem. Any idea on how bounty works in the event that you write up your Edit 2 as an answer? – bbgodfrey Jul 1 '15 at 1:05
• @bb: OP will not get the invested rep back even if he answers his own question. – J. M. will be back soon Jul 1 '15 at 5:44

The following may be slightly more direct than the approach given in the answer. I don't split up the wave function into real and imaginary parts, so I can work with the original equations, making it easier to spot errors.

The equation I want to check is eqn, and the equation of motion is nLS. I use two different function names for $\psi$ and its complex conjugate: ψ and ψStar. This avoids trouble with derivatives of the Conjugate function. I'll print out the intermediate results so you can see that every step remains close to what you would do by hand:

eqn =
D[ψ[x, t] ψStar[x, t], t] +
I D[(D[ψ[x, t], x] ψStar[x, t] - ψ[x,
t] D[ψStar[x, t], x]), x] == 0

$$i \left(\psi ^{(2,0)}(x,t) \text{\psi Star}(x,t)-\psi (x,t) \text{\psi Star}^{(2,0)}(x,t)\right)+\psi ^{(0,1)}(x,t) \text{\psi Star}(x,t)+\psi (x,t) \text{\psi Star}^{(0,1)}(x,t)=0$$

nLS =
D[ψ[x, t], t] == -I D[ψ[x, t], x, x] -
I ψ[x, t]^2 ψStar[x, t]

$$\psi ^{(0,1)}(x,t)=-i \psi ^{(2,0)}(x,t)-i \psi (x,t)^2 \text{\psi Star}(x,t)$$

nLSstar =
nLS /. {ψ -> ψStar, ψStar -> ψ,
Complex[x_, y_] -> Complex[x, -y]}

$$\text{\psi Star}^{(0,1)}(x,t)=i \psi (x,t) \text{\psi Star}(x,t)^2+i \text{\psi Star}^{(2,0)}(x,t)$$

Simplify[eqn, Assumptions -> (nLS && nLSstar)]

True

In nLSstar, I form the complex conjugate of the equation of motion, by directly exchanging the functions and reversing the sign of $i$. Using the the result in the Assumptions, Simplify is able to verify the claim.