Tutorial 105


MAPLE is a powerful computer algebra system that can perform many mathematical calculations. It can also be used as a programming language. This lab is intended to introduce both of these capabilities. The MAPLE program is available to UCCS students in the computer lab in EAS 136.

Logging into the System

On the log-in screen, you will see a prompt for your username and password. Type in your username first. This will be the first letter of your first name followed by the first seven letters (or less) of your last name. For example, if your name is John Williams, then your username will be JWilliam.

If you have not previously logged in, you will need the initial password. This is usually the first eight digits of your student ID number. After you log in you will be asked to change this password, make sure you remember it!


If for some reason either your username or your password does not work, first check that the DOMAIN is set to UFP. If it still doesn't work, ask someone for help.


Starting out with MAPLE

Double click the MAPLE icon on the desktop. This will open a MAPLE worksheet, and you should see a prompt in the upper left corner that looks like this:


Maple as a Calculator

The prompt is where everything begins and ends in MAPLE. Now we will look at a few of the functions MAPLE can perform. First, notice that MAPLE can function as an expensive calculator. Try typing the following:

> 2+2;

If you did this correctly, you should get the answer displayed underneath in blue. (Notice that all commands in MAPLE are displayed in red, while solutions are displayed in blue. Text will be in black.)


You have to end commands in maple with a colon or a semicolon. If you end a line with a colon, the command will be executed, but the solution will not be displayed. If you end a line with a semicolon (as above), the solution will be displayed in blue in the middle of the screen.

We can continue with multiplication. The asterisk symbol (*) is used to indicate multiplication. You cannot leave it out. Try typing the following lines:

> 2*2;

> (2)(2);

Notice that the line without the asterisk gives the wrong solution.

Subtraction should be written as follows:

> 5-3;

Now on to division. Try typing the following line:

> 5/3;

Notice that MAPLE simply reproduces the fraction. In order to come up with a decimal solution, try typing 5.0 instead of 5 in the equation. This tells MAPLE that you want a decimal answer. Then you will get the following solution:

> 5.0/3;

MAPLE also has a function that will automatically evaluate the expression entered. It is called evalf(). Try typing

> evalf(5/3);

This command evaluates the expression and gives you the answer in what the computer calls a "floating point" number. That just means that it will give you the answer in decimal form.

Now try a few of your own calculations!

Assigning Variables in MAPLE

It is often convenient to take a long expression and give it a name. That way, you don't have to repeatedly type in the long expression. Assignment in MAPLE is done with the operator ':='. For example, the following line assigns the letter 'a' the approximate value of Pi.

> a:=3.14159;

Now every time the letter 'a' is used in an expression, it will actually refer to the value for Pi! Try typing the following:

> a;

> 2*a;


If you try to use just the '=' instead of ':=', the assignment will not be made

Help in MAPLE

In the example above, the value for Pi was assigned to a variable to save it. Does the value for Pi have to be entered everytime it is used? Maybe MAPLE has a better choice. There are two ways to find help in MAPLE. The first is to use the scroll down menu at the top of the screen. This menu is very similar to the help used in other programs. Simply use the mouse to click on 'Help', and then select the option of your choice. The second way to find help in MAPLE is to use the command line. The command for help is a question mark '?' followed by a search string. Try typing the following line and then pressing 'Enter'.

> ?Pi

MAPLE brought up a window with not just Pi listed, but also some of the other constants it uses. There is no need to type the value for Pi everytime it is used. Instead, substitute the constant, 'Pi'.


It is not necessary to type in the entire word when searching for help. For example, to find help on functions, you can simply type '?fun'. MAPLE will bring up a menu of close matches and you can choose the one that best suits your needs.

Exponents in MAPLE

If you wish to find, for example, 13 to the fifth power, then you can easily do it in MAPLE. The caret '^' (or 'hat') is used in exponentiation. Try typing

> 13^5;

Remember that you can also use the exponent operator to compute the roots of numbers. If you want to find the cube root of 876, simple type

> evalf(876^(1/3));

Exercises on Exponents:

Find solutions for the following:

1.) 9.8 to the fifth power

2.) 2 to the eighth power

3.) The square root of 225, 488.0

Built in MAPLE functions

MAPLE has the same built in functions that you see in scientific calculators. A few examples are, sin(x), cos(x), tan(x), log(x), sqrt(x), and exp(x). Try typing the following:

> log(10.0);

This answer tells you that log(x) does not mean the base 10 logarithm, but the natural logarithm. If you don't know what that is, don't fret. The natural logarithm is simply a logarithm with base e (approximately 2.718).

The trigonometric functions should be entered in the same way, for example, sin(2*Pi) should be as below,

> sin(2*Pi);

Now try typing sin2*Pi, omitting the parentheses. What is the result?

MAPLE also recognizes the inverse trigonometric functions. For instance, the inverse tangent is 'arctan'. Recalling that the inverse tangent of 1 is Pi/4, we can enter it as below to see that the arctan function works as expected.

> 4*arctan(1.0);

Now, let's look at e. Try computing e to the tenth power.

> e^10.0;

Well, it didn't evaluate that, so now try to use the evalf function to obtain a solution.

> evalf(e^10.0);

Oops, that didn't work either. In MAPLE, e^x is not a valid command. MAPLE is treating the letter 'e' as an undefined variable, just like it would 'x'. To find e^x, use the function, exp(x).

> exp(10.0);

Exercises on Built in Maple functions:

Find solutions for the following:

1.) The cosine of Pi/4

2.) e to the 13

3.) The square root of 488


Defining Functions in MAPLE

MAPLE far exceeds a basic calculator when it comes to handling functions. Our first task for this section is to learn how to define a function in MAPLE. Let's take for example, f(x)=x^2+2x+4. To enter this into MAPLE, try typing,

> f:=(x)->x^2+2*x+4;

Now f is defined as a function of x. Typing

> f(x);

demonstrates that MAPLE remembers our function. Not only that, but say you want to find f(x+4). All you have to do now is type

> f(x+4);

and MAPLE does the rest. If you want to find the function value at 7, say f(7), type

> f(7);

and MAPLE computes the function value for you. What a time saver!!!

Exercises on Defining functions in MAPLE:

1.) Define h(x)=9*x^2+28*x+8

2.) Find the function value at 24

3.) Find the function value if it is shifted x+2

Solving Polynomial Equations in MAPLE

Now that you can define functions in MAPLE, let's begin learning how to solve polynomial equations. Type the following line to define a polynomial t(x).

> t:=x->x^3-4*x^2-11*x+30;

Now that the polynomial t(x) is defined, there are a number of things that can be done to manipulate and to solve it. First, the polynomial can be factored, try typing the following:

> factor(t(x));

That command factored the function into its easiest rational form. In the case above, the solutions are now apparent, 2,5, and -3. The solution for the function can also be found by using the function solve(). The next line demonstrates the solve() command.

> solve(t(x));

The above function was relatively simple, let's try one that does not have an obvious solution. Define a polynomial v(x) as below and factor it.

> v:=x->x^4-4*x^3+x+2;

> factor(v(x));

This function could not be factored into an easy solution, so try to solve it using solve(). (Try typing it first without the evalf())

> evalf(solve(v(x)));

We can see that solving the equation yields four solutions, 1, 3.9, and -0.45+0.55I and -0.45-0.55I. The I is what is called an imaginary number. An imaginary unit is defined as I=sqrt(-1) or I^2=-1. For example, the equation x^2=-25 has two roots, 5I and -5I. If you put these back into the equation, you will see that they really do form the solution.

The solution for even the complicated polynomial can be found using the factor() and solve() functions in MAPLE.

Exercises on Solving Polynomials in MAPLE:

1.) Define h(x)=x^4-11x^3-3x^2+171

a.) Factor the polynomial

b.) Give the solutions of the polynomial

2.) Define j(x)=10x^3 + 15*x-270

a.) Factor the polynomial (if possible)

b.) Give the roots of the polynomial (in simplest form)

Basic Plots in MAPLE

The command for graphing in MAPLE is simply 'plot()'. Inside the parentheses, you will enter first the function, then the range of x values, separated by commas. Let's start off with a linear function, p(x)=2x+8.

> plot(2*x+2,x=-10..10);

Well that was easy. We'll try something a little more difficult this time. Try plotting sin(x).

> plot(sin(x),x=-2*Pi..2*Pi);

MAPLE plots have a lot of functionality. If you use your mouse to right click on the plot you just made, you will get a menu of options. Try changing the style of the graph and the axes and see what happens.

You can plot two functions together using the display command in MAPLE. Let's try to plot b(x)=cos(x) along with c(x)=cos(2x).

> p1:=plot(cos(x),x=-2*Pi..2*Pi):

> p2:=plot(cos(2*x),x=-2*Pi..2*Pi):

> display(p1,p2);


To display multiple plots within one graph, it is also possible to list them within a single command. For the above example, the command 'plot([cos(x),cos(2*x)],x=-2*Pi..2*Pi)' will yield the same result.

Now we're going to try a function that requires us to change the range of the y-values so that we can see the function clearly. Let's try plotting the following functions. (To do this we will need to use MAPLE's library of plots. The first line of code below will import that library.)

> with(plots):

> p3:=plot(sqrt(x),x=-10..10):

> p4:=plot(exp(x),x=-10..10):

> display(p3,p4);

As you can see, MAPLE uses the range of y from 0 to about 25000! But we can't even see the squareroot function. We need to redefine our y-values so that we can see more of the plot. Let's try y from 0 to 10 and see what heppens.

> p5:=plot(sqrt(x),x=-10..10,y=0..10):

> p6:=plot(exp(x),x=-10..10,y=0..10):

> display(p5,p6);

Now we can clearly see what happens in a smaller portion of the graph. You can change the domain and the range of your graph to "zoom" in or out on any portion of your graph.

Exercises on Plotting functions in MAPLE:

1.) Plot the quadratic equation f(x)=x^2+2x+4, find an appropriate domain and range.

2.) Plot the cosine function with x-values, -Pi to Pi

3.) Plot the functions f(x)=x^2 and g(x)=x together.