This first tutorial explains:
|
It is best to work through the tutorials sequentially.
- To begin a maple session on the PCs in the Mathematics Computer Lab (rooms AB 3-333, 3-335, 3-337), click through the sequence:
Start > Programs > Maple 11 > Maple 11
- To end a maple session: click on the X in the upper right corner of the maple window.
- To run a maple tutorial on a PC in the Mathematics Computer Lab, start Maple and click through the sequence:
Help > Take a Tour of Maple
or
Help > Quick Reference
- Note: The maple prompt is usually a > symbol.
- For help during a maple session, click the Help button, or enter
> ?index

> ?command 
where command can be, as examples
> ?plot 
> ?factor 
> ?trig 
> ?simplify 
> ?expand 
> ?Digits 
> ?evalf 
> ?combine 
> ?limit 
Expressions
- Basic Arithmetic Operations
|
+ addition |
* multiplication __ 2 times x+1 is 2*(x+1), not 2(x+1) |
|
- subtraction |
/ division |
|
^ exponentiation |
|
Note: curly braces { } and square brackets [ ] do not represent parentheses in Maple.
- To assign an expression to a variable, use :=
> x := 9 ;
variable x is 9
> w := x+3 ;
variable w is 12
> y := x/2 ;
variable y is 9/2 (not 4.5)
> z := y^3 ;
variable z is 729/8
> qaz := 5*w ;
variable qaz is 60
> qwe := sqrt(x) ;
variable qwe is 3
> zaq := y + w ;
variable zaq is 33/2
- NOTE: Maple commands terminate with a semicolon, not by hitting enter. Consequently, a single Maple command may span many lines.
- Storage is permanent unless a variable is set to another value or is reset
> x := 9 ;
variable x is 9
> x := 4 ;
variable x is now 4
> x := 'x' ;
variable x is reset or "unassigned"
- To see what is stored in a quantity, just enter its name
> x := 9 ;
variable x is 9
> x;
will show that x is 9
- To reset all quantities (almost like exiting maple and starting over)
> restart;

- To plot an expression, say f = x2 + cos x on interval [-2, Pi]
> f := x^2 + cos(x) ;
> plot( f, x = -2..Pi, title = `your title` ) ; 
Notes: The number Pi is represented by Pi (not pi). In Maple, pi represents the Greek letter Pi.
The title is enclosed in left quotes, not right quotes.
- To substitute into an expression, say f = x2 + cos x
> f := x^2 + cos(x) ;
defines f as an expression
> r := subs( x = 0, f ) ;
substitutes x=0 into f and stores cos(0) in r
> r;
shows that r is 1
> subs( x = Pi, f ) ; 
> evalf( subs( x = Pi, f ) ) ;
returns: 8.8696044
> R := evalf( subs( x = Pi, f ) ) ;
stores 8.8696044 in R
Note: One does not evaluate expression f at x = 0 by entering f(0);. This is because f is defined as an expression, not as a function.
- To substitute into a multivariate expression, say f = x2 + xy
> f := x^2 + x*y;
defines f as an expression
> r := subs( x = 1, y = 3, f ) ;
substitutes x=1 and y=3 into f and stores result in r
Functions
- To define f as a function rather than as an expression, say
f(x) = x3 - 3x2 - 9x + 6> f := x -> x^3-3*x^2-9*x+6 ;
f is defined as a function
> f(z);
returns z3 - 3 z2 - 9 z + 6
> f(x+h);
returns (x+h)3 - 3 (x+h)2 - 9 x - 9 h + 6
> plot( f(x), x = -4..5 ) ;
plots f(x) from x=-4 to 5
> plot( f, -4..5 ) ;
plots f from -4 to 5
> f(1);
evaluates f at x=1
Try these (with f defined as above):
> expand( f(x+h) - f(x) ) ; 
> factor( f(x+h) - f(x) ) ; 
> factor( ( f(x+h) - f(x) ) / h ) ;
called the "difference quotient" of f
> limit( %, h = 0 ) ; 
Note: A percent % references the previous result; two %% references the second previous result; three %%% references the third previous result.
- To turn an expression into a function.
Example: Suppose we had defined
y = x3 - 3x2 - 9x + 6
as an expression:
> y := x^3-3*x^2-9*x+6 ;
y is defined as an expression
To turn it into a function, use unapply:
> f := unapply( y, x ) ;
turns expression y into a function f(x)
> f(2);
evaluates f(2) and returns -16.
- To define a multivariate function.
> f := (x,y) -> y * cos(x) ;
f is defined as a function of x and y
> r1 := f(0,2) ;
evaluates f(0,2) and stores result 2 in r1.
> f(Pi,2) ;
evaluates f(Pi,2) and returns -2.
- To turn a multivariate expression into a multivariate function.
Example: Suppose we had defined z = y cos x as an expression:
> z := y * cos(x) ;
z is defined as an expression involving x and y
To turn it into a function, use unapply:
> f := unapply( z, (x,y) ) ;
turns expression z into a function f(x,y)
> f(0,2);
evaluates f(0,2) and returns 2.
> f(Pi,2);
evaluates f(Pi,2) and returns -2.
- To convert powers of trig functions to sines and cosines, use combine:
> Q1 := cos(x)^3 - 4*sin(x)^5 ;

> Q2 := combine(Q1) ; 
Note:
cos(x)^3 means cos3 x or (cos x)3.
cos(x^3) means cos (x3).
- To expand trig functions, use expand:
> Q1 := sin(x+y) ;

> Q2 := expand(Q1) ; 
- Piecewise Functions. For example, to define the piecewise function
|
f(x) = |
x + 5 |
if x < -1 |
|
x2 + 1 |
if -1 < x < 2 |
|
|
1 |
if x = 2 |
|
|
7 - x |
if x > 2 |
> f := x -> piecewise( x <= -1, x+5, x<2, x^2+1, x=2, 1, x>2, 7-x) ; 
Note that the order is: ( range 1, function 1, range 2, function 2, . . . )
> f(-3);
evaluates f(-3)
> f(2);
evaluates f(2)
> plot( f(x), x = -6..8, title = `A Piecewise Function` ) ; 
plots f(x) on interval [-6,8] and gives the plot a title
> limit( f(x), x = -1, left ) ;
evaluates the left-sided limit of f(x) at -1
> limit( f(x), x = -1, right ) ;
evaluates the right-sided limit of f(x) at -1
> limit( f(x), x = -1 ) ;
evaluates the limit of f(x) at -1 (it does not exist)
> limit( f(x), x = 2 ) ;
evaluates the limit of f(x) at 2
- Try these examples:
> 8*4;

> 8/4; 
> 9^4; 
> evalf(9/4); 
> factor( x^5 - 8*x^3 + 16*x ) ; 
> simplify( (x^5 - 8*x^3 + 16*x) / x ) ; 
> factor(%) ; 
> evalf(Pi) ;
the number Pi
> evalf(pi) ;
The Greek letter pi is not a number.
> evalf( cos(3) ) ; 
> evalf( log(exp(-4)) ) ; 
Note: The quantity e-4 is entered as exp(-4), not as e^(-4). Likewise, for example, ex2 is entered as exp(x^2), not as e^(x^2).
> f := exp(x); 
> plot( f, x = -2..2 ) ; 
> subs( x = 2, f ) ; 
> exp(2); 
> evalf( exp(2) ) ; 
> g := sqrt(x) ; 
> plot( g, x = 0..2 ) ; 
> combine( sin(2*x)*cos(4*x) + cos(2*x)*sin(4*x) ) ; 
> expand( sin(6*x) ) ; 
> combine(%); 
> expand( cos(x-y) ) ; 
> combine( sin(3*x)^4 ) ; 
> plot( {f,g}, x = 0..2 ) ;
to plot two expressions on a common graph.
Note: Curly braces { } denote a set (list).
> plot( f-g , x = 0..2 ) ;
plots the difference f(x) - g(x)
> h := x^3 ; 
> plot( {f, g, h}, x = 0..2 ) ;
to plot three expressions on a common graph
> plot( 1/(x-3) , x = -2..8, -10..10 ) ; 
plots 1/(x-3) on interval [-2,8] with the range restricted to [-10,10]
> limit( 1/(x-3), x = 3, left ) ;
evaluates the left-sided limit of 1/(x-3) at 3
> limit( 1/(x-3), x = 3, right ) ;
evaluates the right-sided limit of 1/(x-3) at 3
> limit( 1/(x-3), x = -infinity ) ;
evaluates the limit of 1/(x-3) as x approaches -infinity
> limit( 1/(x-3), x = infinity ) ;
evaluates the limit of 1/(x-3) as x approaches infinity
- Digits: By default Maple performs 10 digit arithmetic. We can change the precision easily by settings Digits to another value. For example, to perform 16 digit arithmic in a Maple session, set Digits to 16 at the beginning of your Maple session:
> Digits := 16 ;
sets the precision to 16 in all subsequent calculations
> evalf( Pi ) ;
gives the value of Pi to 16 digits
3.141592653589793
> evalf( exp(1) ) ;
gives the value of the number e to 16 digits
2.718281828459045
> evalf( 1/3 ) ;
gives the value of 1/3 to 16 digits
0.3333333333333333
- Some of the Many Functions Known To Maple Include:
|
Function |
Command |
|
Function |
Command |
|
cos x |
cos(x) |
|
arccot x |
arccot(x) |
|
sin x |
sin(x) |
|
ex |
exp(x) |
|
tan x |
tan(x) |
|
ln x |
log(x) |
|
cot x |
cot(x) |
|
cosh x |
cosh(x) |
|
arccos x |
arccos(x) |
|
sinh x |
sinh(x) |
|
arcsin x |
arcsin(x) |
|
tanh x |
tanh(x) |
|
arctan x |
arctan(x) |
|
arcsinh x |
arcsinh(x) |
Note: The quantity e-4 is entered as exp(-4), not as e^(-4). Likewise, for example, e-x2 is entered as exp(-x^2), not as e^(-x^2), and not as exp((-x)^2).
Maple knows many other functions.
