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:
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:
Notice that the line without the asterisk gives the wrong solution.
Subtraction should be written as follows:
Now on to division. Try typing the following line:
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:
MAPLE also has a function that will automatically evaluate the expression entered. It is called evalf(). Try typing
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.
Now every time the letter 'a' is used in an expression, it will actually refer to the value for Pi! Try typing the following:
If you try to use just the '=' instead of ':=', the assignment will not be madeHelp 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'.
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
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
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:
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,
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.
Now, let's look at e. Try computing e to the tenth power.
Well, it didn't evaluate that, so now try to use the evalf function to obtain a solution.
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).
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,
Now f is defined as a function of x. Typing
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
and MAPLE does the rest. If you want to find the function value at 7, say f(7), type
and MAPLE computes the function value for you. What a time saver!!!
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).
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:
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.
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.
This function could not be factored into an easy solution, so try to solve it using solve(). (Try typing it first without the evalf())
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.
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.
Well that was easy. We'll try something a little more difficult this time. Try plotting sin(x).
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).
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.)
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.
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.