Complex Numbers/Complex Plane

Background

The positive square root of -1

imaginary  = Sqrt[-1]

(-imaginary)^2

Complex numbers are composed of a real part + an imaginary part

z1  =  a  +  I b;
z2 =  c  +  I d;

Simple operations on complex numbers

compadd  =  z1  +  z2;

compmult  =  z1*z2;

Simplify[compmult, 
      a ∈  Reals  &&  b ∈  Reals  && 
        c  ∈  Reals  &&  d  ∈  Reals ]

Mathematica does not assume that symbols are necessarily real...

Re[compadd]
Im[compadd]

However, the Mathematica function ComplexExpand assumes that the variables are real....

ComplexExpand[Re[compadd]]

ComplexExpand[Im[compadd]]

ComplexExpand[Re[z1/z2]]

ComplexExpand[compmult]

ComplexExpand[Re[z1^3]]
ComplexExpand[Im[z1^3]]

Function to convert to Polar Form

Pform[z_]  :=  Abs[z] Exp[I Arg[z]]

Pform[z1]

Pform[z1 /. {a -> 2, b -> -π}]

ComplexExpand[Pform[z1]]

Numerical Precision and Complex Rounding

ExactlyOne  =  Exp[2 π I]

NumericallyOne  = Exp[N[2 π I]]

Chop[NumericallyOne]

Round[NumericallyOne]

ExactlyI  =  Exp[π I/2]

NumericallyI  =  Exp[N[π I/2]]

Round[NumericallyI]

Chop[NumericallyI]

ExactlyOnePlusI  =  
      ComplexExpand[(Sqrt[2]) Exp[π  I/4]]

NumericallyOnePlusI  =  
      ComplexExpand[(Sqrt[2]) Exp[N[π  I/4]]]

Chop[NumericallyOnePlusI]

Round[NumericallyOnePlusI]

Re[NumericallyOnePlusI]

Im[NumericallyOnePlusI]

Roots to Polynomial Equations

One place that complex numbers appear is in the solution of roots to polynomial equations

sols  =  
      Solve[(x^4  - x^3  + x  + 1)  ==  0, x]

Im[x /. sols]

ComplexExpand[Im[x /. sols]]

ComplexExpand[Im[x /. sols]] // N

ComplexExpand[Re[x /. sols]] // N

Generalize the above to a family of solutions: find b such that imaginary part vanishes

bsols  =  
      Solve[(x^4  - x^3  + b*x  + 1)  ==  0, x]

imb  = ComplexExpand[Im[x /. bsols]];

imr = ComplexExpand[Re[x /. bsols]];

Plot[
      Evaluate[Flatten[imb] /. b -> q], {q, -10, 10}]

Plot[Evaluate[Flatten[imb] /. b -> q], {q, -10, 10}, 
      PlotStyle -> Table[{Hue[a/6]}, {a, 1, 4}]]

Plot[Evaluate[Flatten[imr] /. b -> q], {q, -10, 10}, 
      PlotStyle -> Table[{Hue[a/6]}, {a, 1, 4}]]

Plot[Evaluate[Flatten[imr] /. b -> q], {q, -10, 10}, 
      PlotStyle -> 
        Table[{Hue[a/6], Thickness[0.05 -  .01*a]}, {a, 1, 4}]]