Welcome to Maple
Copyright 2001
Department of Mathematics
University of Georgia
Athens, Georgia
Carol W. Penney
This introduction will help you begin your work with Maple. Work through the examples and do the exercises to gain practical experience with this powerful and useful computer algebra program. Do not try to memorize commands now; you will learn more about particular Maple commands as you work on projects. The last section, Project 1: Investigations of Functions and Graphs , outlines a short project that will give you practice working with Maple. You will investigate two functions and write a report on the results of your investigations. Begin your work by clicking on the plus sign below to open the first section of this introduction.
The Maple Worksheet
You are reading a Maple worksheet. It consists of a combination of text, commands, and output. Your projects are presented in the form of worksheets and you work in a worksheet, combining your exposition, input, and output to produce a report on each of your investigations.
Text: As you see, Maple acts like a word processor to produce text. It has the usual word processing capabilities, some of which you can see in the Edit menu above.
Commands: Command lines appear in red. Here is one; to enter it click your mouse in the command line and press [Enter].
| > | factor(x^4+13*x^3+45*x^2-25*x-250); |
As you see, output is in blue. Notice that your cursor automatically jumps to the next command line, ready to execute the next command.
Maple consists of two parts: the front end , which is the content of the display, and the kernel , the computational engine of Maple. Even though you see a command in the worksheet, Maple's kernel will not know it exists until you enter that command. In order to enter a command, you must send it to the kernel by placing your cursor on the command line and pressing [Enter]. If you enter a command now, save your program, close it, and open it later, you may see blue output displayed by the front end, but Maple's kernel will not remember having calculated it. You must re-enter any command you want the kernel to know about because Maple begins each session with an empty kernel.
Addition:
| > | 12+56; |
Subtraction:
| > | 768-12.4; |
The asterisk indicates multiplication, and the ^ symbol indicates exponentiation. Here we calculate (
)(
):
| > | 5*2^4; |
Compare these two calculations of the square root of 200---first the exact value then a decimal approximation, which is obtained by inserting a decimal point in the number.
| > | sqrt(200); |
| > | sqrt(200.0); |
The standard rules of parentheses apply. Compare these two calculations:
| > | 2/(3+5); |
| > | 2/3+5; |
A plot of the graph of
on the domain [-2,3]:
| > | plot(x^2,x=-2..3); |
| > |
Notice that your cursor moved to the blank execution group below the plot command. Each time you enter a command, the cursor will move to the next command line. The empty execution group above this paragraph has a function; it stops the cursor so that you can look at the graph. If you want to see what happens if this empty execution cell is not present, do the following exercise:
Entering Commands: In order to create an execution group so you can type a new command, place your cursor where you want to type the command and click on the prompt icon, which looks like [> and lies on the line of icons at the top of the page immediately to the right of the T . Clicking the prompt icon creates an Execution Group . Type your command followed with a semicolon. Then enter the command.
Typing Text: In order to type text following an execution group, click on that execution group bracket and select Insert Paragraph from the Insert Menu. Begin to type. You notice that text is black. The Maple kernel ignores text, which is present for the benefit of the reader---you do not [Enter] text. An alternative method of creating a place to type text is to click on the prompt icon then the T icon ( T stands for text) on the left of the prompt icon. This will create an execution group in which you can type text.
Opening two worksheets at once: You can work with two or more worksheets open at once. You can choose to toggle back and forth from one to the other or view two worksheets simultaneously. Choose your arrangement by selecting, from the Window menu, Cascade , Tile , Horizontal , or Vertical .
Saving your work: Save frequently as you work. If there is a power outage or if you crash you will not lose anything except the work you have done since the previous Save , so from time to time you will appreciate having developed the habit of saving frequently. In order to save this file, choose Save As from the File menu. A dialog box will appear, asking you to give the file a name and choose a place to save it. Name your file something you can remember (such as Welcome followed by your initials), then type a: filenameyourinitials and click O.K. This will save the file to your floppy disk (in drive a).
Once you have saved your work, you can save updates as you work by simply clicking on Save in the File menu; you only have to tell Maple where to save and what to name the file the first time you save. Before making your final Save of each session, select Remove Output from Worksheet from the Edit menu. This will save room on your floppy disk, may prevent difficulty opening your file on a different computer, and will ensure that when you next open your file output that is unknown to the computer will not appear to be known.
Functions
Before we begin more investigations of Maple, we clear the kernel's memory with the restart command. This is good way to ensure that Maple will not be remembering any values that you assigned earlier in this session and have forgotten about.
| > | restart: |
Maple knows the usual functions, such as sin(x), ln(x), arctan(x), and so forth. Most are entered in the obvious way:
| > | sin(x); |
| > | ln(x); |
The notation for the natural exponential function is this:
| > | exp(x); |
Defining Functions: You can also define your own functions. For example: to define the function f(x)=x^3-x^2+1, think of the function f as a rule that operates on the number x to transform it to x^3-x^2+1. Define f as follows:
| > | f:=x->x^3-x^2+1; |
Now that Maple knows this function, you can refer to it by name throughout your work. Maple will be able to evaluate f(x), plot its graph, solve equations involving f(x), and so forth.
Evaluation of a Function: You can evaluate a built-in function or a function you have defined. By hand, you would denote the value of f at x=2 by f(2); Maple notation is the same. Calculate an exact value by entering the value of x without a decimal point, a floating point (decimal) approximation by entering x with a decimal point.
| > | sin(Pi/4); |
| > | f(2); |
| > | f(2.0); |
| > | f(sqrt(2)); |
| > | f(sqrt(2.0)); |
| > | f(Pi); |
Since
has no place to put a decimal point, use the command evalf ("evalf" is short for "evaluate as a floating point number") to evaluate f(Pi) as a decimal.
| > | evalf(f(Pi)); |
| > | evalf(sin(Pi/4)); |
| > | g:=x-> |
| > | h:=x-> |
| > |
Graphs of Functions: To plot the graph of f(x)=x^3-x^2+1 on the interval [-0.5,1]:
| > | plot(f(x),x=-0.5..1); |
| > |
You can insert various options in the plot command to change the way the graph looks. You may want to zoom in on the graph, change the color of the graph, display or suppress the display of asymptotes, change the relative proportions of units in the x- and y- directions, and so forth.
If you want to set the range of the plot, insert bounds on y. For example, to display values of y between 0.9 and 1.1:
| > | plot(f(x),x=-0.5..1,y=0.9..1,title="Nessie"); |
If you want to select a different color for your graph, insert a color command. Readily available colors are:
aquamarine black blue navy coral cyan
brown gold green gray grey khaki
magenta maroon orange pink plum red
sienna tan turquoise violet wheat white
yellow
| > | plot(tan(x),x=-10..10,y=-5..5,color=navy); |
| > |
Notice that Maple drew lines that look like vertical asymptotes to the graph. In fact, Maple is sketching the graph by connecting points on the graph; because it does not recognize the discontinuities of the tangent function, it is simply attempting to draw a continuous function by drawing "almost vertical" lines between points on separate branches of the graph. If you do not want to see these "asymptotes", warn Maple to look for discontinuities by inserting discont=true in your plot command:
| > | plot(tan(x),x=-10..10,y=-5..5,discont=true,color=navy); |
| > |
Sometimes the graph is best displayed if the scale of the horizontal units is different from those in the vertical direction:
| > | plot(x^2,x=-5..5); |
But sometimes you want the units to be equal in the horizontal and vertical directions in order to show the scale of the graph accurately. In this case use scaling=constrained in your plot command:
| > | plot(x^2,x=-5..5,scaling=constrained); |
| > |
To plot the graphs of two functions on the same coordinate system, enclose the pair of functions in brackets.
| > | plot([x^2,1-3*x],x=0.1..0.5); |
| > |
If you have defined a function, you may refer to it either by typing its formula or, more simply, by name. The following two commands produce identical graphs.
| > | plot(x^3-x^2+1,x=-0.5..2); |
| > | plot(f(x),x=-0.5..2); |
| > |
Algebra
Maple will expand or simplify algebraic expressions, solve equations, combine expressions, and so forth.
| > | restart: |
Solving equations: An equation must contain an equals sign. Typically you are trying to solve an equation for the unknown in the equation. Suppose, for example, that we want to solve the quadratic equation x^2+4x=3 for x. State the equation to be solved and the variable for which you want to solve:
| > | solve(x^2+4*x=3,x); |
If you want decimal approximations to these solutions, you can write any number in the equation with a decimal point:
| > | solve(x^2+4*x=3.0,x); |
Another way to find decimal approximations to these solutions is to use fsolve (for "floating point solve"). The fsolve command will often find solutions that solve cannot find, since Maple uses ordinary algebraic manipulations in the solve command and numerical methods for fsolve .
| > | fsolve(x^2+4*x=3,x); |
| > | fsolve(x^2+4*x=0,x);fsolve(x^2+4*x,x); |
Sometimes you must give Maple an interval on which to search with the
fsolve
command. Consider the equation
. We first plot the graphs of these two functions
| > | plot({x^3-2*x+1,sin(x)},x=-5..5,y=-10..10); |
It is apparent from the plot that there are three solutions to the equation
. If we use the
fsolve
command without an interval, we obtain only one solution.
| > | fsolve(x^3-2*x+1 = sin(x),x); |
To obtain the remaining solutions, we must specify intervals on which Maple is to search.
| > | fsolve(x^3-2*x+1 = sin(x),x=-2..0); |
| > | fsolve(x^3-2*x+1 = sin(x),x=1..2); |
You can solve a pair of equations in two variables by enclosing the equations in braces, to form a set of equations. For example, to solve the simultaneous equations x+3*y=7, 2*x-5*y=1 for x and y:
| > | solve({x+3*y=7,2*x-5*y=1},{x,y}); |
If you write any number in either equation as a decimal, you will obtain your solution in decimal form.
| > | solve({x+3*y=7.0,2*x-5*y=1},{x,y}); |
Other useful algebraic commands :
| > | expand((x-3)^4*(x+1)); |
| > | factor(x^5-11*x^4+42*x^3-54*x^2-27*x+81); |
| > | simplify((x^2-3^2)/(x-3)^2); |
| > |
| > | 2*(5+7); |
| > | 2(5+7); |
| > |
Calculus
Maple will calculate derivatives and integrals for you.
Differentiation
You know several symbols, among them f'(x) and dy/dx, for the derivative of a function y=f(x) with respect to x, and you know that these can be used interchangeably. Maple also has two different commands for computing the derivative of a function f(x) with respect to x, D(f) and diff(f(x),x), but these two Maple commands produce subtly different results. Consider these commands:
| > | restart; |
| > | D(sin); |
Define the function f(x)=x^3-5x-7 and find its derivative:
| > | f:=x->x^3-5*x-7; |
| > | D(f); |
Notice that in order to calculate D(f), f must be a function. If you attempt to calculate the derivative of an expression, you will get an unexpected result:
| > | D(x^3-5*x-7); |
Use D(f) as you would any other function. You can evaluate D(f) at x or at a specific value of x, such as x=2. You can plot the graph of D(f), solve equations involving D(f), differentiate D(f), and so forth. First notice the difference between the function D(sin) and the value, D(sin)(x) , of the derivative at x:
| > | D(sin);D(sin)(x); |
For the function f(x) defined above, compare the derivative, D(f), of f(x) with the value, D(f)(x), of that derivative:
| > | D(f);D(f)(x); |
Evaluate each of these derivatives at x=2:
| > | D(sin)(2); |
| > | D(f)(2); |
To plot the graph of the derivative:
| > | plot(D(sin)(x),x=0..2*Pi); |
| > | plot(D(f)(x),x=-1..1); |
To solve the equation f '(x)=0:
| > | solve(D(f)(x)=0,x); |
| > | fsolve(D(f)(x)=0,x); |
The derivative of f ' (x), which is called the second derivative of f with respect to x and is denoted in handwriting as f ' ' (x) :
| > | D(D(f)); |
The value of this second derivative, f ' ' (x), of f at x:
| > | D(D(f))(x); |
The value f ' ' (2):
| > | D(D(f))(2); |
| > |
The other differentiation command is diff(f(x),x):
| > | restart: |
| > | f:=x->x^3-5*x-7; |
| > | diff(x^2,x); |
| > | diff(f(x),x); |
| > | diff(sin(3*x),x); |
Notice that in order to use the command diff(f(x),x), f (x) is an expression, not a function. If you attempt to calculate the derivative of a function using the diff notation, you will get an unexpected result:
| > | diff(sin,x); |
| > | diff(f,x); |
| > | D(f);diff(f(x),x); |
In fact, the value of D(f) at x, D(f)(x), is the same as diff(f(x),x):
| > | D(f)(x);diff(f(x),x); |
So while you can do most of the same things with the diff command that you can do with the D command,
| > | plot(D(f)(x),x=-1..1);plot(diff(f(x),x),x=-1..1); |
| > | solve(D(f)(x)=0,x);solve(diff(f(x),x)=0,x); |
| > | fsolve(D(f)(x)=0,x);fsolve(diff(f(x),x)=0,x); |
| > | D(D(f))(x);diff(diff(f(x),x),x); |
evaluation of the derivative at a specific value of x, say x=2, is simpler to accomplish with the D command than with the diff command. Evaluation with the D command is simple:
| > | D(f)(2); |
But in order to evaluate the expression diff(f(x),x) at x=2, you must substitute 2 for x using the subs command:
| > | subs(x=2,diff(f(x),x)); |
An alternative is to use the eval command
| > | eval(diff(f(x),x),x=2); |
Integration
Maple will antidifferentiate a function as well as calculate a definite integral.
| > | restart: |
Antidifferentiation: To antidifferentiate, use the int command. This command finds an antiderivative of f(x)=x^2 with respect to x.
| > | int(x^2,x); |
Notice that Maple did not find the most general antiderivative,
, of f(x)=x^2. If you want the general antiderivative, you must add the
+C
:
| > | int(x^2,x)+C; |
Example: To find an antiderivative of g(x)=sin(3*x):
| > | int(sin(3*x),x); |
or define g(x) then antidifferentiate.
| > | g:=x->sin(3*x); |
| > | int(g(x),x)+C; |
| > |
The Definite Integral:
The same
int
command, used in a slightly different way, will give you the definite integral. Here we find
:
| > | int(x^2,x=2..4); |
| > |
;
;
.
Packages
In order to maximize efficiency, Maple's kernel contains only basic operations. Specialized operations are contained in packages, which must be loaded before use. As an example of this, let's look at the package plots , which contains a command that creates animations. First load the plots package by entering the command with(plots):
| > | restart: |
| > | with(plots): |
Then enter the animate command. Here we create a sequence of graphs of y=a*sin(x), as a takes on values from 0.1 to 2.0:
| > | animate(a*sin(x),x=-2*Pi..2*Pi,a=0.1..2.0,color=navy); |
| > |
You can play this movie by clicking anywhere in the movie and selecting the play button from the row of icons that appears.
If you want to see the commands that are in the Plots package, change the colon in the with(plots): command to a semicolon and enter the command.
| > | with(plots); |
Printing
Before printing, save your work. Occasionally disaster strikes while printing, and you would hate to lose your work during this final step. You can look at a print preview in the File menu before printing to see what each page looks like. To save paper, before printing go to View menu and select Zoom Factor, 75% . To print, choose Print from the File menu.
Help
There is an extensive Help menu, which includes a New User's Tour . Click the Help icon at the top of the page. If you know the name of a command about which you want help, type ?command and press [Enter]; this will act like a hyperlink, sending you to the help page for that command.
| > | ?plot |
| > |
Summary of Important Commands:
You can obtain many results with only a few commands. The four essential tools that you will need to use in every project are these:
:
| > | f:=x->x^3-3*x+4; |
| > | f(5); |
| > | plot(f(x),x=-3..5); |
| > | plot([f(x),x^2],x=-3..5); |
for
| > | solve(4*x^3+6*x+7=10,x); |
| > | fsolve(4*x^3+6*x+7=10,x); |
| > |
Exercises:
Use these exercises to practice using the commands you have learned. Try to remember how to enter the appropriate commands before you look them up. At the end of this project you will find a section called Tools for this Project; it contains all of the commands you will need to work these exercises. State each problem and present your answer to problem 4 clearly in a complete sentence.
and
.
Now you are ready to begin your project.
Project: Investigations of Functions and Graphs
.
To plot your circumscribed rectangle, enter the leftmost and rightmost x-coordinates of R and lowest and highest y-coordinates of R in the following four commands then enter all of the commands.
| > | leftx:= ; |
| > | rightx:= ; |
| > | lowesty:= ; |
| > | highesty:= ; |
| > | with(plottools):with(plots): box:=rectangle([leftx,lowesty],[rightx,highesty],color=yellow): |
| > | display([plot([f(x),g(x)],x=0..1.25*rightx,y=min(0,1.25*lowesty)..1.25*highesty),box]); |
Read the section How to work your project before you write your report so that you will know what sort of report you are expected to submit. Your ability to organize and write a clear report will be essential to your success in any future career; this is a good opportunity to hone those essential skills.
Academic Honesty Statement:
Place the following statement (by copying and pasting) at the end of your report and sign it in ink. Your instructor will not grade your report unless this signed statement appears at the end of your report.
I understand that I may work with others if I give them credit in this statement. I also understand that I am required to write my report--that to copy all or part of someone else's report or to allow someone else to copy all or part of my report constitutes plagiarism, which is a serious violation of academic honesty.
I worked with (replace this parenthetical remark with first and last names of those with whom you worked) on this project. I wrote my own report. I did not copy any of this report from anyone else and I did not allow anyone else to copy any of this report.
Signed: