A very brief introduction to using Maple
Math 356
February 1, 2007
Important Concepts

If you need help use '?' (Ex. ? seq)
You end statements with ; (if you want output) or : (if you don't).
You may place multiple statements on one line.
To evaluate statements, push < Enter >.
To go to the next line, push < Shift >-< Enter>.
Maple is Case-SenSitive (AA not the same as aA).
You need to use * to multiply. (Ex. 2b is not 2*b)
Use ^ to put something to a power.
pi is Pi and sqrt(-1) is I.
To define a variable to store it in memory, use :=
      (Ex. Define z to be 3: z:=3; z+4;)
You may have a complicated expression that equals something nice. Use simplify() and/or expand().
To define a range of numbers, use .. (Ex. 1..10 means 1 through 10)
If you want to see what the floating point value of an irrational number is, use evalf()
Using lists

Lists are useful ways to store and reference data.
A list looks like [1,2,3]. Without brackets: Called a sequence.
Entries in a list may be anything, even lists.
      (Ex. A:=[[1,2],[2,3],[4,10]];)
In order to reference elements in a list, use square brackets, inside of which place the entry you want.
      (Ex. A:=[10,21,32]; To determine the second entry, ask for A[2];)
To peel off the brackets, use op().
To count the number of elements in a list, use nops(). [This is useful for looping.]
***Very important*** seq() is very powerful. Use it to create lists based on rules.
Method of use: seq(function of variable,variable defined where)
Examples: seq(i,i=1..10); gives a sequence of the numbers i from 1 through 10.
      [seq(i^2,i=3..10)]; (note the brackets) gives a LIST of the squares of integers from 3 through 10.
      [seq(i^2,i=[4,1,9])]; evaluates i^2 only at 4, 1, and then 9, so the result is [16,1,81].

Use lists to keep track of recursive information using for loops (described in programming below).
Algebra and Calculus

Use exp(x) to represent the function ex
diff(f(x),x); takes the derivative of f with respect to x.
int(f(x),x); takes the integral of f with respect to x.
solve(a*x^2+b*x+c=0,x); solves for the roots of a*x^2+b*x+c=0 symbolically. (You may need to use evalf)
coeff tells you the coefficients (Ex. coeff((1+x)^10,x^3) gives 120 (= 10 choose 3)
      since the coefficient of x^3 in (1+x)^10 is 120 (by the binomial theorem.))
Plotting

Syntax to plot a 2D graph between x=a and x=b: plot(f(x),x=a..b);
Syntax to plot a 2D graph between x=a and x=b and restrict range: plot(f(x),x=a..b,c..d);
Plot multiple graphs on the same graph: plot({f(x),g(x)},x=a..b);
You can also plot points. If your points are (x1,y1), (x2,y2), and (x3,y3), write:
plot([[x1,y1],[x2,y2],[x3,y3]],x=a..b,style=POINT); (Setting the style tells Maple not to connect the dots.)
Analagously to multiple graphs, you can plot multiple sequences of points.
Linear Algebra
Programming

You'll have to think about how you can get a computer to do what you do naturally.
Computers are especially good at doing brute force computations.
Example Start with 1. Add 5 multiply by 10 subtract 40 divide by 5. Do this 100 times.
You'll need to use a for loop.
Syntax: for < variable > from < start > to < finish > do < instructions > end do;
Think of this as giving rules to the computer. Since we need to run the loop 100 times, we'll define a variable that serves as a counting variable (i) and start i counting at 1 to 100. The computer will know to stop after 100 loops because i will be 100 at that time. We'll also need a variable to keep track of what's happening. Call it Total. We'll have to declare that it starts with 1, then in each iteration of the loop, we need to tell it to do the instructions we want, and write over itself. So what we have to write is:
Total := 1;
for i from 1 to 100
do
Total := ((Total+5)*10-40)/5;
end do;

Notice that keeping everything on separate lines helps you be able to read what's going on.

If you want to define elements of a list recursively, a for loop is also useful.
A[0]:=1;
for i from 1 to 10
do
A[i] := 2*A[i-1];
end do;
A[10]; <-- Ask Maple to tell you what A[10] is.

Probability

Miscellaneous


Back to the Maple Page.
Back to the Math 356 Home Page.