Complex Numbers/Complex Plane

Background

The positive square root of -1

imaginary = Sqrt [ - 1 ]

( - imaginary ) ^ 2

- 1

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

z1 = a +  b ;

z2 = c +  d ;

Simple operations on complex numbers

compadd = z1 + z2 ;

compmult = z1 * z2 ;

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

( a + b ) ( c + d )

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

Re[compadd]

Im[compadd]

- Im [ b ] - Im [ d ] + Re [ a + c ]

Im [ a + c ] + Re [ b ] + Re [ d ]

However, the Mathematica function ComplexExpand does assume that the variables are real....

ComplexExpand [ Re [ compadd ] ]

a + c

ComplexExpand [ Im [ compadd ] ]

b + d

ComplexExpand [ Re [ z1 / z2 ] ]

a c c 2 + d 2 + b d c 2 + d 2

ComplexExpand [ compmult ]

a c - b d + ( b c + a d )

ComplexExpand[Re[z1^3]]

ComplexExpand[Im[z1^3]]

a 3 - 3 a b 2

3 a 2 b - b 3

Function to convert to Polar Form

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

Note: the function Arg[z] returns an angle in the range -π to π which measures the inclination of z with respect to the +Re axis in the complex plane.

Pform [ z1 ]

Arg [ a + b ] Abs [ a + b ]

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

- ArcTan [ π 2 ] 4 + π 2

ComplexExpand [ Pform [ z1 ] ]

a 2 + b 2 Cos [ Arg [ a + b ] ] + a 2 + b 2 Sin [ Arg [ a + b ] ]

Numerical Precision and Complex Rounding

ExactlyOne = Exp [ 2 π ]

1

NumericallyOne = Exp [ N [ 2 π ] ]

1. - 2.449293598294706 × 10 - 16

Chop [ NumericallyOne ]

1.

Round [ NumericallyOne ]

1

ExactlyI = Exp [ π / 2 ]

NumericallyI = Exp [ N [ π / 2 ] ]

6.123233995736766 × 10 - 17 + 1.

Round [ NumericallyI ]

Chop [ NumericallyI ]

1.

ExactlyOnePlusI = ComplexExpand [ 2 Exp [ π / 4 ] ]

1 +

NumericallyOnePlusI = ComplexExpand [ 2 Exp [ N [ π / 4 ] ] ]

1. + 1.0000000000000002

Chop [ NumericallyOnePlusI ]

1. + 1.0000000000000002

Round [ NumericallyOnePlusI ]

1 +

Re [ NumericallyOnePlusI ]

1.

Im [ NumericallyOnePlusI ]

1.0000000000000002

Roots to Polynomial Equations

Complex numbers frequently appear in the solution of roots to polynomial equations:

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

{ { x 1 4 - 7 4 - 1 2 5 2 - 7 2 } , { x 1 4 - 7 4 + 1 2 5 2 - 7 2 } , { x 1 4 + 7 4 - 1 2 5 2 + 7 2 } , { x 1 4 + 7 4 + 1 2 5 2 + 7 2 } }

The next statement produces a list of the complex solutions of the polynomial:

x /. sols

{ 1 4 - 7 4 - 1 2 5 2 - 7 2 , 1 4 - 7 4 + 1 2 5 2 - 7 2 , 1 4 + 7 4 - 1 2 5 2 + 7 2 , 1 4 + 7 4 + 1 2 5 2 + 7 2 }

Im [ x /. sols ]

{ - 7 4 + Im [ - 1 2 5 2 - 7 2 ] , - 7 4 + Im [ 1 2 5 2 - 7 2 ] , 7 4 + Im [ - 1 2 5 2 + 7 2 ] , 7 4 + Im [ 1 2 5 2 + 7 2 ] }

ComplexExpand [ Im [ x /. sols ] ]

{ - 7 4 + Sin [ 1 2 ArcTan [ 7 5 ] ] 2 1 / 4 , - 7 4 - Sin [ 1 2 ArcTan [ 7 5 ] ] 2 1 / 4 , 7 4 - Sin [ 1 2 ArcTan [ 7 5 ] ] 2 1 / 4 , 7 4 + Sin [ 1 2 ArcTan [ 7 5 ] ] 2 1 / 4 }

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

{ - 0.458821464672557 , - 0.8640541908597383 , 0.458821464672557 , 0.8640541908597383 }

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

{ - 0.5661209411559501 , 1.0661209411559502 , - 0.5661209411559501 , 1.0661209411559502 }

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

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

This will give a list of rules that can be used to find solutions;as "b" is unspecified the rules depend on the symbol "b"

General :: spell1 : Possible spelling error: new symbol name \" bsols \" is similar to existing symbol \" sols \". More… "Possible spelling error: new symbol name \\\"\\!\\(bsols\\)\\\" is similar to existing symbol \\\"\\!\\(sols\\)\\\". \\!\\(\\*ButtonBox[\\\"More\[Ellipsis]\\\", ButtonStyle->\\\"RefGuideLinkText\\\", ButtonFrame->None, ButtonData:>\\\"General::spell1\\\"]\\)"

{ { x 1 4 - 1 2 ( 1 4 + ( 2 3 ) 1 / 3 ( 4 + b ) ( 9 + 9 b 2 + 3 - 229 - 192 b + 6 b 2 - 4 b 3 + 27 b 4 ) 1 / 3 + ( 9 + 9 b 2 + 3 - 229 - 192 b + 6 b 2 - 4 b 3 + 27 b 4 ) 1 / 3 2 1 / 3 3 2 / 3 ) - 1 2 ( 1 2 - ( 2 3 ) 1 / 3 ( 4 + b ) ( 9 + 9 b 2 + 3 - 229 - 192 b + 6 b 2 - 4 b 3 + 27 b 4 ) 1 / 3 - ( 9 + 9 b 2 + 3 - 229 - 192 b + 6 b 2 - 4 b 3 + 27 b 4 ) 1 / 3 2 1 / 3 3 2 / 3 - 1 - 8 b 4 1 4 + ( 2 3 ) 1 / 3 ( 4 + b ) ( 9 + 9 b 2 + 3 - 229 - 192 b + 6 b 2 - 4 b 3 + 27 b 4 ) 1 / 3 + ( 9 + 9 b 2 + 3 - 229 - 192 b + 6 b 2 - 4 b 3 + 27 b 4 ) 1 / 3 2 1 / 3 3 2 / 3 ) } , { x 1 4 - 1 2 ( 1 4 + ( 2 3 ) 1 / 3 ( 4 + b ) ( 9 + 9 b 2 + 3 - 229 - 192 b + 6 b 2 - 4 b 3 + 27 b 4 ) 1 / 3 + ( 9 + 9 b 2 + 3 - 229 - 192 b + 6 b 2 - 4 b 3 + 27 b 4 ) 1 / 3 2 1 / 3 3 2 / 3 ) + 1 2 ( 1 2 - ( 2 3 ) 1 / 3 ( 4 + b ) ( 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3 2 / 3 ) + 1 2 ( 1 2 - ( 2 3 ) 1 / 3 ( 4 + b ) ( 9 + 9 b 2 + 3 - 229 - 192 b + 6 b 2 - 4 b 3 + 27 b 4 ) 1 / 3 - ( 9 + 9 b 2 + 3 - 229 - 192 b + 6 b 2 - 4 b 3 + 27 b 4 ) 1 / 3 2 1 / 3 3 2 / 3 + 1 - 8 b 4 1 4 + ( 2 3 ) 1 / 3 ( 4 + b ) ( 9 + 9 b 2 + 3 - 229 - 192 b + 6 b 2 - 4 b 3 + 27 b 4 ) 1 / 3 + ( 9 + 9 b 2 + 3 - 229 - 192 b + 6 b 2 - 4 b 3 + 27 b 4 ) 1 / 3 2 1 / 3 3 2 / 3 ) } }

Because it is a long set of rules and hard to follow, let's look at the form of bsols:

Dimensions [ bsols ]

{ 4 , 1 }

Short produces a very abbreviated form of the solution… in this case limited to 3 lines by the optional parameter.

Short [ bsols , 3 ]

{ { x 1 4 - 1 2 1 4 + 1 1 + 1 1 - 1 2 1 2 - ( 2 3 ) 1 / 3 ( 4 + b ) ( 1 ) 1 / 3 - 1 2 1 1 - 1 - 8 b 4 1 4 + 1 1 1 1 1 + ( 1 ) 1 / 3 2 1 1 1 1 } , 3 }

So we see that bsols is a list of length 4 of list containing one rule. (Solutions to equations are always this way, it is a list of the number of solutions, each member being a rule for each variable that is solved for...)

In our case of one variable, the extra layer of lists is not terribly useful, one way to get rid of the extra layers is to use Flatten:

Dimensions[Flatten[bsols]]

Short[Flatten[bsols], 3]

{ 4 }

{ x 1 4 - 1 2 1 4 + 1 1 + 1 1 - 1 2 1 2 - ( 2 3 ) 1 / 3 ( 4 + b ) ( 1 ) 1 / 3 - ( 1 ) 1 / 3 2 1 3 1 - 1 - 8 b 4 1 4 + 1 1 1 1 + ( 1 ) 1 / 3 2 1 1 1 1 , 3 }

In the next command, we produce a list of values (not of rules, because we have taken x and applied every rule in bsols to it... These values are the imaginary parts of the solutions x that make the polynomial vanish (and a function of b, because it hasn't been specified yet)

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

Dimensions[imb]

Short[imb[[1]]]

{ 4 }

- 1 2 1 1 Sin [ 1 2 Arg [ 1 4 + 1 1 + 1 1 2 1 1 ] ] - 1

And likewise for the real parts of x that solve the polynomial equation

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

Plot[] expects a list of functions to plot, The "Flatten" function ensures that Plot is getting a list, but it is redundant in this particular case.  This plot works as follows, for each member in the list, plot the result of replacing b with q for values of q between -10, 10---it is a long-handed way of seeing exactly what is going on and demonstrates the replacement technique.

So the following should be  a plot of the imaginary values of x as a function of b.

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

[Graphics:HTMLFiles/Lecture-08_11.gif]

Graphics

In fact, we should be able to do the  same thing without replacement as the following shows, it is probably instructive to show both ways.

Plot [ Evaluate [ imb ] , { b , - 10 , 10 } ]

[Graphics:HTMLFiles/Lecture-08_12.gif]

Graphics

There are a few problems that make it difficult to interpret the graph---one is the numerical noise that makes the solutions
jump back and forth; second, because all the colors are the same,  it is not clear which values of x belong to the same solution.  

Let's first try to make each member of the list (remember, there are 4 because it is a fourth-order polynomial and because Dimensions[imb] told us so...

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

[Graphics:HTMLFiles/Lecture-08_13.gif]

Graphics

The plot above is a little better, it looks like the blue curve comes in from the northeast and then then its imaginary part vanishes at a critical values of q (around -0.5), the cyan curve is probably the minus values of the blue curve... and the same thing for yellow and green.  It is much easier to see the branches of solutions for the real parts below.

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

[Graphics:HTMLFiles/Lecture-08_14.gif]

Graphics

But here, because the lines are the same thickness, we don't know if the cyan and blue curves just "stop." Let's find out by also adjusting their thickness.

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

[Graphics:HTMLFiles/Lecture-08_15.gif]

Graphics

It is pretty clear that the parameter b is behaving like a "pitchfork" bifurcation---there is one value of x upto a critical value of b, where x splits into two solutions.  This is a picture of two isolated pictchforks.


Created by Mathematica  (October 3, 2005) Valid XHTML 1.1!