You are on page 1of 18

3-Days Workshop at HPCC Presented by: Ms.

Nida Fouq, ITM, HPCC , NEDUET

MAPLE MANUAL
Introduction:
Maple is the essential technical computing software for today’s engineers, mathematicians, and
scientists. Whether you need to do quick calculations, develop design sheets, teach fundamental
concepts, or produce sophisticated high -fidelity simulation models, Maple’s world -leading computation
engine offers the breadth and depth to handle every type of mathematics.
Maple combines the world’s most powerful mathematical computation engine with an intuitive,
“clickable” user interface. Its smart document environment automatically captures all of your technical
knowledge in an electronic form that seamlessly integrates calculations, explanatory text and math,
graphics, images, sound, and diagrams.

MAPLE Tutorial:
Every Maple command is next to a prompt (the greater than sign >), and every Maple command must be
terminated by a semicolon or colon. The semicolon tells Maple to print the result of the command, the
colon tells Maple not to print the command's result.
A Maple command can contain a comment that is not really part of the command. A pound sign (i.e. #) as
part of a line of Maple input means a comment that Maple should ignore.

> 4+4; # Maple ignores wha t comes after the pound sign.

Maple is a numeric calculator


Algebraic Calculations
2+4;
12*34567890;
134^39;
3/5 + 5/9 + 7/12; Maple can calculate with fractions without converting to decimals

1/3 +1/3;
1.0/3 +1/3; answer is incorrect use evalf for approx
evalf(1/3 +1/3);
sqrt(24); leaves the answer in exact form
sqrt(24.0); Or use evalf
4*(3+Pi);
100!;
length( % ); Maple can determine the num ber of digits in a large number

0.3463678+1.7643
Converting rational
Convert(%,’rational’) or
convert(ctrl+L,’rational’) enter the equation when ctrl+L window activate

1
3-Days Workshop at HPCC Presented by: Ms. Nida Fouq, ITM, HPCC , NEDUET

Trigonometric functions
sin(5*Pi/3); evalf(%);
tan3(Pi/3); sec(Pi/4); arcsin(-1);

Multiple Command Execution in single line


sin(Pi/3); cos(Pi/3); tan(Pi/3);
or
sin(Pi/3); press [Shift] + [Enter]
cos(Pi/3); press [Shift] + [Enter]
tan(Pi/3); press [Enter]

exp(1); exponential function


abs(-3);
abs(exp(1)-Pi);
ifactor(31722722304); Maple can find the prime factorization of any integer
ifactor(100!);

Maple can test an integer and determine if it is a prime number or not.


isprime( 2^19 - 1 );

Maple can find the greatest common divisor of two integers.


igcd( 6!, 7! );
igcd( 231, 260 );

ilcm(-10,6,-8);
max(3/2 , 1.49);
min(3/5, ln(2), 9/13, - ∞);

seq(k^2,k=1..100);

(3+3 I)/(2 + 6 I) #Complex Number Computation , I represents sqrt(-1)

using the command


eval stands for evaluate and f for floating point
evalf(3/5+5/9+7/12);
evalf(Pi); evalf(Pi,100); Try asking for ten thousand decimal places of Pi.

Assigning variables
Using assignment operator : =
k := 3/5+5/9+7/12;
evalf(k);
evalf(k,3);

2
3-Days Workshop at HPCC Presented by: Ms. Nida Fouq, ITM, HPCC , NEDUET

j := 2^5;
sqrt(j);

w := 4*(3+Pi);
evalf(w,4);

result := seq(sqrt(k),k=1..10);
evalf(result);

Pi;
evalf(%);
%+5;

Warning: Use of % should be avoided as much as possible, as it may make the worksheet unreadable.

Clearing Variables
Using command
Restart; OR unassign('x'); OR x := 'x';

Vectors
A vector in Maple is a one-dimensional array whose indices start from 1. The vector() function is used to
define a vector in Maple. It is part of the linalg package. There are several ways to define a vector:
1. vector([x1,x2...xn]) or vector(n, [x1,x2,...xn]);
 Creating a vector of length n
 containing the given elements
 x1,x2,...xn .
2. vector(n);
 Creating a vector of length n with unspecified elements.
#load the package

Defining the vector a with specified elements 1,2,3,4,5

Defining the vector A with specified elements 1,4,2

Defining the vector A with 4 unspecified elements


# Zero Vector
If a vector A is defined, we can access the nth element of the vector A by typing A[n].
A:= Vector([1,2,3,4,5]);

Vector Algebra
The commonly used algebra operations on vectors are as follows:

A:= Vector(3,[1,2,3]);
B:= Vector(3,[-4,-2,-1]);
2*A;

3
3-Days Workshop at HPCC Presented by: Ms. Nida Fouq, ITM, HPCC , NEDUET

-3*B;
A-B
A+B
DotProduct(A,B);
CrossProduct(A,B);

Matrices
A matrix in Maple is a two-dimensional array with row and column indices starting from
1. Matrices are defined in two ways:
 A:=Array(1..m,1..n); # A matrix with m rows and n columns
 A:=Matrix(m,n,[..list f elements..]); #a matrix with m rows and n columns with specified
elements
The function Matrix() is part of the LinearAlgebra package.

A:= Matrix(2,2,[1,3,4,6]);

The elements are read sequential ly and inserted row by row.

Matrix Algebra

* Sign

it will display zero matrix of 2X2

4
3-Days Workshop at HPCC Presented by: Ms. Nida Fouq, ITM, HPCC , NEDUET

a:= m2(1..3, 2) select sub-matrix

The eval command


e.g 3x2+8

W := 3*x^2+8;
eval(3*x^2+8,x=4); evaluating the expression where x has the value 4
OR
eval(W,x=4);

M := eval(W,x=5+2*u);
expand(M);

Expression , replace by 7 and y by 12


U := (2/5)*x^2+3*y;
q := eval(U,[x=7,y=12]);
evalf(q);

f := t^2*sin(t); self define expression


eval( f, t=Pi/4 ); evaluate our function using the eval command

We can also evaluate our function using the subs command


subs( t=Pi/4, f );

Notice that, unlike the eval command, subs did not simplify the result so we also need to use simplify.
simplify( % ); evalf( % );

f := exp(sqrt(t))*(1+arcsin(sec(t)));
eval( f, t=ln(2) );
evalf( % );
(Notice that the answer is a complex number. I is Maple's notation for  1 .)

Function Vs Expression
Function is defined by:
f := x -> cos(Pi*x)+3;

Take note of the syntax here. The "arrow" is necessary, and is made by typing (with no
intervening space) a "minus sign" and a "greater than" symbol.

Warning: Maple will not define a function if you type either

f(x) := cos(Pi*x)+3;
or

5
3-Days Workshop at HPCC Presented by: Ms. Nida Fouq, ITM, HPCC , NEDUET

f := cos(Pi*x)+3;
The first input fails to define the desired function because of the assignment to the symbol . In
general, this kind of assignment should be avoided in Maple.

The second input creates an expression, not a function.


If the following three commands
restart;
f(x) := x^2;
f(3);
are entered in the workspace below, the output will not be the expected
=9
The correct way to enter this function and evaluate it at would be
restart;
f := x -> x^2;
f(3);

This is the expression,


y := 3*x+x^2;
and this is the function.
f := x -> 3*x+x^2;

Putting values
f(-1);
f(2+sqrt(5));
evalf(f(2+sqrt(5)));
f(x+4);
simplify(f(x+4));

Converting Expressions to Functions


if an expression such as
Q := x*sin(x)-exp(2*x);
already appears in Maple, it can be made into a function only by use of the unapply command, whose
syntax is
f := unapply(Q,x);
The expression is now the function , so that evaluation at, for example, , is
accomplished with
f(1);

The expand command


expand command is to "multiply out" products of polynomial expressions. It can also be used to expand
trigonometric and other more general functions.
k := (x+2)^2*(3*x-3)*(x+5);
expand(k);
expand( (x+1)^8 );
expand(sin(2*x));
, , etc.

6
3-Days Workshop at HPCC Presented by: Ms. Nida Fouq, ITM, HPCC , NEDUET

The factor command


The factor command can factor polynomials
Factor the expression:
w := 3*x^2-10*x-8;
factor(w);
factor( x^6-1 );

Expression

H := 2*(x-2)*(2*x^2+5*x+2)*(x+4);
ans := expand(H);
factor(ans); different from original expression bcoz it factorizes 2x 2+5x+2

B := (x^3-7*x^2+15*x-9)/(x^2-4*x+3); used with a rational expression


factor(B);
factor(numer(B)); numer and denom commands to examine the factors of the numerator and
denominator separately
factor(denom(B));

The simplify command


25^(1/6);
Simplify(%);

Trigonometric expressions

V := cos(x)^5+sin(x)^4+2*cos(x)^2 -2*sin(x)^2-cos(2*x);
simplify(V);

Add rational expressions.


M := (1/(x+1))+(x/(x-1));
simplify(M);

The combine command


combine(cos(x)^2 - sin(x)^2);
expand and combine are inverses of each other

Normal Function
If an expression contains fractions, it may be useful to restructure the expression as a large
fraction by canceling out common factors in the numerator and denominator. The normal
function implements this process.

normal(x5/(x+1)+ x4/(x+1));

7
3-Days Workshop at HPCC Presented by: Ms. Nida Fouq, ITM, HPCC , NEDUET

The solve command


Used to solve an equation for some unknown. You give command for the equation to solve and the
variable to solve for. Here is an easy example.

solve( 5*x+3=2, x );

Maple tells us what value of x solves the equation. You may wonder why we need to tell Maple to solve
for x when in fact x is the only variable in the equation. But it may be that the equation has several
variables, so we always need to tell Maple what var iable to solve for. For example,

solve(4-v=2*T-k*g,g);

Here is a little nicer way of displaying the same result:

g = solve(4-v=2*T-k*g,g);

solve( a*x+b=c, x );
solve( a*x+b=c, b );

eqn1 := a*x^2+b*x+c=0;

Notice how there are two distinct kinds of "equal signs" in the above command, one is the assignment
operator and the other is part of the equation. The first "equal sign" says that eqn1 is a name for
a*x^2+b*x+c=0. The second "equal sign" asks if the left hand side of the equation is equal to the right
hand side.

solve( eqn1, x );
a := 1; b := 2; c := -1; substitute values in quadratic equation
eqn1;

solution := solve( eqn1, x );

The name solution now refers to both of the solutions! Here is how we can give a name to each
individual solution.

solution[1];
solution[2];

Suppose we want to check that these solutions really do solve the quadratic.

subs( x=solution[2], eqn1 );


simplify( % );

eq := x^3-5*x^2+23=2*x^2+4*x-8;
lhs(eq);
rhs(eq);
eqn2 := lhs(eq)-rhs(eq)=0;

8
3-Days Workshop at HPCC Presented by: Ms. Nida Fouq, ITM, HPCC , NEDUET

eqn3 := x^3-34*x^2+4=0;
H := solve(eqn3,x);

sol := evalf(H);

Note that the I stands for . When a solution is this complicated it is more useful to look at the
approximate solutions using evalf command.
The small imaginary part attached to each real root can be removed with the fnormal command.

fnormal([sol]);

Finally, the imaginary unit, , can be removed with

simplify(fnormal([sol]));

fsolve(eqn3,x);

Maple's fsolve command will compute a numerical approximation for each solution of a polynomial
equation.

eqn := x^4-x^3-17*x^2-6*x+2=0;

fsolve(eqn,x);

Maple can do symbolic manipulations on more than one equation at a time.


Here are two equations is two unknowns.

eqn1 := 2*x+4*y=6;
eqn2 := -x+5*y=1/2;

We shall ask Maple to solve this system of equations, then give the solution a name and
compute a decimal approximation of the solution. Notice the way the solve command is
written here, using braces around the equat ions and the variables.

answer := solve( {eqn1, eqn2}, {x, y} );


evalf( % );

Notice that the variables x and y still do not have values. (Those are not assignment operators inside the
braces.)

x; y;

The solve command found the values of x and y that satisfy the equations, but the solve
command does not give x and y those values. The assign command is used to assign the values from
the solution to the variables.

assign( answer );
x; y;

9
3-Days Workshop at HPCC Presented by: Ms. Nida Fouq, ITM, HPCC , NEDUET

We have seen several examples of how Maple can solve equations symbolically. After we have computed
the answer symbolically, we can always use the evalf command to find a numeric approximation of
the solution. However, there are equations that Maple cannot solve symbolically and in those cases we
can only calculate numeric approximations of a solution. Let us look at an example. Here is a fairly
complicated equation. We shall give it the name eqn3.

eqn3 := -2+exp(t)=sin(t^2);

Let us have Maple try to solve it symbolically.

solve( eqn3, t );

Not a very useful answer. (Look at the answer very carefully. Can you make sense out of it? Is it
really "the solution" of the equation?) So let us use the fsolve command to tell Maple to solve
this equation numerically.

answer := fsolve( eqn3, t );

Why is this command called "fsolve" and not "solvef"? the evalf and fsolve commands they are
described respectively as "evaluate using floating -point arithmetic" and "solve using floating -point
arithmetic". So it would seem that their names should be more consistent.

Let us check that our numeric solution really is a solution.

subs( t=answer, lhs(eqn3) );


subs( t=answer, rhs(eqn3) );

We still cannot tell if these are the same number. So find their decimal values.

evalf( subs( t=answer, rhs(eqn3) ) );


evalf( subs( t=answer, lhs(eqn3) ) );
Close enough.

Solve for x in the quadratic Equation

Solve for x in eq. (x-7)2+(x-1)2 = 4((x-1)2+(x-4)2)

Ctrl+drag the equation, right click, select Manipulate equation .

Group all of the terms to left


In Addition region, group terms row, accept the default side Left, click Do.

Expand the left side of equation


Miscellanous Operations region, we can apply different operations, we have to expand so from the drop -
down menu select expand, since left side is already selected, click Do.
Click Return Steps
Now Ctrl+Drag the final result into the new document block region.
Right click, Solve-> Solve for variable ->x

10
3-Days Workshop at HPCC Presented by: Ms. Nida Fouq, ITM, HPCC , NEDUET

Instant Solution
(x-7)2+(x-1)2 = 4((x-1)2+(x-4)2)
Right click the expression and select Solve -> Solve for variable->x

Pick and Drop Interactive Solution


(x-7)2+(x-1)2 = 4((x-1)2+(x-4)2)
Write the above expression and then enter
Ctrl+L “enter the assigned number of the above equation” then click Ok
With the equation number inserted, enter -(x-7)2
Repeat for (x-1)2
The left side became zero(0).
Enter “expand( “ on the command prompt
Now Press Ctrl+L and enter the value of the resul t then closing the parenthesis,).
Similarly find factor or solve

Graphical Solution
(x-7)2+(x-1)2 = 4((x-1)2+(x-4)2)
Write expression and then enter.
Right click the output , select Move to Left, right click the output and select Left hand side. Right click
the output and select Expand.
Ctrl+drag the eq into new document block , right click, select Plots-> 2-D Plot.
Right click the plot and select Axes-> Properties. In the Horizontal tab, de-select Use data extends,
change the range 0 and 5. Similarly vertical tab change -5 to 10.

Quadratic Trigonometric equation


6cos2(x)-cos(x)-2= 0 [0,2*Pi]

Graphical Solution

Write equation, then press enter button, right click select left hand side, right click select plots -> plot
builder.
Modify plot range 0 to 2*Pi

Solution by task template


Write equation, select Tools menu -> tasks-> Browse. Expand the Algebra folder and Solve Analytically
in a specified interval
Click Insert minimal Content.
Replace the current expression . And run.

Example:Linear Systems with an Infinite Number of Solutions

When a system has more variables than equations we often get not one, but an infinite number of
solutions.

eqns := { x+2*y+z=2 , 3*x+y=1 };


soln := solve(eqns);

11
3-Days Workshop at HPCC Presented by: Ms. Nida Fouq, ITM, HPCC , NEDUET

Now let's look at the solution that is generated when we take x=1,2,3 and 4
eval(soln,x=1);
eval(soln,x=2);
eval(soln,x=3);
eval(soln,x=4);

Maple can also do symbolic calculus calculations.


Derivatives
examples using functions g and h,

diff( g(x)*h(x), x );
diff( g(x)/h(x), x );
simplify( % );

Maple can compute partial derivatives.


g := 1/(x^2+y^2);

Maple uses the same command, diff, for computing partial derivatives.

diff( g, x );
diff( g, y );

We can compute higher order partial derivatives. Here are all four of the second order partial
derivatives.

diff( g, x,x );
diff( g, y,y );
diff( g, x,y );
diff( g, y,x );

Here is what a partial derivative looks like symbolically.


diff( h(x,y), x,y );

example:
f := x^2*sin(3*x);
diff( f, x );
diff( f, x,x ); Second Derivative

We can compute any order of derivative that we want, computing the 7th derivative.
diff( f, x$7 );

By using interactive
Question:
f(x)=xcos(x)
graph: f, f’, f”
-Pi to Pi

Solution:
x*cos(x)

12
3-Days Workshop at HPCC Presented by: Ms. Nida Fouq, ITM, HPCC , NEDUET

now format menu Create Document Block .Ctrl+drag the original expression to the new document
block. Right click the expression and select Differentiate -> x.
now again go to format menu create doc block. Ctrl+drag the derivated expression, right click and
select Differentiate -> x.
Ctrl+drag the expression new document block, right click and select plots-> plot Builder.
In the interactive Plot Builder: Select Plot Type dialog, change x-axis range –Pi..Pi
High light the other derivative and ctrl+drag and plot them or u can simply drop these ex pression the
graph
Add a Legend
Right click in the plot region select Legend -> Show legend
Add a Title
Click the drawing I con in the toolbar Click T in the drawing menu.
Click the plot region the text will appear

Solution By Tutor:
Tools->Load Pacakage-> StudentCalculus1
x*cos(x)
right click the expression, select tutor ->calculus-single variable-> Derivatives

change the different options and click Display and then close

Access The Tutor from a Task Template


Tools-> tasks-> Browse
Open Task Template dialog, now expand calculus -> Derivatives-> graph f(x) and its Derivatives
Click Insert Minimal Content at the top of the dialog to insert task template into the current document
Enter the new expression in the f(x) region
Enter the interval
Click Launch Differentiation tutor
Click close

Antiderivatives
int( x*ln(x), x );

Notice that Maple does not put a +C at the end of its antiderivatives. You are expected to know that they
really are supposed to be there.

int( x*ln(x), x=0..2 );


evalf( % );

Maple has a slight variation on the int command. The Int command is called the inert form of int. The
inert form of a Maple command does not do any calculation. Instead, it typesets a formula for us.

Int( x*ln(x), x );

We can use the inert form of a Mapl e command to get nice looking formulas like the following.

13
3-Days Workshop at HPCC Presented by: Ms. Nida Fouq, ITM, HPCC , NEDUET

Int( x*ln(x), x ) = int( x*ln(x), x );

Symbolic Summation
sum( i, i=1..n );
factor( % );
Sum( i^2, i=1..n ) = sum( i^2, i=1..n );

Maple can also compute limits


limit( sin(2*x)/(3*x), x=0 );
Limit( ln(x^2)/(x-1), x=1 ) = limit( ln(x^2)/(x-1), x=1 );
Limit( 1/x-1/(exp(x)-1), x=0 ) = limit( 1/x-1/(exp(x)-1),x=0);
Maple can do one sided limits.
Limit( x^(p/ln(x)), x=0, right ) = limit( x^(p/ln(x)), x=0,
right ); you will notice +ve (when right)or –ve sign (when left)associated with zero in limits
Maple can also do limits at infinity.
Limit( (ln(n))^(a/n), n=infinity) = limit( (ln(n))^(a/n),n=infinity);
Limit( x^n/exp(x), x=infinity) = limit( x^n/exp(x),x=infinity);
And Maple can compute Taylor series.
taylor( sin(x), x=0 );
taylor( sin(x), x=Pi/2, 10 );

GRAPHING CALCULATION
Tools->Assistants->plot builder.
Add expressions
X^2+1
Cos(x)+1
Ok
Another way
Write expression on document mode
e.g x^2
right click on the expression, select plots -> plot builder.
Another way
plot( x^2, x=-5..5 );
We give the plot command the formula that we want to graph and then tell it what interval of
numbers to draw the graph over.
plot( sin(x), x=-2*Pi..2*Pi );
Maple can even plot graphs from negative infinity to infinity. This is useful when we want an
overall idea of what a graph looks like without having to guess at an appropriate domain.
g := (x^2+3*x)/(x^4+x+1);
plot( g, x=-infinity..infinity );
plot( x^2, x=-infinity..infinity );
plot(sin(x), x=-infinity..infinity );
We can also control the range used on the vertical axis of a graph.

plot( sin(x), x=-2*Pi..2*Pi, -1/2..1/2 );

14
3-Days Workshop at HPCC Presented by: Ms. Nida Fouq, ITM, HPCC , NEDUET

Give expression/function a name first and then graph it.

f := x^3-x;
plot( f, x=-5..5 );
plot( f, x=-5..5, -10..10 );
More than one functions at a time by putting a list of functions inside a pair of brackets.
plot( [sin(x), cos(x)], x=0..2*Pi );

Graphs of data points


When we graph data points we can have Maple either graph the points and connect them together with
straight lines or just graph the points by themselves. Here is how to give Maple a list of points to be
plotted and joined by straight lines.

plot( [ [0,1/2], [1/2,1], [1,1/4], [3/2, 2], [2, 1] ] );


plot( [ [0,1/2], [1/2,1], [1,1/4], [3/2, 2], [2, 1] ], style=point ,color=blue, symbol=diamond );
Using lists of data points, we can get Maple to draw any polygon in the plane.
plot( [ [0,2], [1,-1], [-1,1], [1,1], [-1,-1], [0,2] ], axes=none );
We can give the list of points a name before we plot it.
List := [ [1,1], [3,2], [3,1], [1,2], [1,1] ];
plot( List, 0..3, 0..2 );

TITLE Option
plot( 4*x*(1-x), x=0..1, title="The logistic map." );

Using with(plots) command


A special plotting package called plots contains many additional graphing features. To use these
commands, you need to execute the following line which loads plots. Recall, the colon at the end of the
statement allows this line to be executed without displaying any distracting output. To se e the contents of
plots you can change the colon to a semicolon.
with(plots):
The display command allows you to combine graphs of expressions and points in the same picture. The
first step is to name the individual picture components.

pict1 := plot([-3*x+5,9-x^2],x=-3..5,color=[green,red]):
pict2 := plot([[-1,8],[4,-7]], style=point,color=blue, symbol=circle):
display([pict1,pict2]);

Interactive Command
The interactive command is part of the plots package. It allows you to build plots interacti vely by
opening a window where you can specify details.
Plots[interactive](sin(x)+1);
Or
interactive(sin(x)+1);
Select 2-D Plot, try different options for line style, axes, or color as well.

15
3-Days Workshop at HPCC Presented by: Ms. Nida Fouq, ITM, HPCC , NEDUET

Parametric Equations
Maple's plot command can also be used to graph curves described by parametric equations.
To graph the parametric curve corresponding to the pair of parametric equations: and on
the parameter interval use the command:

plot([f(t), g(t), t = a..b], x = xmin..xma x, y = ymin..ymax);


There are two things to take careful note of here. First note that there are three entries in the square
brackets : the two parametric expressions for x and y and the parameter domain. Also note that the
viewing window for the plot is separately specified by the x- and y-ranges (i.e., x = xmin..xmax, y =
ymin..ymax).
Plot the parametric curve determined by and over the t-interval [-2, 2] .

plot([t^2-t,2*t-t^3,t=-2..2],x=-2..5,y=-5..5);
When the range is inside the brackets, Maple is graphing the parametric curve but when the range is
outside the brackets, Maple is graphing two separate functions.
more interesting parametric curve.
plot( [t+2*sin(2*t), t+2*cos(5*t), t= -2*Pi..2*Pi] );

Implicit Plots
Maple can plot curves that are implicitly defined by an equation in the variables x and y.

The implicitplot command computes the two-dimensional plot of an implicitly defined curve. By
default, the curve is computed in Cartesian coordinates.

Graph the equation using the implicitplot command.

Recall that this is the equation of an ellipse with the lengths of major and minor axes equal to 10 and 6
respectively.
Our first attempt at getting the expected graph comes up short !
implicitplot(x^2/25+y^2/9=1,x= -5..5,y=-5..5);

Why did we get a circle instead of an ellipse ?

The problem here is that the x- and y-scales are not equal. To force equal scaling add
"scaling=constrained" or click on the graph to expose the graphing toolbar, and select the button marked
1:1.
The graph then appears as seen in the following figure.

implicitplot(x^2/25+y^2/9=1,x= -5..5,y=-5..5,scaling=constrained);

16
3-Days Workshop at HPCC Presented by: Ms. Nida Fouq, ITM, HPCC , NEDUET

Polar Graphs
Graphs of polar equations are handled by the polarplot command, which is part of the plots
package accessed using with(plots).

The general form of the command is:


plot([r(s), theta(s), s=a..b], coords=polar);

If the parameter is actually the angle , the command becomes

plot([r(theta), theta, theta=a..b], coords=polar);

For example, to graph 1+cos( ) in polar coordinates using the plot command, type:

plot(1+cos(theta),theta=-Pi..Pi,coords=polar);

Three Dimensional Graphs


3-Dimensional graphs of functions of two variables.

plot3d( sin(x+y), x=-Pi/2..Pi/2, y=-Pi/2..Pi/2 );

Be sure to click on the above graph and try moving it around with the mouse button pressed down. Here
are a few more examples.

plot3d( sin(sqrt(x^2+y^2)), x= -6..6, y=-6..6 );


plot3d( sin(sqrt(x^2+y^2)), x= -6..6, y=-6..6, style=line );
plot3d( sin(sqrt(x^2+y^2)), x= -6..6, y=-6..6, style=contour);
plot3d( sin(sqrt(x^2+y^2)), x= -6..6, y=-6..6, style=point, color=black);
Maple can graph functions of two variables using other co ordinate systems. Here is a sphere as the graph
of a constant function in spherical coordinates

plot3d( 1, theta=0..2*Pi, phi=0..Pi, coords=spherical, scaling=constrained );

Maple can also graph parametric surfaces in space. Here is a sphere graphed as a parametric
surface (in rectangular coordinates).

plot3d( [cos(u)*sin(v), sin(u)*sin(v), cos(v)], u=0..2*Pi, v=0..Pi,scaling=constrained);

Cylindrical coordinates
Here is a demonstration of cylindrical coordinates.
plots[coordplot3d]( cylindrical );

[z*theta, theta, cos(z^2)];


plot3d( %, theta=0..Pi, z=-2..2, coords=cylindrical,color=theta );

17
3-Days Workshop at HPCC Presented by: Ms. Nida Fouq, ITM, HPCC , NEDUET

Animation
Animation displays a number of frames in sequence. There are two basic animation functions defined in
Maple. They are animate and animate3d.
Before using them, we must load the plots package via the command with(plot).

Two-dimensional Animation
animate() is used for two-dimensional animation. It has one frame variable, t, and one
dependent variable, x. The frame variable t changes for each fra me and the dependent
variable x defines the function argument range in each frame.

animate(x*t+5, x=-6..6, t=-2..2);


click on picture the animation toolboxes activated. Play the button and see the results.
For continuous play select from the context bar and then click the play button .
By default, a two-dimensional animation consists of 16 frames. If the motion is not smooth, you
can increase the number of frames by using the frames option.
Increase number of frames to 30. It shoul d be noted that computing more frames requires more
time and memory.
animate(x3-3*x2*t, x=-5..5, t=-5..5, frames=30);

Three Dimensional Animations


animate3d() is used for 3-dimensional plot animation. It has one frame variable, t, and
two dependent variables, x and y. The frame variable t changes for each frame and the
dependent variables x and y define the function argument range in each frame.

animate3d(t*(x 2+y2), x=-2..2,y=-2..2, t=1..10);


By default, a three-dimensional animation has 8 frames. We can also use the frames
option to change the frame number.

The next animation also has a lot of frames and it runs for a fairly long time. It is also periodic.
There is a button for "continuous play" and if you click on that button, because of the periodicity
this animation it will play smoothly over and over again.
plots[animate]( [(1+.5*sin(t)*cos(5*s))*cos(s),
(1+.5*sin(t)*cos(5*s))*sin(s), s=0..2*Pi],
t=0..2*Pi, scaling=constrained,
numpoints=100,
color=blue, axes=none, frames=100 );
This last animation is not as complicated as it seems. It is "morphing" a circle. The parametric
equations in the animate command define a "circle" whose radius ( given by the term
1+sin(t)*.5*cos(5*s)) changes both with angle (the s variable) and with time (the t
variable which is also the frame parameter). Try changing any of the parameters in the
command. Even if you do not yet understand the equations, you can modify them to see what
happens. Small changes in the equations can lead to big changes in the animation.

18

You might also like