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$
1
  • 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, 2017 at 7:51

2 Answers 2

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 and acknowledge that you have read and understand our privacy policy and code of conduct.

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