0

I define

ψ1 = Sqrt[Subscript[ρ, 1][t]] E^(I Subscript[θ, 1][t]);
ψ2 = Sqrt[Subscript[ρ, 2][t]] E^(I Subscript[θ, 2][t]);

and

eq1 = (I ℏ D[ψ1, t] - U ψ1 - K ψ2)/E^(I Subscript[θ, 1][t]) // FullSimplify

gives

enter image description here

I want to get the imaginary part of the above expression where $\rho$ is positive, and $\theta$ is real.

The result should be

enter image description here

while ComplexExpand gives

enter image description here

How do I do it correctly?

m_goldberg
  • 107,779
  • 16
  • 103
  • 257
matheorem
  • 17,132
  • 8
  • 45
  • 115
  • 1
    If you simplify assuming Subscript[ρ, 1][t] > 0 and Subscript[ρ, 2][t] > 0, it works as expected – Lukas Lang May 30 '18 at 07:23
  • 2
    FYI, You should avoid using Subscript while defining symbols (variables). Subscript[x, 1] is not a symbol, but a composite expression where Subscript is an operator without built-in meaning. You expect to do $x_1=2$ but you are actually doing Set[Subscript[x, 1], 2] which is to assign a Downvalue to the operator Subscript and not an Ownvalue to an indexed x as you may intend. – rhermans May 30 '18 at 08:16

1 Answers1

2

Try the following.

Here are your expressions:

ψ1 = 
  Sqrt[Subscript[ρ, 1][t]] E^(I Subscript[θ, 1][t]);
ψ2 = 
  Sqrt[Subscript[ρ, 2][t]] E^(I Subscript[θ, 2][t]);
eq1 = 
  (I*ℏ D[ψ1, t] - U ψ1 - k ψ2)/E^(I Subscript[θ, 1][t]) // FullSimplify

enter image description here

I assume, your K is not the reserved Mma constant and replaced it, therefore, by the small k above.

Let us now represent the exponent in the trigonometric form and replace the imaginary unit by any letter, say, by X for further use:

eq2 = ExpToTrig[eq1];
eq3=eq2 /. Complex[0, a_] -> X*a

enter image description here

Now this:

Coefficient[eq3, X]

makes the job:

enter image description here

Have fun!

m_goldberg
  • 107,779
  • 16
  • 103
  • 257
Alexei Boulbitch
  • 39,397
  • 2
  • 47
  • 96
  • Great, I actually tried i->x before, however, it can not replace the i/2. Clever trick for Complex[0, a_] -> X*a – matheorem May 31 '18 at 00:23