MAPLE HELPSHEETS: BASICS

MAPLE:   BASICS


This first tutorial explains:
It is best to work through the tutorials sequentially.
Do NOT copy and paste these examples into a Maple session. Doing so WILL inroduce hidden control characters into your Maple session, causing errors.


  1. To begin a maple session on the PCs in the Mathematics Computer Lab (rooms AB 3–333, 3–335, 3–337), click on the Maple icon on the desktop, or find Maple through Start > Programs.

  2. To end a maple session: click on the X in the upper right corner of the maple window.

  3. To run a Maple tutorial or get Maple help,

    Help > Maple Help
    or
    Help > Take a Tour of Maple
    or
    Help > Quick Help
    or
    Help > Quick Reference

  4. Note: In Worksheet mode, the Maple prompt is a [> symbol. To my students: I prefer that you use Worksheet mode.

  5. 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


    Basic Arithmetic Operations
    + addition * multiplication __ 2 times x+1 is 2*(x+1), not 2(x+1)
    subtraction / division
    ^ exponentiation

    IMPORTANT NOTES:

    1. Always use the asterisk * 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.
    2. Curly braces { } and square brackets [ ] do NOT represent parentheses in Maple.
    3. In Maple, % refers to the last result, and %% refers to the result from two calculations earlier. However, I STRONGLY discourage its use. It has brought grief to many a student and professional. (I do not allow my students to use this feature.)
    4. Always store expressions, functions, results, etc., under descriptive names and then use their names. NEVER re-type results or other items that you have already stored in a Maple session. Instead, simply use its descriptive name. (See examples below.)


    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).

  6. 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

    [> qwerty := sqrt(x) ;   variable qwerty is 3

    [> zaq := y + w ;   variable zaq is 33/2

  7. NOTE: Maple commands terminate with a semicolon or by hitting enter. To enter a LONG expression that spans multiple lines, you may use Shift–Enter.

  8. 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"

  9. 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

  10. To reset all quantities (clear your session's memory. . . much like exiting Maple and starting over)

    [> restart;

  11. To plot an expression, say f = x2 + cos x on interval [–2, Pi]

    [> 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 π.
    The title is enclosed in double quotes.

  12. 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 and not as a function.

  13. 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

  14. 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

    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 ) ;

  15. 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 named f(x)

    [> f(2) ;   evaluates f(2) and returns –16.

  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(π,2) and returns –2.

  17. To turn a multivariate expression into a multivariate function.

    [> 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.

  18. 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).

  19. To expand trig functions, use expand:

    [> Q1 := sin(x+y) ;

    [> Q2 := expand(Q1) ;


  20. 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, range 3, function 3, . . . )

    [> f(-3) ;   evaluates f(–3)

    [> f(2) ;   evaluates f(2)

    [> plot( f(x), x = -6.0 .. 8.0, 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 x = –1

    [> limit( f(x), x = -1, right ) ;   evaluates the right–sided 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

  21. Try these examples:

    [> 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 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.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 ) ;  
        plots 1/(x–3) on interval [–2,8] with the vertical 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


  22. Digits:   By default Maple performs 10 digit arithmetic. We can change the precision easily in a Maple session by settings Digits.
    For example, to perform 16 digit arithmetic in a Maple session, set Digits to 16 at the beginning of your Maple session:

    [> Digits := 16 ;   sets the arithmetic precision to 16 in all subsequent calculations

    [> evalf( Pi ) ;   gives the value of π 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


  23. Some of the Many Functions Known To Maple Include:

    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)

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), and not as exp((-x)^2).

Maple knows many other functions.


Go to the Maple Help Sheet Index

Written and maintained by

Prof. Kevin G. TeBeest
Applied Mathematics
Kettering University

Last modified: 10/30/2023

Maple® is a registered trademark of Waterloo Maple Software.

Copyright © 1997–2023 Kevin G. TeBeest. All rights reserved.