Since you will not be given a Maple manual, you should learn to use Maple by using the built in Help facility. To get help on a particular topic, such as the plot command, type, after the prompt >, the command ?plot;. A window will open describing the basic structure of the command and giving examples of its use. To close this window when you have finished with it, click the left mouse button on the rectangle in the upper left corner of the window and then drag the mouse pointer down, releasing the button when Close is highlighted. Another way to invoke Help is to place the mouse pointer on the word Help at the far right of the Menu Bar, click the left mouse button, and drag the mouse pointer down, releasing the button when the desired item (such as Topic Search) is highlighted. We shall refer to this process as choosing Topic Search from the Help menu. Fill in the Topic box, click the left mouse button on the item that you want, and then click on OK.
To continue, you will need to know some basic commands and syntax of Maple.
Return to the Table of Contents
(2*x +y^2)/(2*x + exp(x)) + 1;
Note that the exponential function is built into Maple and is referred to as exp. Similarly, Maple knows the functions log, sin, cos, tan, and many more standard functions.
When operating on integers, Maple does exact arithmetic, rather than using decimal approximations. To get a decimal approximation, use the Maple command evalf. The Maple command evalf(4/7,20); produces a 20 digit approximation to 4/7. Typing only evalf(4/7); will produce a 10 digit approximation -- as will typing 4.0/7.0;.
Return to the Table of Contents
Return to the Table of Contents
Return to the Table of Contents
Return to the Table of Contents
The command for both definite and indefinite integration is int. If Maple cannot evaluate a definite integral exactly, numerical integration may be used. Type ?int and ?int[numerical] for details on integration in Maple.
Return to the Table of Contents
Consider the differential equation d2y/dx2-y=x3. To describe this equation in Maple, we need to communicate that the unknown solution y is a function of x, and to describe the relevant derivatives of y with respect to x. To communicate to Maple that y is the dependent variable and x is the independent variable, we write y(x) instead of y when referring to this variable. Since the first derivative is diff(y(x),x)}, the second diff(y(x),x$2), etc., the differential equation d2y/dx2-y=x3 should be expressed to Maple as diff(y(x),x$2) -y(x)=x^3 . Notice that Maple echoes it back in symbolic form. To use this equation later we give it a name by typing de:=diff(y(x),x$2) -y(x)=x^3; so that the symbol de will refer to this equation. We can use the commands rhs and lhs to refer to the right or left side of the differential equation. To place other conditions on y(x), we group additional equations together with de inside braces. For example, the initial value problem d2y/dx2-y=x3, y(0)=1, y'(0)=2 can be described to Maple via ivp:={de,y(0)=1,D(y)(0)=2}; . Note the use of D as another notation for differentiation. Any conditions on higher derivatives at a point are described via the D notation as well, for example D(D(y))(0)=3.
Once a differential equation has been described to Maple, Maple can attempt to find its general solution, particular solutions, or to plot solutions. We briefly describe the relevant functions here. Find more about a function by typing ?functionname. For example ?dsolve will tell you all about the Maple function dsolve.
Brief summary of relevant Maple commands for Differential Equations
dfieldplot produces a plot of the direction field of a single first order differential equation or a system of two first order autonomous differential equations.
dsolve(de,y(x)); or dsolve(ivp,y(x)); In these basic forms, dsolve will attempt to solve the differential equation or the initial value problem for y(x) described in ivp, returning a formula for y(x) if possible. In the first form, arbitrary constants _C1, etc. will be used to express a general solution.
soln:= dsolve(ivp,y(x),numeric); In this form dsolve finds an approximate solution to the initial value problem described in ivp. The output soln is a Maple procedure. To get the value of this approximate solution at a particular point, e.g., x=2.5, type soln(2.5);. Because the solution is returned as a Maple procedure which produces output of the form [x= 2.5, y(x) = 6.437], the plot command cannot be used directly to graph the approximate solution. Instead, use the odeplot command. Sometimes it is useful to convert the approximate solution from the form of a Maple procedure into a standard function that just returns the y-value. This can be done by typing yapprox:= u-> subs(soln(u), y(x));. A graph of the approximate solution over the interval 0 < x < 5 can then be obtained by typing plot(yapprox, x=0..5);.
odeplot is used to plot numerical solutions of differential equation obtained from using the numeric option of dsolve.
DEplot may be used to plot numerical solutions of differential equations with a set of initial conditions. In the case of a single first order equation or a system of two first order autonomous equations, it can also be used to plot the direction field of the equation, with or without solution curves. In fact, the default option is to also produce the direction field; to suppress the direction field, one must add the option arrows = NONE. For computing the numerical solution at a particular point, the numeric option of dsolve should be used. The default numerical method used by the DEplot command is the classical fourth order Runge-Kutta method with a fixed step size. For some problems, the default step size may be too large to produce an accurate solution. This may be corrected by using the stepsize option. In general, the default method used by DEplot is a poor choice of method, so it is better to use the command with the option method=rkf45, which is the default method for the numeric option of the dsolve command.
Examples of use of Maple commands for Differential Equations
with(plots): with(DEtools):
de1:= diff(y(x),x) = - y(x) + 1/(1 + exp(x));
s1:=dsolve(de1,y(x));
t1:=rhs(dsolve({de1,y(0)=-2},y(x)));
plot(t1,x=-1..5);
dfieldplot(de1,y(x), x=-1..5,y= -6..4);
initval:={[y(0)=-2],[y(0)=1]};
DEplot(de1, y(x), x=-1..5, initval,y=-6..4);
t2:=dsolve({de1,y(0)=-2},y(x),numeric);
odeplot(t2,[x,y(x)],-1..5);
Linear Algebra: To use Maple's linear algebra commands, you first enter with(linalg): To see a list of commands in this package, type with(linalg);, i.e., use a semicolon instead of a colon. In this course, we will only use a few of Maple's linear algebra commands: matadd to add two matrices, multiply to multiply a matrix times a vector, linsolve to solve the linear system of equations A x = b, det to find the determinant of a matrix, and eigenvects to find the eigenvalues and eigenvectors of a matrix.
Return to the Table of Contents
The window which appears when you start Maple is called a Maple worksheet. To complete each computer assignment in Mathematics 251 you are asked to turn in an edited printout of your work; such a printout can be obtained by editing, and then printing, your worksheet. The printout should include only the numerical, symbolic, and graphical output of Maple which is appropriate for the solution of the problems assigned, plus text material in which labels are provided for graphical output and explanations added. Maple includes various editing capabilities which should enable you to produce neat and coherent output, and which we now describe.
To remove an unwanted portion of your Maple worksheet (e.g., a region containing commands that you typed incorrectly or that were not directly relevant to the solution of the exercises), select the region to be deleted by clicking the left mouse button at the beginning, then dragging the mouse across to the end of the portion of the worksheet you wish to delete. The region should now be highlighted. Then choose Cut from the Edit menu. To copy a region to a new location, select the region as above, but now choose Copy from the Edit menu. Then click the left mouse button in the position in which you wish to insert your selected region and choose Paste from the Edit menu.
To insert text, such as a label for a plot, into your worksheet, click the mouse at the beginning or end of the plot and choose Text Input from the Insert menu. Now type your label. To continue using your worksheet, move the mouse pointer down to the next prompt > and click the left mouse button. If there is no prompt, insert one by clicking on the prompt symbol > in the Tool Bar Menu.
Sometimes it is useful to be able to place a comment after a Maple command, rather than insert text elsewhere in the worksheet. To do this, enter the sharp symbol #. Everything typed on a line following this symbol will be considered by Maple to be a comment, and therefore not executed.
To make your worksheet less cluttered, it is a good idea to have Maple suppress the output of various commands, e.g., the command with(plots) or a command given to assign a name to a plot. To do this, end the command with a colon (:), instead of a semicolon (;).
Return to the Table of Contents
Return to the Table of Contents
Return to the Table of Contents
Return to the Table of Contents
Return to the Table of Contents
The home page of the course contains a section that contains pointers to these Maple worksheets. Follow the instructions there to obtain your personal copy of the worksheet before starting Maple.
Return to the Table of Contents
Any Maple command previously entered in your worksheet can be re-executed without retyping it in a new location. Simply move the mouse to the position of the command you wish to execute and hit the Return key.
It is often useful to be able to refer later to the result of a computation -- the output of some command -- in a simple way. To make this possible, simply assign the output of the command to a variable. For example, if you enter a:= evalf(2*Pi); then you can later square the result of evalf(2*Pi); by typing a*a;.
You can assign a name to a plot just as described above for assigning a name to an expression. Several previously named plots can then be displayed on the same graph by using the command display. Type ?plots[display] for details.
If you assign the name a as above and then continue your Maple session, you may want to reassign the name a to another expression. To do so, first unassign a by typing a:='a';. To clear all the assigned variables in a Maple session, type restart;. One common problem is to try to use such a variable without unassigning it, forgetting that is has already been assigned a value. A simple way to avoid this is to issue the restart command before beginning a new problem. This will not change anything on your screen.
Return to the Table of Contents
Return to the Table of Contents
Last modified January 5, 2000 by Richard T. Bumby, bumby@math.rutgers.edu,
based on the version of January 6, 1999 by
the original author:
Richard S. Falk, falk@math.rutgers.edu