Application Center - Maplesoft

App Preview:

An introduction to complex numbers

You can switch back to the summary page by clicking here.

Learn about Maple
Download Application


 

Complex_Number.mws

> restart: with(plots):

Warning, the name changecoords has been redefined

Complex numbers, an introduction
(by P.H. Stikker)

Introduction

History

Diophantus (ca 250 a.d.) was one of the first mathematicians to discover that the set of real numbers wasn't sufficient.
Pacioli wrote in 1494 in his book 'Summa de Arithmetica' that the equation
x^2+c = b*x was unsolvable unless b^2 is greater than or equal to 4c.
Cardano wrote in his book 'Ars Magna' (1545) the equation
x^4+12 = 6*x^2 is insolvable, because the solutions are 'imaginary'.
Cardano did use the root of a negative number to solve another problem.

Gauss was the first one to call these expressions 'complex numbers'

The great mathematician Bombelli from Bologna made in 1572 in his book 'Algebra' a theory of imaginary and complex numbers.

The number i

We define i to be the number such that i^2 = -1

Maple uses " I " instead of i .
The first mathematician to use this notation was Leonhard Euler (1707 - 1783).

This worksheet

In this worksheet I will explain 5 common ways to write down a complex number. I will not go too much into theory.

Notation 1: a+I*b

Introduction

Gauss (1777 - 1855) first used the notation a+bi .
"a" is called the real part and
"b" is called the imaginary part.
Also Maple knows this:

> Re(2+4*I);

2

> Im(2+4*I);

4

The first question is whether a complex number can be written in more than one way using this notation.
The answer is no, which we prove below:

Proof #1

if a + bI = c + dI <=> (a - c) = (d - b)I
The left-hand side is a real number, but then there must also be a real number on the right-hand side, and this is only true if d - b = 0 => d = b, but then on the left side it must be that a = c

The rules

The rule for addition is as follows:

a+b*I+(c+d)*I = a+c+(b+d)*I

The rule for subtraction is as follows:

a+b*I-(c+d)*I = a-c+(b-d)*I

The rule for multiplication is as follows

(a+b*I)*(c+d*I) = a*c+a*d*I+b*c*I+b*d*I^2 = a*c-b*d+(a*d+b*c)*I

The rule for division is as follows:

(a+b*I)/(c+d*I) = (a+b*I)/(c+d*I)*(c-d*I)/(c-d*I) = (a*c+b*d+(-a*d+b*c)*I)/(c^2+d^2) = (a*c+b*d)/(c^2+d^2)+(-a*d+b*c)/(c^2+d^2)*I

Let's see whether Maple does the same thing:

Addition

> (5+2*I)+(-3+4*I);

2+6*I

Subtraction

> (5+2*I)-(-3+4*I);

8-2*I

Multiplication

> (5+2*I)*(-3+4*I);

-23+14*I

Division

> (5+2*I)/(-3+4*I);

-7/25-26/25*I

You can check by yourself that this is correct.

Notation 2: [a, b]

Introduction

Besides writing numbers down as an expression, we can also write them down as a point.
For th complex numbers this can give some problems, but Sir William Rowan Hamilton (1805 - 1865) gave a good way to do this anyway.
He renamed the often called x-axis to Real-axis and the y-axes to Imaginary-axis.

Fortunately Maple does know a way to plot these coordinates, using 'complexplot'

Plotting complex numbers with Maple

> with(plots):

> complexplot(3+4*I,x=-10..10,style=point);

[Maple Plot]

Uhm, the imaginary axis and real axis doesn't seem to intersect nicely at (0;0). Fortunately, there is a way around this problem:

> complexplot([3+4*I],x=-10..10,style=point);

[Maple Plot]

Although I think most Maple users, uses x, in this case the x-axis should be "Real-Axis", and the y-axis should be "Imaginary-axis", also this can easily be done:

> complexplot([3+4*I],x=-10..10,labels=[Real,Imaginary],style=point);

[Maple Plot]

Also complex functions can be plotted by Maple:

> complexplot(x+x*I,x=-10..10,labels=[Real,Imaginary]);

[Maple Plot]

Notation 3: [r, phi]

Introduction

If we can write a complex number as a point in a cartesian coordinate system, there must be a way represent them in a polar coordinate system.
In a polar coordinate system, we represent points by giving the length of a vector and the angle it makes with the positive x-axis.

Transforming

We want to find a way that a point A(x;y) can be transformed in A(r, phi ).

r is the distance of the vector and phi is the angle with the positive x-axis.
Since we can make a 90 degree triangle using point A(x;y), B(4;0) and O(0;0), r is easily calculated:
(click here to see the triangle)
r = sqrt(x^2+y^2)

and

tan(phi) = y/x

Also Maple can easily transform a complex number:

> convert(4+3*I,polar);

polar(5,arctan(3/4))

Let's check if this is okay:

> r:=sqrt(4^2+3^2);

r := 5

Yes, Maple does it in a correct way.
You can also get just the argument by itself:

> argument(4+3*I);

arctan(3/4)

Plotting polar

As with notation 2, also complex numbers can be easily plotted in polar coordinates by Maple:

> complexplot(x+x*I, x=-30..30,coords=polar,scaling=constrained);

[Maple Plot]

Doing it yourself

Although Maple can plot complex numbers, in below a procedure wich does the same thing, but using in a way the normal plot:

> p:=proc(a,b)
local i,help,pointset:

pointset:=[];

for i from a to b by 0.1 do
help:=subs(x=i,f(x));
pointset:=pointset,[Re(help),Im(help)];
end do:

pointset:=[pointset];
pointset:=subsop(1=NULL, pointset);

pointplot(pointset,style=line,coords=polar,scaling=CONSTRAINED);

end:

> f:=x->x+x*I;

f := proc (x) options operator, arrow; x+I*x end pr...

> p(-30,30);

[Maple Plot]

Notation 4: r*(cos(phi)+I*sin(phi))

Since we already looked at the transformation in the previous notation this one shouldn't be hard to understand.
We already saw that:
r = sqrt(x^2+y^2)

and

tan(phi) = y/x

Using the triangle from A(x,y), B(4;0) and O(0;0)

We can also deduce:
x = r*cos(phi)

y = r*sin(phi)

x and y are a, and b in a + b*I, so substitution gives:

a+b*I = r*cos(phi)+r*sin(phi)

Rearrangement gives then:

a+b*I = r*(cos(phi)+I*sin(phi))

Notation 5: r*exp(I*phi)

The formula of Euler

Euler proved that :
exp(I*phi) = cos(phi)+I*sin(phi)

Therefore any complex number can be written down as:

r*exp(I*phi)

The proof

We know that the function F(x) = exp(x) has the following characteristics:

(1) f(0) = 1

(2) f(x1 + x2) = f(x1) * f(x2) or exp(x1+x2) = exp(x1)*exp(x2)

(3) f(x) > 0, in particular f(x) <> 0

Let's check these conditions with Maple:

> f:=x->exp(x);

f := exp

The first one:

> f(0);

1

Correct, the second one:

> f(a+b);

> f(a)*f(b);

exp(a+b)

exp(a)*exp(b)

Not the same yet, so let's try:

> simplify(%);

exp(a+b)

Correct, and now the last one:

> solve(f(x)=0);

No answer, that is correct.


If z = x + yI, than is E(z) =
exp(x)*(cos(y)+I*sin(y))

For all real values from z it is true that: Im(z) = y = 0, so:
z = x => E(x) =
exp(x)

Are the characteristics (1) and (2) also valid for the function E?
(1) E(0) =
exp(0)*(cos(0)+I*sin(0) = 1*(1+0)) = 1

(2) E(z1) * E(z2) = exp(x1)*(cos(y1)+I*sin(y1))*exp(x2)*(cos(y2)+I*sin(...

= exp(x1)*exp(x2)*(cos(y1)*cos(y2)-sin(y2)*sin(y1)+I*...
exp(x1)*exp(x2)*(cos(y1)*cos(y2)-sin(y2)*sin(y1)+I*...
=
exp(x1+x2)*(cos(y1+y2)+I*sin(y1+y2)) = E(z1+z2)

(3) E(z) <> 0

For a (pure) imaginary number z it is valid that: Re(z) = x = 0

So: E(Iy) = exp(0)*(cos(y)+I*sin(y)) => exp(I*y) = cos(y)+I*sin(y)

Often we write phi instead of y

Some other procedures

Showing all notations

The procedure in below is made to show every type of notation of a complex number:

> complexnotation:=proc()
local cartpoint,polarpoint,t,g:

cartpoint:=[Re(f),Im(f)];
polarpoint:=convert(f,polar);
t:=sqrt((Re(f))^2+(Im(f))^2)*(cos(arctan(Im(f)/Re(f)))+I*sin(arctan(Im(f)/Re(f))));
g:=sqrt((Re(f))^2+(Im(f))^2)*exp(I*(arctan(Im(f)/Re(f)))):

print(`the complex number:`);
print(f);
print(`can also be written as:`);
print(``);
print(`as a cartesian point`);
print(cartpoint);
print(``);
print(`as a polar point`);
print(polarpoint);
print(``);
print(`in r(cos(phi)+I*(sin(phi))`);
print(t);
print(``);
print(`in r*exp(I*phi)`);
print(g);
print(``);
print(`In a complex coordinate system the point can be represented as follows:`);
pointplot([Re(f),Im(f)],labels=[Real,Imaginary]);
end:

> f:=4+2*I:

> complexnotation();

`the complex number:`

4+2*I

`can also be written as:`

``

`as a cartesian point`

[4, 2]

``

`as a polar point`

polar(2*sqrt(5),arctan(1/2))

``

`in r(cos(phi)+I*(sin(phi))`

2*sqrt(5)*(2/5*sqrt(5)+1/5*I*sqrt(5))

``

`in r*exp(I*phi)`

4+2*I

``

`In a complex coordinate system the point can be re...

[Maple Plot]

Showing the triangle

In below a small procedure, showing the triangle mentioned earlier.

> showtriangle:=proc()
local vectorl,pointp,vectorp,j,k:
vectorl:=x->(a/b)*x:
j:=subs(a=Im(f),%):
k:=subs(b=Re(f),%):

if Re(f)>0 then
vectorp:=plot(k,0..Re(f),color=blue,filled=true):
pointp:=pointplot([Re(f),Im(f)],labels=[Real,Imaginary]):
display(vectorp,pointp);
else
vectorp:=plot(k,Re(f)..0,color=blue,filled=true):
pointp:=pointplot([Re(f),Im(f)],labels=[Real,Imaginary]):
display(vectorp,pointp);
end if:
end:

> f:=4+3*I;

f := 4+3*I

> showtriangle();

[Maple Plot]

>

Maple and i

The problem

Let's say we wanted to plot the function of the third root of x. If you didn't have much Maple knowledge you would try:

> f:=x->x^(1/3);

f := proc (x) options operator, arrow; x^(1/3) end ...

> plot(f(x),x=-10..10);

[Maple Plot]

But unfortunately, this is only the positive side. Where are the negative values? (-8)^(1/3) = -2, anyone with some mathematical knowledge knows this.

Solution 1

The problem arises as soon as x<0. You could therefore split the complete function into two parts:
First a function and a graph for only values from x>0:

> f:=x->(x)^(1/3);

f := proc (x) options operator, arrow; x^(1/3) end ...

> plot(f(x),x=-30..30);

[Maple Plot]

The second part should be for x < 0. We will do this by first making x positive again, and than multiply the outcome by -1:

> g:=x->-1*((-1*x)^(1/3));

g := proc (x) options operator, arrow; -(-x)^(1/3) ...

> plot(g(x),x=-30..0);

[Maple Plot]

Now we make both plots as a variable for Maple, and display them in one plot:

> pf:=plot(g(x),x=-30..0):

> gf:=plot(f(x),x=0..30):

> with(plots):

> display(pf,gf);

[Maple Plot]

Solution 2

Fortunately, there is an easier way, using a Maple command called surd:

> surd(x,3);

surd(x,3)

> plot(surd(x,3),x=-30..30);

[Maple Plot]

Why doesn't Maple plot it straight away?

Introduction

The whole problem lies in the fact that Maple works with complex numbers. Although working with these numbers is for us often more complicated, for Maple it is easier and more precise.

It tries to find an answer to the problem: z^3 = -8 .

Although -2 seems an easy answer, Maple finds:

> (-8)^(1/3);

(-8)^(1/3)

> evalf(%);

1.000000000+1.732050807*I

To solve the problem above, Maple follows a different method than that we should choose if our complex number skills aren't very good

"De Moivre"

De Moivre found:

De Moivre:

(cos(phi)+i*sin(phi))^n = cos(n*phi)+i*sin(n*phi) n epsilon Nu

The general solution method for z^n = c becomes:

First, rewrite c to:

c = r*exp((phi+2*k*Pi)*i)

So:

z^n = r*exp((phi+2*k*Pi)*i) => z = r^(1/n)*exp((phi/n+2*k*Pi/n)*i)

for k= 0, 1, 2, ... , n-1 we find all (different) complex solutions.

The example

Let's see how this goes in our example

We wanted to solve:

z^3 = -8

First change it to polar coordinates:

> convert(-8,polar);

polar(8,Pi)

so: r = 8 and n=3, gives:

> 8^(1/3)*exp((Pi/3+2*k*Pi/3)*I);

8^(1/3)*exp(I*(1/3*Pi+2/3*k*Pi))

> z1 := simplify (subs (k=0, %));

z1 := 1+I*sqrt(3)

> z2 := simplify (subs (k=1, %%));

z2 := -2

> z3 := simplify (subs (k=2, %%%));

z3 := 1-I*sqrt(3)

"z1" is the principal root of -8 and therefore Maple with give this answer.

Also via the modulus-argument notation the problem can be found.
In the next paragraph I have done this

A different way

With help from the Euler formulaEuler formula we can now change f(n):

> (8)^(1/3)*(cos((Pi+2*k*Pi)/3)+I*sin((Pi+2*k*Pi)/3));

8^(1/3)*(cos(1/3*Pi+2/3*k*Pi)+I*sin(1/3*Pi+2/3*k*Pi...

> z1 := simplify (subs (k=0, %));

z1 := 1+I*sqrt(3)

> z2 := simplify (subs (k=1, %%));

z2 := -2

> z3 := simplify (subs (k=2, %%%));

z3 := 1-I*sqrt(3)

Once again the same solutions.

A third solution

With use of complex number theory, we can also plot the function. We will have to use a pointplot once again, but the procedure is nicer.

.

> with(plots):

> g:=proc(a,b,c)
local i,j,k,l,m,n,z1,p,q,r,inputset:

inputset:=[];

for j from a to 0 by c do

for i from 0 to b-1 by 1 do
p:=abs(j)+1;
z1:= simplify(subs(k=i,p^(1/b)*exp((Pi/b+2*k*Pi/b)*I)));
if Im(z1)=0 then
inputset:=inputset,[j,z1];
end if:
end do:
end do:


q:=plot((x)^(1/b),x=a..(-1*a),style=line):

inputset:=[inputset];
inputset:=subsop(1=NULL,inputset);
r:=pointplot(inputset,style=line,thickness=0,color=red):
display(q,r);
end:

> g(-27,3,0.1);

[Maple Plot]