A quick introduction to Maple...


Getting started...

Type maple to begin.
oscar.Princeton.EDU% maple
    |\^/|     Maple V Release 5 (WMI Campus Wide License)
._|\|   |/|_. Copyright (c) 1981-1997 by Waterloo Maple Inc. All rights
 \  MAPLE  /  reserved. Maple and Maple V are registered trademarks of
 <____ ____>  Waterloo Maple Inc.
      |       Type ? for help.

># This line is ignored by Maple
># expressions must end with a semicolon 

> #echo
> 123;
                                                123

# using + - * / 
> 1 + 2 * 3  - 6 / 2;

# using ^
> 2 ^ 10;    
                                               1024

                                                 4
# assignment 
> a := 1 + 2;
                                              a := 3
# fetch the value
> a;
                                                 3

# ditto : retrieve the last result
> %;
                                                 3
# using it in another expression
> % + 5;
                                                 8

# use 'a' in another expression
> a + 7;

# --------
                                                10
# assigning a function to a variable
> f := x^2 -1;
                                                  2
                                            f := x  - 1
# assigning a function to a variable
> g:= x-1;
                                            g := x - 1

# performing computations
> f/g;
                                               2
                                              x  - 1
                                              ------
                                              x - 1
# save the result for the future
> h := %;
                                                  2
                                                 x  - 1
                                            h := ------
                                                 x - 1

# simplify an expression
> simplify(h);  
                                               x + 1

# expand an expression
> expand(h);
                                             2
                                            x        1
                                           ----- - -----
                                           x - 1   x - 1

# more examples 

# using both
> simplify(expand(h));
                                               x + 1


# assigning an expression to a variable
> d := (x+1)*(x+2)*(x-3);
                                   d := (x + 1) (x + 2) (x - 3)

# expand an expression 
> expand(d);
                                            3
                                           x  - 7 x - 6
# using factor()
> factor(%);
                                      (x + 1) (x + 2) (x - 3)

# -----------------------

# retrieve the value
> d;
                                      (x + 1) (x + 2) (x - 3)

# retrieve the value
> x;
                                                 x
# assigning a new value
> x := 2;
                                              x := 2
# recompute d
> d;
                                                -12

# --------------------------


# using UNIX commands
> 
> !echo 123
123
!
>

# another example
> !date
Wed Oct  7 14:03:06 EDT 1998
!
> 


# -------------------------
 
> 3/4;
                                                3/4
# evaluate using FP
> evalf(%);
                                            .7500000000

# set the number of significant digits
> Digits := 5;
                                            Digits := 5

# only 5 digits are reported
> evalf(3/4);
                                              .75000
#-------------------------

# assigning a value
> x:=2;
                                              x := 2
# 
> x;
                                                 2
# "clear" x
> x := 'x';
                                              x := x

> f := x;
                                              f := x
# computing an indefinite integral
> int(f,x);
                                                   2
                                              1/2 x
# computing a finite integral
> int(f, x=-1..2);
                                                3/2

# -----------------------------

# can't get an exact answer 


> 
> f := exp(-x*x)*ln(x);
                                                   2
                                        f := exp(-x ) ln(x)

> int (f,x);
                                         /
                                        |        2
                                        |  exp(-x ) ln(x) dx
                                        |
                                       /

> int (f,x=a..b);
                                         b
                                        /
                                       |         2
                                       |   exp(-x ) ln(x) dx
                                       |
                                      /
                                        a

> int (f,x=1..exp(2));
                                       exp(2)
                                      /
                                     |              2
                                     |        exp(-x ) ln(x) dx
                                     |
                                    /
                                      1

> evalf(%);

                                           .03588274959

# -----

# another example
> int (sin(x), x);
                                              -cos(x)

# using Pi        
> int (sin(x), x=0..Pi);
                                                 2



Yefim Shuf | CS Department | Princeton University
Last modified: Wed Oct 7 13:23:37 EDT 1998