Expressions Involving Complex Variables
Mathematica usually pays no attention to whether variables like

stand for real or complex numbers. Sometimes, however, you may want to make transformations which are appropriate only if particular variables are assumed to be either real or complex.
The function
ComplexExpand expands out algebraic and trigonometric expressions, making definite assumptions about the variables that appear.
| ComplexExpand[expr] | expand expr assuming that all variables are real |
| ComplexExpand[expr,{x1,x2,...}] | expand expr assuming that the are complex |
Expanding complex expressions.
This expands the expression, assuming that

and

are both real.
| Out[1]= |  |
In this case,

is assumed to be real, but

is assumed to be complex, and is broken into explicit real and imaginary parts.
| Out[2]= |  |
With several complex variables, you quickly get quite complicated results.
| Out[3]= |  |
There are several ways to write a complex variable
z in terms of real parameters. As above, for example,
z can be written in the "Cartesian form"
Re[z]+I Im[z]. But it can equally well be written in the "polar form"
Abs[z] Exp[I Arg[z]].
The option
TargetFunctions in
ComplexExpand allows you to specify how complex variables should be written.
TargetFunctions can be set to a list of functions from the set
{Re, Im, Abs, Arg, Conjugate, Sign}.
ComplexExpand will try to give results in terms of whichever of these functions you request. The default is typically to give results in terms of
Re and
Im.
This gives an expansion in Cartesian form.
| Out[4]= |  |
Here is an expansion in polar form.
| Out[5]= |  |
Here is another form of expansion.
| Out[6]= |  |