I am working with cumbersome equations, that contain a lot of terms. Here I will consider simple example:
v[x_, y_, t_] = {D[Ψ[x, y, t], {y, 1}], -D[Ψ[x, y, t], {x, 1}]}; r = {x, y}; II = {{1, 0}, {0, 1}}; Q = {{n1[x, y, t], n2[x, y, t]}, {n2[x, y, t], -n1[x, y, t]}}; p1 = D[Q, t] + v[x, y, t].Grad[Q, r]; eq1=p1[[1, 1]] + I*p1[[2, 1]] eq2=p1[[1, 2]] + I*p1[[2, 2]] As a result, I have two scalar equations (which I treat as expressions, omitting zero right hand side), eq1, eq2:
$n1_t+\Psi_y n1_x-n2_x\Psi_x+i(n2_t+\Psi_y n2_x+n1_x\Psi_x)$
$n2_t+\Psi_y n1_y-n2_y\Psi_x+i(-n1_t+\Psi_y n2_y+n1_y\Psi_x)$
I want to rewrite them in terms of a new variable, $n=n1+i*n2$. As a result, I should get:
$n_t+\Psi_y n_x+in_x\Psi_x$
$-in_t+\Psi_y n_y+in_y\Psi_x$
I calculated it on the paper, but it is easy to verify, that these are correct answers:
n[x_, y_, t_] = n1[x, y, t] + I*n2[x, y, t]; eq1r = D[n[x, y, t], t] + D[Ψ[x, y, t], y]*D[n[x, y, t], x] + I*D[Ψ[x, y, t], x] D[n[x, y, t], x]; eq2r = -I*D[n[x, y, t], t] + D[Ψ[x, y, t], y]*D[n[x, y, t], y] + I*D[Ψ[x, y, t], x] D[n[x, y, t], y]; Simplify[eq1 - eq1r] Simplify[eq2 - eq2r] How can I do it automatically? Note, that it is not always possible to write the answer in terms of n and it's derivatives. Sometimes it could involve complex conjugate of n, or even Re[n] and Im[n], which are n1 and n2 correspondingly.
Hope it is clear what I want. I tried to use simple substitution ./, but I cannot make it work with eq1/.n1[x,y,t]->Re[n[x,y,t]].
For example, the following equation can be rewritten in terms of n and it's coplex conjugate (and derivatives):
v[x_, y_, t_] = {D[Ψ[x, y, t], {y, 1}], -D[Ψ[x, y, t], {x, 1}]}; r = {x, y}; II = {{1, 0}, {0, 1}}; Q = {{n1[x, y, t], n2[x, y, t]}, {n2[x, y, t], -n1[x, y, t]}}; A = 1/2*(D[v[x, y, t], {r}] + Transpose[D[v[x, y, t], {r}]]); Ω = 1/2*(D[v[x, y, t], {r}] - Transpose[D[v[x, y, t], {r}]]); p2 = Simplify[(ξ*A + Ω).(Q + II/2)]; eq=p2[[1, 1]] + I*p2[[2, 1]] 


