This first tutorial explains:
|
Help >
Maple Help
[> ?index
[> ?command
where command can be, as examples
Basic Arithmetic Operations
IMPORTANT NOTES:
Expressions
First realize that an expression is NOT a function. An expression may be
manipulated (simplified, factored, stored, plotted, added, multiplied,
etc.), but it CANNOT be evaluated. Furthermore, plotting an expression
f is not performed the same way as plotting a function f(x).
[> 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
[> qwerty := sqrt(x) ;
variable qwerty is 3
[> zaq := y + w ;
variable zaq is 33/2
[> x := 9 ;
variable x is 9
[> x := 4 ;
variable x is now 4
[> x := 'x' ;
variable x is reset or "unassigned"
[> x := 9 ;
variable x is 9
[> x;
will show that x is 9
[> restart;
[> f := x^2 + cos(x) ;
[> plot( f, x = -2.0 .. Pi, title = "Your Title" ) ;
NOTES: The number π is represented
in Maple by
Pi
(not pi).
In Maple, pi
represents the Greek letter lower case π.
[> 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
and not as a function.
[> 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
[> f := x -> x^3 - 3*x^2 - 9*x + 6 ;
f is defined as a function
In more recent versions of Maple, you may enter
[> f(x) := x^3 - 3*x^2 - 9*x + 6 ;
f is defined as a function
[> f(1);
evaluates f at x = 1 and returns 5
[> 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.0 .. 5.0 ) ;
plots f(x) from x = 4 to 5
[> plot( f, -4.0 .. 5.0 ) ;
plots f from x = 4 to 5
Try these (with f defined as above):
[> expand( f(x+h) - f(x) ) ;
[> factor( f(x+h) - f(x) ) ;
[> diffquot := factor( ( f(x+h) - f(x) ) / h ) ;
called the "difference quotient" of f
[> limit( diffquot, h = 0 ) ;
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 named f(x)
[> f(2) ;
evaluates f(2) and returns 16.
[> 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(π,2) and returns 2.
[> y := 'y' ;
restores y to an unassigned quantity
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(π,2) and returns 2.
[> Q1 := cos(x)^3 - 4*sin(x)^5 ;
[> Q2 := combine(Q1) ;
[> Q1 := sin(x+y) ;
[> Q2 := expand(Q1) ;
[> f(x) := piecewise( x <= -1, x+5, x < 2, x^2 + 1, x = 2, 1,
x > 2, 7 - x) ;
[> f(-3) ;
evaluates f(3)
[> f(2) ;
evaluates f(2)
[> plot( f(x), x = -6.0 .. 8.0, title = "A Piecewise Function" ) ;
[> limit( f(x), x = -1, left ) ;
evaluates the leftsided limit of f(x) at x = 1
[> limit( f(x), x = -1, right ) ;
evaluates the rightsided limit of f(x) at x = 1
[> limit( f(x), x = -1 ) ;
evaluates the limit of f(x) at x = 1 (it does not exist)
[> limit( f(x), x = 2 ) ;
evaluates the limit of f(x) at x = 2
[> 8*4 ;
[> 8/4 ;
[> 9^4 ;
[> evalf( 9/4 ) ;
[> factor( x^5 - 8*x^3 + 16*x ) ;
[> Result := simplify( (x^5 - 8*x^3 + 16*x) / x ) ;
[> factor( Result ) ;
[> evalf( Pi ) ;
the number π
[> evalf( pi ) ;
The Greek letter π is not a number.
[> evalf( cos(3) ) ;
[> evalf( log( exp(-4) ) ) ;
NOTE: The quantity
e4 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.0 .. 2.0 ) ;
[> subs( x = 2, f ) ;
[> exp(2);
[> evalf( exp(2) ) ;
[> g := sqrt(x) ;
[> plot( g, x = 0.0 .. 2.0 ) ;
[> combine( sin(2*x)*cos(4*x) + cos(2*x)*sin(4*x) ) ;
[> R := expand( sin(6*x) ) ;
[> combine(R);
[> expand( cos(x-y) ) ;
[> combine( sin(3*x)^4 ) ;
[> plot( { f, g }, x = 0.0 .. 2.0 ) ;
to plot two expressions on a common graph.
Note:
Curly braces { } denote a set (list).
[> plot( f - g , x = 0.0 .. 2.0 ) ;
plots the difference
f(x) g(x)
[> h := x^3 ;
[> plot( {f, g, h}, x = 0.0 .. 2.0 ) ;
to plot three expressions on a common graph
[> plot( 1/(x-3) , x = -2.0 .. 8.0, -10.0 .. 10.0 ) ;
[> limit( 1/(x-3), x = 3, left ) ;
evaluates the leftsided limit of 1/(x-3) at 3
[> limit( 1/(x-3), x = 3, right ) ;
evaluates the rightsided limit of 1/(x3) at 3
[> limit( 1/(x-3), x = -infinity ) ;
evaluates the limit of 1/(x3) as x approaches infinity
[> limit( 1/(x-3), x = infinity ) ;
evaluates the limit of 1/(x3) as x approaches infinity
[> Digits := 16 ;
sets the arithmetic precision to 16 in all subsequent calculations
[> evalf( Pi ) ;
gives the value of π to 16 digits
[> evalf( exp(1) ) ;
gives the value of the number e to 16 digits
[> evalf( 1/3 ) ;
gives the value of 1/3 to 16 digits
NOTE: The quantity
e4
is entered as
exp(-4), not as
e^(-4).
Likewise, for example,
ex2
is entered as
exp(-x^2),
not as
e^(-x^2),
and not as
exp((-x)^2).
Maple knows many other functions.
Written and maintained by
Last modified: 10/30/2023
Copyright © 19972023 Kevin G. TeBeest. All rights reserved.
or
Help >
Take a Tour of Maple
or
Help >
Quick Help
or
Help >
Quick Reference
+
addition
*
multiplication
__
2 times x+1 is
2*(x+1), not
2(x+1)
subtraction
/
division
^
exponentiation
* for
multiplication!
(Depending on the input mode you're using, Maple might display the
asterisk as a dot.)
In written mathematics, we understand that 2x means 2 times
x.
But in Maple, as in most programming languages, you should type 2*x.
(Danger: Maple sometimes allows multiplication without
using the asterisk operator, but it is safest to use the asterisk
as that is consistent with most programming languages.)
My students MUST use the asterisk for ALL
multiplications. Failure to do so will result in point loss.
The title is enclosed in double quotes.
f(x) =
x + 5 if x < 1
x2 + 1 if 1 < x < 2
1 if x = 2
7 x if x > 2
Note that the order is:
(
range 1, function 1,
range 2, function 2,
range 3, function 3, . . .
)
plots f(x) on interval [6,8] and gives
the plot a title
plots 1/(x3) on interval [2,8] with the vertical range restricted to
[10,10]
For example, to perform 16 digit arithmetic in a Maple session,
set Digits to 16 at the beginning of your Maple session:
Function
Command
cos x
cos(x)
sin x
sin(x)
tan x
tan(x)
cot x
cot(x)
arccos x
arccos(x)
arcsin x
arcsin(x)
arctan x
arctan(x)
Function
Command
arccot x
arccot(x)
ex
exp(x)
ln x
log(x)
cosh x
cosh(x)
sinh x
sinh(x)
tanh x
tanh(x)
arcsinh x
arcsinh(x)
Prof. Kevin G. TeBeest
Maple® is a registered trademark of Waterloo Maple Software.
Applied Mathematics
Kettering University