The results of DSolve
are usually expressions that can be further simplified. For instance, consider the following expression for a co-ordinate of a particle in constant magnetic field,
z[t] -> -((1/(2*(Bx^2 + By^2 + Bz^2)^2))*(E^(t*(-Sqrt[-Bx^2 - By^2 - Bz^2]))*
(-(2*Bx^2*Bz^2*t*E^(t*Sqrt[-Bx^2 - By^2 - Bz^2])) -
2*By^2*Bz^2*t*E^(t*Sqrt[-Bx^2 - By^2 - Bz^2]) + Bx^2*Sqrt[-Bx^2 - By^2 - Bz^2]*
E^(2*t*Sqrt[-Bx^2 - By^2 - Bz^2]) + By^2*Sqrt[-Bx^2 - By^2 - Bz^2]*
E^(2*t*Sqrt[-Bx^2 - By^2 - Bz^2]) - By^2*Sqrt[-Bx^2 - By^2 - Bz^2] -
Bx^2*Sqrt[-Bx^2 - By^2 - Bz^2] - 2*Bz^4*t*E^(t*Sqrt[-Bx^2 - By^2 - Bz^2]))))
I want to define absB^2 = Bx^2 + By^2 + Bz^2
, so that the exponential and denominators are simple and the output is more readable. However if I simply define it as a rule Bx^2 + By^2 + Bz^2 -> absB^2
, mathematica fails to make the substitution in the exponentials (it works for the denominators), likely because of the negative signs. In this case I can make do by putting in another rule Bx^2 + By^2 +Bz^2 -> I abs B
, but that doesn't seem a principled approach to me. Another idea I had was something like Bx -> Sqrt[absB^2 - By^2 -Bz^2]
, but that will mess up all the Bx
elsewhere.
How should I do it? All quantities are real, but as long as the complex numbers occur as exponentials only it's fine.
Bx
was replaced byabsB
, any guesses why? $\endgroup$