MAPLE

Purdue students can gain access to MAPLE through

Purdue Software Remote (goremote)

You will find MAPLE under

Main/Standard Software/Computational Packages

I like to use Maple notation to input commands. To make this the default, click on the Tools menu and select Options. Under the Display tab, select

Input Display: MAPLE Notation

from the drop-down menu.

You can also choose to have your graphics pop up in separate windows instead of inline by selecting

Graphics Display: Window

You will need to have the Window option if you want to animate graphics, as explained below.

You can choose to have the options apply only to the current session or to every session you run from now on by clicking on the appropriate boxes at the bottom of the options dialogue box.

When your maple window appears, select

New / Worksheet Mode

from the FILE menu. Click in the window next to the prompt to put your cursor there.

Try typing this command:

diff( x^3 * exp(x) * sin(x) , x);

and push RETURN after the semicolon. The semicolon is important. Maple won't ever do anything until you give it a semicolon and then a RETURN. (If you use a colon in place of a semicolon, MAPLE will execute the command, but not show the output.)

Now copy and paste these commands at your prompt (one line at a time):

int( x^10 * ln(x) , x);
int( exp(x) * sin(x) , x=0..2*Pi);
(x^3+3*x^2+3*x+1)*(x^2+x+1);
expand(%);
factor(%);
convert( (x^4+1)/(x^5+4*x^4+7*x^3+7*x^2+4*x+1) , parfrac , x );
solve( a*x^2+b*x+c=0 , x );
solve( { x^2+y^3=1, x+y=1} , {x,y} );

Note, the percent sign % above is maple shorthand for the output of the last executed command. Typing

(x^3+3*x^2+3*x+1)*(x^2+x+1);
expand(%);

gives the same result as typing

expand( (x^3+3*x^2+3*x+1)*(x^2+x+1) );

If you want to see Cardano's formula for the cubic and the formula for the roots of a quartic, you know what to do!

Now try these:

plot( exp(-x)*sin(3*x) , x=0..3 );
plot3d( sin(x)*sin(y) , x=0..2*Pi , y=0..2*Pi );

Maple can also do animated graphics. (Pull down the TOOLS menu on the maple toolbar and select Options. Under the Display tab, select Graphics: Window and click on Apply to session or Apply globally at the bottom of the dialogue box.)

Next, type

with(plots);

This last command loads the list of special commands that you see dispalyed after you push RETURN. (If you don't want to see all those commands, type a colon after the command instead of a semicolon.)

Now type

animate( sin(x)*cos(t) , x=0..2*Pi , t=0..2*Pi );

Notice the buttons above the graphics window that look like the controls of a VCR. Click on the "play" button to run the animation through one cycle of time t. To make the graphics run continuously, click on the far right button (that looks like a circle with an arrow on it) and then click on "play."

Now try

animate3d( sin(x)*sin(y)*cos(t) , x=0..2*Pi , y=0..2*Pi, t=0..2*Pi );

MAPLE can find roots of polynomials numerically, even if it fails to find them exactly. Try

solve(r^7+7*r^5-3*r^4+3*r^3-3*r^2+2*r+1,r);
evalf({%});
evalf({solve(r^7+7*r^5-3*r^4+3*r^3-3*r^2+2*r+1,r)});

Did you ever wonder if Fourier Series really converge? Try this one:

f := x -> sum( ((-1)^n /(2*n+1)^2 ) * sin( (2*n+1)*x ) , n=0..5);
f(Pi/4);
plot( f(x) , x=-3*Pi..3*Pi );

And this one:

f := x -> sum( (1/(2*n+1)) * sin( (2*n+1)*x ) , n=0..5);
plot( f(x) , x=-3*Pi..3*Pi );

Go back and position the mouse just after the 5 in the range term n=0..5 and push BACKSPACE and then type a bigger number like 12 and then push RETURN, and then push RETURN again to make the plot statement rerun.

Here is a great way to learn maple by taking advantage of the on-line help that comes with maple. Let's say you want to compute the Taylor expansion of exp(x)*tan(x) out to order 15. Type

?taylor

A window will pop up about the taylor command. You can read the computer manual style description of this command, or you can just scroll the window down near the bottom where you will find several examples of the command displayed. Go ahead, scroll down and find the first example. Highlight one of the commands and copy it. (You can select COPY from the EDIT menu if you don't use the usual shortcut.) Now paste the command at your prompt and push RETURN. (You can also paste by selecting PASTE from the EDIT menu.) Try it. You'll get

taylor( exp(x), x=0 , 4 );

Now push RETURN and get the Taylor expansion for exp(x) about x=0 up to order 4. It is now clear that typing

taylor( exp(x)*tan(x), x=0 , 15 );

will give us what we want.

Type

?conformal

to see some nice examples of ways to plot conformal mappings. You'll need to type

with(plots):

before you can use the conformal command.

Now try this:

with(linalg);

This command loads a whole bunch of nice linear algebra routines. Now you can do this:

m := matrix( [  [1,2,3] , [3,2,1] , [sqrt(2),sqrt(3),Pi]  ] );
inverse(m);

Investigate the commands addrow, mulrow, and swaprow using the online help. Now try this sequence of commands (this is how I like to teach Gaussian elimination in MATH 262).

m := matrix( [   [8,2,3] , [3,2,1] , [6,6,7]  ] );
m1 := mulrow( m , 1, 1/8 );
m2 := addrow( m1, 1, 2, -3 );
m3 := addrow ( m2, 1, 3, -6 );
m4 := swaprow( m3, 2, 3 );
det(m);
inverse(m);
eigenvals(m);
eigenvects(m);

Maple has a large assortment of commands for solving and studying ODE's. Try these.

with(DEtools);
ODE := diff(y(x),x) = y(x)^2 + x^2;
dfieldplot( ODE , y(x), x=-1..1, y=-1..1 );
dsolve (ODE , y(x) );
dsolve ({ ODE, y(0)=0 } , y(x) );
y := rhs(%);
plot(y, x=-1..1);
y;
y:='y';
y;

Notice that when you define a variable like y to be something, it is that something from that point on. For example, if you were to define x to be equal to t^2 via the command

x := t^2;

and then try to do this:

plot( sin(x), x=0..4 );

you would get the error message

Error, (in plot) invalid arguments

because x is not a free variable to range from 0 to 4 in the plot command; it is t^2. To undefine the variable x, you would do this:

x := 'x';

Now you can go back and position the cursor in the plot command and push RETURN and the plot will work. (Funny thing about MAPLE, the commands are executed in the order that you push RETURN, and this does not need to be the same as the order they appear on the page. So, for example, if you forget to type

with(linalg);

before you start using commands like matrix, you can type

with(linalg);

at the bottom of the page and then go back up and push RETURN on the commands that failed to run because the linear algebra package had not been loaded.)

It is easy to combine two plots into one plot. Here's an example:

with(DEtools);
ODE := diff(y(x),x) = y(x)^2 + x^2;
plot1 := dfieldplot( ODE , y(x), x=-1..1, y=-1..1 );
y := rhs( dsolve( { ODE, y(0)=0 } , y(x) ) );
plot2 := plot(y, x=-1..1);
with(plots);
display( {plot1, plot2} );

Here is another handy feature of the online maple help. Let's say you want to differentiate a function, but you don't know the name of the command to use. You might guess that there is a differentiate command in maple and that chances are it begins with di. Type

?di

at a maple prompt. A window will pop up with all the commands in maple that begin with di. You'll see a diff in the list and that is the best bet. Click on it and you'll get a full description of the diff command we used above. Scroll down to near the bottom to see a bunch of examples.

It is easy to investigate the convergence of a series. Try these.

pts := [seq( [ n , evalf(Sum(1/(k^3*sin(k)^2),k=1..n))], n=1..400)]:
plot(pts, style=point);

(Something funny happens at 355 because 355/113 is very close to pi.)

Here are some graphing commands that come in handy:

with(plots):
implicitplot( x^2/9 + y^2/4 = 1 , x=-4..4, y=-3..3 );

plot( [3*cos(t),2*sin(t), t=0..2*Pi] );

p1 := plot( [3*cosh(t),2*sinh(t), t=-2..2] , [-3*cosh(t),2*sinh(t), t=-2..2], color=red ):
p2 := plot( { (2/3)*x, -(2/3)*x } , x=-11..11 ):
display( {p1,p2} );

Here are some old Maple assignments from MATH 266. Try some of them.

NOTE: The demo's above were created in Maple, then saved as PostScript files, then converted to PDF files for display on the web. This process is rather easy. I explain the details of how to do this in

How to turn Maple into a technical word processor for the web.

Next, go to Professor Harold Boas' maple website at Texas A & M

http://www.math.tamu.edu/~harold.boas/courses/math696/Maple.html

for a nice little maple tuturial.


You are now ready to move on to the next section, matlab


Back to the MATH 2000 HOME PAGE