Maple Handout
Click on the [▼] to expand and collapse the section
Chapter 1: Introduction to Maple
Objectives: To learn the basic Maple syntax and use of Maple help. And use of the software for Calculus problems.
Maple is a mathematical software package used for symbolic and numerical calculations. In this Lab we will introduce the basics of Maple. Lets learn to type the correct Maple commands and execute them. The main idea is to use it and don't be afraid of error messages as we learn by fixing our mistakes.
After typing the Maple commands on prompt "> ", press [Enter] to execute and get the result. Every Maple command must be punctuated with either a semicolon ";" or a colon ":".
Try this now by multiplying two numbers
| > | 105*168; |
| (1.1) |
If the semicolon is missing we get the warning message:
| > | 11*45 |
| Warning, inserted missing semicolon at end of statement | |
| (1.2) |
If we place a colon at the end, out put will be suppressed
| > | 1022*765: |
| > | 23*345; # Press the [Enter] key to go to the next prompt, note that "#" is used for comment. |
| (1.3) |
Arithmetic Operations
In Maple we can use the usual arithmetic operations
If you ever need additional information about a Maple command, you can always ask for Help by typing in a question mark followed by the Maple command and then press [Enter]. For example, type in ?+ and then press [Enter]. A help window will open that gives information on the various arithmetic operations that are available in Maple.
| > | ?+ |
On many platforms there is an additional Help menu on the menu bar. On these platforms invoking help is accomplished by selecting the Maple command in question and then pulling down the Help menu. For example, use the mouse to select + and then pull down the Help menu and click on the menu item that says Help on "+".
We will get the following window
The following computes the floating-point operation
| > | evalf(23/11); |
| (1.1.1) |
Constants And Built-in Functions
Maple has many of the the standard mathematical constants built-in. Maple is also "case sensitive" , which means that it treats "a" and "A" as distinct symbols.
| > | Pi; |
| > | evalf(%); |
| > | evalf(%%,50); |
| > | sin(Pi/4.0); |
| > | evalf(%); |
| > | sqrt(3); |
| > | evalf(%,30); |
| > | I^2; # complex number |
| (1.2.1) |
| > | # Press the [Enter] key to go to the next prompt. |
Defining Variables and Functions
You can assign a value or a function to a variable with the colon-equal symbol ":='' (assignment operator).
| > | a := 123; |
| > | a; |
| (1.3.1) |
This means that the variable "a'' has been assigned the value 123 and it will have this value through the remainder of the session unless you assign it another value or "unassign" it.
| > | 4*a+12; |
| (1.3.2) |
The following statement is the way to "unassign" the variable.
| > | a := 'a'; |
| (1.3.3) |
Note that in the last statement we have enclosed a within two single quotes '.
The most important syntax in Maple for calculus is the definition of function. We can enter the following.
| > | f := x^2; |
| (1.3.4) |
The last command defines the function and you can check that out with the following command.
| > | f; |
| (1.3.5) |
There is a Maple procedure called subs which allows you to evaluate this expression. The format is
subs(variable = value, expression involving variable).
| > | ?subs # try this by pressing Enter to get help |
| > | subs(x=5,f); |
| (1.3.6) |
Warning: Standard functional notation for a Maple expression, such as f(5), is not understood by Maple at all.
| > | f(x); |
| > | f(5); |
| (1.3.7) |
If you want to use standard functional notation then you can do so using the minus-greater than symbol "->", made by typing the "minus sign" followed by the "greater than'" sign. For example:
| > | f := x -> x^3+2; |
| (1.3.8) |
| > | f(x); |
| (1.3.9) |
Now we have
| > | f; |
| (1.3.10) |
| > | f(5); |
| (1.3.11) |
| > | # Press the [Enter] key to go to the next prompt. |
Algebra
2-D Plots
Let make use of Maple help
| > | ?plot |
If a function "f" is defined on an interval [a,b] you can plot it with one of the following commands.
plot(f,a..b,options)
or
| > | f := x -> exp(-x^2); |
| (1.5.1) |
We now plot this function over the interval [-3,3].
| > | plot(f,-3..3); |
![]() |
Next we can plot including label option.
| > | plot(f(x),x=-3..3,y=-0.3..1); |
![]() |
| > | plot(f,x=-3..3); |
| Error, (in plot) invalid plotting of procedures, perhaps you mean plot(f, -3 .. 3) |
On the other hand if you use the following statement then you get an empty plot.
| > | plot(f(x),-3..3,-0.3..1); |
| Warning, unable to evaluate the function to numeric values in the region; see the plotting command's help page to ensure the calling sequence is correct | |
![]() |
You should carefully read the help information for the plot command which will be used a lot in the course of this text. There is a special Maple Library called plots that has many useful procedures defined. In particular, there is the command display. There are two ways to invoke a procedure from a Library Package like plots, for example you can access all of the routines with the command
"."
You can also invoke display using the command
" plots[display]({set of plots });".
Sometimes we wish to printout text information on our plots. The plots procedure textplot works for this. The following will serve as an example that uses the plots routines textplot and display. Make sure that you use colons and semicolons where they are used below.
| > | plot1 := plot(f,0..3): |
| > | plot2 := plots[textplot]([0.7,0.8,`x=0.4336,y=0.615`],align = RIGHT): |
| > | plots[display]({plot1,plot2}); |
![]() |