4
$\begingroup$

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?

$\endgroup$
  • 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$ – Anjan Kumar Feb 6 '17 at 7:51
5
$\begingroup$

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) *)
$\endgroup$
0
$\begingroup$

See the documentation for Im:

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

http://reference.wolfram.com/language/ref/Im.html

$\endgroup$

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.