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 ;
[> w := x+3 ;
[> y := x/2 ;
[> z := y^3 ;
[> qaz := 5*w ;
[> qwerty := sqrt(x) ;
[> zaq := y + w ;
[> x := 9 ;
[> x := 4 ;
[> x := 'x' ;
[> x := 9 ;
[> x;
[> 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) ;
[> r := subs( x = 0, f ) ;
[> r;
[> subs( x = Pi, f ) ;
[> evalf( subs( x = Pi, f ) ) ;
[> R := evalf( subs( x = Pi, f ) ) ;
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 ;
[> r := subs( x = 1, y = 3, f ) ;
Functions
[> f := x -> x^3 - 3*x^2 - 9*x + 6 ;
In more recent versions of Maple, you may enter
[> f(x) := x^3 - 3*x^2 - 9*x + 6 ;
[> f(1);
[> f(z);
[> f(x+h);
[> plot( f(x), x = -4.0 .. 5.0 ) ;
[> plot( f, -4.0 .. 5.0 ) ;
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 ) ;
[> 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 ;
To turn it into a function, use unapply:
[> f := unapply( y, x ) ;
[> f(2) ;
[> f(x,y) := y * cos(x) ;
[> r1 := f(0,2) ;
[> f(Pi,2) ;
[> y := 'y' ;
Example: Suppose we had defined
z = y cos x as an expression:
[> z := y * cos(x) ;
To turn it into a function, use unapply:
[> f := unapply( z, (x,y) ) ;
[> f(0,2);
[> f(Pi,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) ;
[> f(2) ;
[> plot( f(x), x = -6.0 .. 8.0, title = "A Piecewise Function" ) ;
[> limit( f(x), x = -1, left ) ;
[> limit( f(x), x = -1, right ) ;
[> limit( f(x), x = -1 ) ;
[> limit( f(x), 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 ) ;
[> evalf( pi ) ;
[> 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 ) ;
Note:
Curly braces { } denote a set (list).
[> plot( f - g , x = 0.0 .. 2.0 ) ;
[> h := x^3 ;
[> plot( {f, g, h}, x = 0.0 .. 2.0 ) ;
[> plot( 1/(x-3) , x = -2.0 .. 8.0, -10.0 .. 10.0 ) ;
[> limit( 1/(x-3), x = 3, left ) ;
[> limit( 1/(x-3), x = 3, right ) ;
[> limit( 1/(x-3), x = -infinity ) ;
[> limit( 1/(x-3), x = infinity ) ;
[> Digits := 16 ;
[> evalf( Pi ) ;
[> evalf( exp(1) ) ;
[> evalf( 1/3 ) ;
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.
variable x is 9
variable w is 12
variable y is 9/2 (not 4.5)
variable z is 729/8
variable qaz is 60
variable qwerty is 3
variable zaq is 33/2
variable x is 9
variable x is now 4
variable x is reset or "unassigned"
variable x is 9
will show that x is 9
The title is enclosed in double quotes.
defines f as an expression
substitutes x = 0 into f and stores cos(0) in r
shows that r is 1
returns: 8.8696044
stores 8.8696044 in R
defines f as an expression
substitutes x = 1 and y = 3 into f and stores result in
r
f is defined as a function
f is defined as a function
evaluates f at x = 1 and returns 5
returns z3 3 z2 9 z + 6
returns (x+h)3 3 (x+h)2
9 x 9 h + 6
plots f(x) from x = 4 to 5
plots f from x = 4 to 5
called the "difference quotient" of f
y is defined as an expression
turns expression y into a function named f(x)
evaluates f(2) and returns 16.
f is defined as a function of x and y
evaluates f(0,2) and stores result 2 in r1.
evaluates f(π,2) and returns 2.
restores y to an unassigned quantity
z is defined as an expression involving x and y
turns expression z into a function f(x,y)
evaluates f(0,2) and returns 2.
evaluates f(π,2) and returns 2.
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, . . .
)
evaluates f(3)
evaluates f(2)
plots f(x) on interval [6,8] and gives
the plot a title
evaluates the leftsided limit of f(x) at x = 1
evaluates the rightsided limit of f(x) at x = 1
evaluates the limit of f(x) at x = 1 (it does not exist)
evaluates the limit of f(x) at x = 2
the number π
The Greek letter π is not a number.
to plot two expressions on a common graph.
plots the difference
f(x) g(x)
to plot three expressions on a common graph
plots 1/(x3) on interval [2,8] with the vertical range restricted to
[10,10]
evaluates the leftsided limit of 1/(x-3) at 3
evaluates the rightsided limit of 1/(x3) at 3
evaluates the limit of 1/(x3) as x approaches infinity
evaluates the limit of 1/(x3) as x approaches infinity
For example, to perform 16 digit arithmetic in a Maple session,
set Digits to 16 at the beginning of your Maple session:
sets the arithmetic precision to 16 in all subsequent calculations
gives the value of π to 16 digits
gives the value of the number e to 16 digits
gives the value of 1/3 to 16 digits
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)
Maple® is a registered trademark of Waterloo Maple Software.
Prof. Kevin G. TeBeest
Applied Mathematics
Kettering University