Sample Interactive Lesson

The following cannot be changed; but the downloadable version is interactive.

In this lesson you will get a brief introduction to the numeric, symbolic and graphic features of Maple.

Input the following commands. They are self-explanatory. Maple response follows each command.

Thus, both input and output are listed on this Maple worksheet.

If you get an error message, correct the syntax.

First of all, we show that Maple can be used as a calculator and then show that it can be used as a computer algebra system.

Maple as a calculator:

> 2/3+8/7

Warning, premature end of input

Remember every command should end with ; (a semicolon).

> 2/3 + 8/7;

[Maple Math]

> evalf(%);

[Maple Math]

evalf(%) means evaluate the previous expression. Maple uses the traditional order of operations.

Maple as a computer algebra system

Maple performs symbolic operations, like factoring, the four operations, substitution, solving sophisticated equations or systems of equations.

Factoring

> factor(x^2+5*x-6);

[Maple Math]

Multiplying two polynomials

> expand((x+6)*(x-1));

[Maple Math]

Solving an algebraic equation

> solve((x^2+5*x-6),x);

[Maple Math]

Substituting in an algebraic expression

> subs(x=3,(x^2+5*x-6));

[Maple Math]

Solving a general algebraic equation

> solve(a*x^2+b*x+c=0,x);

[Maple Math]

Solving a system of equations

> solve({-2*x+y-3*z=1,2*x-2*y+z=-3,x+y+z=-3},{x,y,z});

[Maple Math]

Solving a dependent system of equations

Maple solves a dependent system of equations. In the following, Maple chooses arbitrarily one variable and expresses the remaining variables in terms of that variable.

> solve({-2*x+y-3*z=1,2*x-2*y+z=-3},{x,y,z});

[Maple Math]

Solving a recurrence equation as a function of n

Using the rsolve command, Maple solves a recurrence equation, if possible, returning f as

a function of n.

> rsolve({f(n)=f(n-1)+f(n-2),f(0)=1,f(1)=3},{f(n)});

[Maple Math]

We can specify the number of digits for evaluating this expression.

> evalf(%,2);

[Maple Math]

Clearing memory of Maple variables

Sometimes Maple holds on to values assigned to variables. If you see any strange output, then assign the variable its own name, as below, using the single quotes around f. This frees the variable for further use.

> f:='f'; x:='x';

[Maple Math]

[Maple Math]

Defining a function

Maple distinguishes between an expression and a function. Define a function using the assignment symbol, :=. Create an arrow use a - (minus sign) followed by > (greater than) symbol.

> f:=x->x^2 + 1;

[Maple Math]

Evaluating a function

Define the function first. Then use evalf( ).

> evalf(f(4));evalf(f(3+h));

[Maple Math]

[Maple Math]

Maple does not evaluate f(3 + h) unless the value for h is given.

Creating a table of values for a function

To create a table of values (x, f(x)) from -2 to 2 with increments of 0.5 for f(x) = [Maple Math] ,

use the following steps. We also separate x and f(x) by enclosing five spaces between two backward quote ( ` ) symbols. The backward quote symbol is the key located next to 1 on the top left corner of the keyboard.

> f:=x -> x^3;

[Maple Math]

> for x from -2 by 0.5 to 2 do print (x, ` `, f(x)) od;

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

Plotting graphs of functions

We plot 1) one function, 2) two functions and 3) a piecewise function.

Suppose the function is given by y = t sin t

To plot a graph of the function, with labels on the y-axis and title, enter the following.

Titles must be enclosed between two backward quote ( ` ) symbols.

> plot(t*sin(t), t=-3*Pi..3*Pi,`t*sin(t)` = -10..10,title=`My First Graph`);

[Maple Plot]

The graph can be reduced or enlarged by resizing the plot window. To do this place the mouse pointer near the graph. Click the left mouse button. This makes the plot window visible. Drag the right bottom corner of the window in or out with the mouse pointer which turns into a two sided arrow.

Two or more functions are plotted with the same reference axes as follows.

> plot({t*sin(t),t^2*sin(t)},t=-3*Pi..3*Pi,title=`My Second Graph`);

[Maple Plot]

To plot more complicated functions we need to activate the built-in package: plots.

We plot the piecewise function f( x ) = [Maple Math]  for [Maple Math] < 2

                                                    = [Maple Math]for 2 <= [Maple Math] < 3

                                                    = 5    for [Maple Math] >= 3

(where <= means 'less than or equal to', >= means 'greater than or equal to')

using the plots package as follows.

> with(plots);

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

First we define the given piecewise function.

> f:=x->piecewise(x<2,x,x<3,x^2,5);

[Maple Math]

The graph is plotted as follows.

> plot(f(x),x=-2..6);

[Maple Plot]

Maple connects the discontinuities by a vertical line.

To show discontinuites we use the condition: discont = true

> plot(f(x),x=-2..6,discont=true);

[Maple Plot]

Polar functions and graphs

Polar functions are plotted using polarplot command. We plot r = sin 3t.

> polarplot(sin(3*t),t=0..2*Pi);

[Maple Plot]

Parametric functions and graphs

Next we plot the parametric function x = [Maple Math] , y = 2 [Maple Math] -1 <= t <= 1.

> plot([t^2,2*t^3,t=-1..1]);

[Maple Plot]

3D graphs

Three dimensional graphs are plotted with the plot3d command. Here we graph

      1.     z = cos xy, x = -3..3, y = -3..3,

and 2.     r = [Maple Math] cos ( [Maple Math] ) on the interval - [Maple Math] <= [Maple Math] <= [Maple Math] and - [Maple Math] <= [Maple Math] <= [Maple Math]

The graphs can be rotated by grabbing one corner by the mouse arrow. The shading changes accordingly. A choice of axes is available on the toolbar.

> plot3d(cos(x*y),x=-3..3,y=-3..3);

[Maple Plot]

Plotting graphs in spherical coordinates

> sphereplot(theta*cos(phi),theta=-Pi..Pi,phi=-Pi..Pi);

[Maple Plot]

Plotting the intersecting surfaces

We plot the intersection of two surfaces: z = [Maple Math] - [Maple Math] and x = 1

> implicitplot3d({z = x^2 - y^2, x = 1}, x = -5..5, y = -5..5,z = -10..30, title = `Intersecting Surfaces: z = x^2 - y^2, x = 1`);

[Maple Plot]

Calculus using Maple

Limits, derivatives, partial derivatives, derivatives of higher order, indefinite, definite and improper integrals are calculated as follows.

limit of f(x) as x approaches 0.

> limit(sin(x)/x,x=0);

[Maple Math]

limit of f(x) as x approaches infinity.

> limit((1+1/x)^x,x=infinity);

[Maple Math]

limit of f(x) as x approaches 1.

> limit((x^2-1)/(x^3-1),x=1);

[Maple Math]

Derivative of a function

> diff(x^4/(x^3+1),x);

[Maple Math]

Partial derivative with respect to x.

> diff((x-2)*y^2,x);

[Maple Math]

Partial derivative with respect to y.

> diff((x-2)*y^2,y);

[Maple Math]

3rd Derivative of a function

> diff(x^6,x,x,x);

[Maple Math]

Indefinite Integral (antiderivative)of a function with respect to x.

> int(x^2-3,x);

[Maple Math]

Definite Integral of a function with respect to x from -2 to 2.

> int(x^2-3,x=-2..2);

[Maple Math]

Integration of an improper integral.

> int(1/x^.5,x= 0..1);

[Maple Math]

_____________________________________________________

MSIP Grant #P120A80089-98: "Three Urban Calculus Reform programs: Adopting the Best" 1998-2001