It seems like Mathematica cannot separate the expression

x / (z + I*y)

into a pure real and imaginary part with the Re[] and Im[] functions. What is the correct way to get the separated parts?

  • 2
    $\begingroup$ Use ComplexExpand to tell Mathematica that variables x, y, and z are reals. Therefore, to get the imaginary part of the expr, ComplexExpand[Im[expr]] $\endgroup$ Feb 6 '17 at 7:51

Use ComplexExpand.

Assuming that x, y and z are all reals:

ComplexExpand[Im[x/(z + I*y)]]
(* -((x y)/(y^2 + z^2)) *)

Assuming that x is complex, the rest are real:

ComplexExpand[Im[x/(z + I*y)], {x}]
(* (z Im[x])/(y^2 + z^2) - (y Re[x])/(y^2 + z^2) *)

See the documentation for Im:

Im[expr] is left unevaluated if expr is not a numeric quantity.



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.