Dr. John C. Nardo, Associate Professor

Mathematics & Computer Science

Oglethorpe University

Atlanta, GA

Maple capitalizes the imaginary unit i from Complex Analysis.  You will be tempted to use lower-case i; fight this impulse.  

Also remember in Maple there is no "implied multiplication."  So, if you want to multiply, you must use an asterix.

You "name" objects in Maple using colon and the equal sign.

> z1:=2+3*I;

z1 := 2+3*I

> z2:=10-9*I;

z2 := 10-9*I

Maple performs all of our usual arithmetic operations on complex numbers.

> z1+z2;


> z1-z2;


> z1*z2;


> z1/z2;


Notice that Maple will try to return a complex number in standard a + bi form.  If it does not, then you can force this to happen using the evalc command (evaluate complex expression).

> sqrt(1+I);


> evalc(sqrt(1+I));


Maple can also calculate a complex number's conjugate using the naturally named conjugate command.  Again use the evaluate complex expression evalc command to force standard a + bi form when you get unexpected results.

> z1;


> conjugate(z1);


> z2;


> conjugate(z2);


> sqrt(1+I);


> evalc(sqrt(1+I));


> conjugate(sqrt(1+I));


> evalc(conjugate(sqrt(1+I)));


Maple again uses the naturally named commands Re and Im to find the real and imaginary parts, respectively, of a complex number.

> Re(z1);


> Im(z1);


> Re(z2);


> Im(z2);


> Re(sqrt(1+I));


> Im(sqrt(1+I));


Maple calculates the modulus (via the abs command) and Argument of a complex number (via the argument command).  

Note that Maple is not being exactly precise with its command names!  We know there is a difference between Arg(z) and arg(z).  The first is the name for a unique angle in the half-open interval (-Pi, Pi].  The second is the name for the infinity family of all possible angles.  Since it is returning the one unique angle, Maple should capitalize its argument command, but unfortunately, it does not.  Be mindful of this subtle programming oversight.  

For special angles, Maple will try to return an exact angle.  For other angles, it will simply return the inverse tangent definition (with a + or - to adjust for reference angles).  You can then use the evalf command to force a floating point/decimal number of radians, if needed.  Notice the percent sign % can be used to refer to the last calculation that Maple performed.  

> abs(z1);


> abs(z2);


> abs(7+0*I);


> abs(0+7*I);


> abs(-7+0*I);


> abs(0-7*I);


> argument(z1);


> evalf(%);


> argument(z2);


> evalf(%);


> argument(7+0*I);


> argument(0+7*I);


> argument(-7+0*I);


> argument(0-7*I);


> argument(-1-I);


> argument(-sqrt(3)+I);


Using Maple to calculate the modulus and argument of a complex number, you can "manually" find the polar form of a complex number.  Maple also has a command to streamline the exhausting task of typing two commands to get an "answer."  You can use the convert command.

> -1-I;abs(-1-I);argument(-1-I);




> convert(-1-I,polar);

polar(2^(1/2), -3/4*Pi)

Maple can easily calculate values of the exponential function for both real and complex numbers using the exp command.  You may need the evalc and evalf commands to force Maple to give the output you desire.

> exp(2);


> evalf(exp(2));


> exp(1+I);


> evalc(exp(1+I));


> evalf(%);



Recall how you make functions in Maple via the following syntax:  

name of function : = variable(s) -> rule; .

> f:=x->arcsin(x^2+1);

f := proc (x) options operator, arrow; arcsin(x^2+1) end proc

> f(0);


> g:=(x,y)->exp(x+y);

g := proc (x, y) options operator, arrow; exp(x+y) end proc

> g(1/4,3/4);


We can use this functional structure in Maple to "automate" the complicated root finding process from class.  

Suppose we wish to find the nth root of a complex number.  First, we put the complex number in polar form by finding its modulus and Argument.  Next, we realize that we have n distinct roots; this reinforces that the index of the root is n.    We developed in class the aforementioned formula with inputs r, theta, n, and k.  

At this point, the inputs r, theta, and index are truly known; they aren't really variables in the formula any more.  The only true variable is k which counts out the various roots:  k = 0, 1, 2, ... n - 1.  This gives the function below in Maple.

> complexroots:=(r,theta,index,k)->r*(cos((theta+2*Pi*k)/index)+I*sin((theta+2*Pi*k)/index));

complexroots := proc (r, theta, index, k) options operator, arrow; r*(cos((theta+2*Pi*k)/index)+I*sin((theta+2*Pi*k)/index)) end proc

We can take this out for a "test drive" by calculating the four fourth roots of unity, i.e. the four fourth roots of the complex number 1 + 0i.  

We easily calculate the polar form in our heads:  1 is on the positive real axis.  The distance to the origin is 1; so, the modulus is 1.  The angle made between the positive real axis and the ray through the particular complex number is zero radians since they are the same ray.  We are told to calculate the fourth root; so, the index is 4.  Thus, we conclude:  r = 1, theta = 0, and index = 4.  This leaves the true variable k, and we count out the four distinct roots with k = 0, 1, 2, 3.  

We get the expected results.

> complexroots(1,0,4,0);


> complexroots(1,0,4,1);


> complexroots(1,0,4,2);


> complexroots(1,0,4,3);



The function I have given assumes you know the modulus and Argument of the complex number, i.e. have already put it in polar form.  Given what you have already learned in this handout/sheet, you know that Maple can calulate these values easily.  So, you could modify this function to calculate these two values on the fly.  Then the new/modified complexroots function would only need the a and b (from the a + bi standard form), the index of the root, and the parameter k.  You should try it out!  Make this new complexroots function with inputs a, b, index, and k!