>

An Introduction to MapleV, Release 5.1

Douglas B. Meade ( meade@math.sc.edu )

http://www.math.sc.edu/~meade/maple/intro5-1.mws

25 February 1999

>

> restart;

> with( plots );

[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]

> with( student );

[Maple Math]
[Maple Math]
[Maple Math]

>

Plotting

In this section we will learn different methods of entering functions in Maple. Then, the user interface will be used to create and manipulate a graph of the function. Unless someone has a better choice, let's use the function [Maple Math] .

> f := x/2 + sin(x) + exp(-x/6);

[Maple Math]

> smartplot(1/2*x+sin(x)+exp(-1/6*x));

[Maple Plot]

>

3D Plots

Here is a brief sample of 3D plots. For further details and examples, please consult the on-line help for plot3d and the plots package.

> plot3d( sin(x*y), x=-Pi..Pi, y=-Pi..Pi );

[Maple Plot]

>

> plot3d([x*sin(x)*cos(y),x*cos(x)*cos(y),x*sin(y)],x=0..2*Pi,y=0..Pi);

[Maple Plot]

>

>

Calculus

Derivatives and Antiderivatives

In this section we will emphasize the graphical aspects of differential calculus. The general outline is to use the GUI to: plot the function, construct the derivative and antiderivative, and then add these functions to the original graph. Let's begin by recalling the definition of the function.

> f;

[Maple Math]

> 1/4*x^2-cos(x)-6*exp(-1/6*x);

[Maple Math]

> 1/2+cos(x)-1/6*exp(-1/6*x);

[Maple Math]

>

> smartplot(1/2*x+sin(x)+exp(-1/6*x));

[Maple Plot]

>

>

Definite Integrals & Riemann Sums

There are a number of nice tools that can be used to enhance the discussion of integral calculus. The Maple spreadsheet is a new addition in Release 5; the graphical and symbolic tools have existed for much longer, but are still very effective. Let's begin by examining the definite integral: [Maple Math] . where f(x) is the function introduced earlier.

>

Using a Spreadsheet to Create a Table of Approximate Values for a Definite Integral

> f;

[Maple Math]

> x0 := 0;

[Maple Math]

> x1 := Pi;

[Maple Math]

>

[Maple Math] [Maple Math] [Maple Math] [Maple Math] [Maple Math]
[Maple Math] [Maple Math] [Maple Math] [Maple Math] [Maple Math]
[Maple Math] [Maple Math] [Maple Math] [Maple Math] [Maple Math]
[Maple Math] [Maple Math] [Maple Math] [Maple Math] [Maple Math]
[Maple Math] [Maple Math] [Maple Math] [Maple Math] [Maple Math]
[Maple Math] [Maple Math] [Maple Math] [Maple Math] [Maple Math]
[Maple Math] [Maple Math] [Maple Math] [Maple Math] [Maple Math]
[Maple Math] [Maple Math] [Maple Math] [Maple Math] [Maple Math]
[Maple Math] [Maple Math] [Maple Math] [Maple Math] [Maple Math]
[Maple Math] [Maple Math] [Maple Math] [Maple Math] [Maple Math]
[Maple Math] [Maple Math] [Maple Math] [Maple Math] [Maple Math]
[Maple Math] [Maple Math] [Maple Math] [Maple Math] [Maple Math]

>

Graphical View

> f, x0, x1;

[Maple Math]

Method 1: Explicit Construction of Sequence of Plots

> R0 := rightbox( f, x=x0..x1, 1 ):

> R1 := rightbox( f, x=x0..x1, 2 ):

> R2 := rightbox( f, x=x0..x1, 4 ):

> R3 := rightbox( f, x=x0..x1, 8 ):

> R4 := rightbox( f, x=x0..x1, 16 ):

> display( [R0,R1,R2,R3,R4], insequence=true );

[Maple Plot]

>

Method 2: Programmed Construction of Sequence of Plots

> Nframe := 10;

[Maple Math]

> LL := plot( f, x=x0..x1 ):

> for n from 0 to Nframe do

> LL := LL, leftbox( f, x=x0..x1, 2^n );

> od:

> display( LL, insequence=true );

[Maple Plot]

>

Symbolic and Numeric Evaluation

Now that we have some ideas about how the definite integral is defined in terms of approximate sums, let's turn our attention to an explicit evaluation of the integral. The context menus provide a simple means to construct the definite integral of [Maple Math] from [Maple Math] to [Maple Math] . This integral can now be evaluated either symbolically or numerically.

> f;

[Maple Math]

> F := Int(1/2*x+sin(x)+exp(-1/6*x),x = x0 .. x1);

[Maple Math]

> F := 1/4*exp(-1/6*Pi)*Pi^2*exp(1/6*Pi)+exp(-1/6*Pi)*exp(1/6*Pi)-6*exp(-1/6*Pi)+7;

[Maple Math]

> simplify( % );

[Maple Math]

> evalf( % );

[Maple Math]

>

>

Differential Equations

The DEtools package (and the odeplot command in the plots package) are very useful when preparing graphical demonstrations about differential equations.

> with( DEtools );

[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]

First-Order Differential Equation

Consider the first-order ordinary differential equation

> ODE := diff( x(t), t ) + 2*x(t) = 1+sin(t)+exp(-2*t);

[Maple Math]

>

The general solution to this problem (or to the related IVP) can be found using the context menu - or by direct use of the dsolve command.

>

> R5 := dsolve(ODE,{x(t)});

[Maple Math]

> dsolve( { ODE, x(0)=alpha }, x(t) );

[Maple Math]

>

Personally, I believe the direction field is more informative:

> DEplot( convert(ODE,piecewise), x(t), t=0..5, [[0,1],[0,2],[0,-5],[0,5]], arrows=THIN );

[Maple Plot]

>

Second-Order Differential Equation

Consider the second-order linear ODE with constant coefficients and a piecewise-defined forcing term:

> ODE2 := diff( x(t), t,t ) + x(t) = t + (5-t)*Heaviside( t-5 );

[Maple Math]

>

Prior to constructing a solution, it might be useful to create a plot of the forcing function.

> plot( rhs(ODE2), t=0..10 );

[Maple Plot]

>

Now, the solution can be obtained "directly" and then massaged into a more reasonable form:

> dsolve( ODE2, x(t) );

[Maple Math]
[Maple Math]
[Maple Math]

> combine( % );

[Maple Math]

> collect( %, Heaviside(t-5) );

[Maple Math]

>

A more natural means of obtaining the solution is to use Laplace transforms:

> dsolve( ODE2, x(t), method=laplace );

[Maple Math]

>

First-Order System of Differential Equations

> with( plots, odeplot );

[Maple Math]

>

Here we illustrate another method of creating a graphical view of the solution to ODEs by considering a familiar first-order system of ODEs:

> sys := diff(y(x),x)= z(x),

> diff(z(x),x)=-y(x);

[Maple Math]

> ic := y(0)=0, z(0)=1;

[Maple Math]

> fcns := { y(x), z(x) };

[Maple Math]

> p:= dsolve( {sys,ic}, fcns, type=numeric );

[Maple Math]

> odeplot( p, [x,y(x)], -4..4 );

[Maple Plot]

> odeplot( p, [ [x,y(x)], [x,z(x)] ], -4..4 );

[Maple Plot]

> odeplot( p, [ [x,y(x)], [x,z(x)], [y(x),z(x)], [x,y(x)^2+z(x)^2] ], -4..4, scaling=constrained );

[Maple Plot]

>

The exact solution can, of course, be found:

> dsolve( { sys, ic }, fcns );

[Maple Math]

>

>

Getting Information from Maple and the WWW

An excellent source of introductory information about Maple is the New User's Tour . For assistance with a specific command, or to locate the necessary command, you should always consult the on-line help (see also the help and ? commands). I also distribute a copy of the Maple Quick Reference Guide ( http://www.math.sc.edu/~meade/maple/maple-ref5.pdf) to all of my students.

>

There are numerous archives of Maple worksheets on the WWW. Here are few of the better sites that I frequent:

Waterloo Maple Software -- http://www.maplesoft.com/

Maple V bilingual (German/English) -- http://www.math.utsa.edu/mirrors/maple/maplev.html

Indiana University Stat/Math Center -- http://www.indiana.edu/~statmath/math/maple/

NC State Maple Archives -- http://www2.ncstate.edu/math/Projects/MapleArchive/MapleArchive.html

These archives contain diverse collections of materials. If you are looking for infomation on a specific topic or for use in a specific course, you should use your browser to conduct a search of the WWW. Some materials are provided in the Maple Share library. In addition, I strongly recommend the Maple User's Group ( http://daisy.uwaterloo.ca/SCG/MUG.html). This mailing list is moderated at the Symbolic Computation Group at the University of Waterloo; the typical volume is about 10 messages per week.

>

>