What can Maple do for you?
Maple is a computer program that, in response to your instructions, performs arithmetic, algebra, and calculus, and generates graphics.
Giving instructions to Maple
An instruction is one or more lines containing expression(s) terminated by ";" or ":".
It is "sent" to Maple by hitting the Enter key.
examples:
| > | 2+2; |
| > | 3+ 3 ; |
| > | plot(sin(x), x=0..10); |
Instructions cause computations to be done. Instructions usually generate output, as in the examples above. Expressions ending with ":" are evaluated but the output is omitted:
| > | x0 := 2: y0 := 5; m := 2: y = y0 + m*(x-x0); |
To get more space to type without executing..
When you need more space for what you are typing,
on a PC, type the two keys "Shift"-"Enter" at the same time.
This gives you a new blank line, like this:
When you press the "Enter" key by itself (without the "Shift") Maple starts executing.
On a Mac, the "Return" key gives you a new blank line.
Arithmetic
Maple uses the symbols + for add, - for subtract, * for multiply, / for divide.
^ denotes exponentiation: i.e., 5^2 means 5 squared. Parentheses () can be used to group portions of expressions.
| > | 2 + (4 - 3)*2; |
Exact and approximate arithmetic
Maple uses exact arithmetic if it can. You cause approximate arithmetic to be done
(i) by giving floating point numbers to start with, or
(ii) by using "evalf" (evaluate as floating point) to convert to approximate arithmetic.
| > | 2.0/6.0; # approximate |
| > | 2/6; evalf(2/6); # use "evalf" to convert exact to approximate |
| > | Pi; evalf(Pi); sin(Pi/4); # Pi is exact, evalf(Pi) approximate |
Assignment and unassignment
You assign values to names with the " := " operator:
| > | a:=x+1; |
| > | a^2; |
To make "a" just a variable name again, with no assigned value, do this:
| > | a:='a'; |
| > | a^2; |
When early parts of a calculation assign values to names that you want to use again as names later on, use unassigment.
Or, you can just use different names later on.
Algebra
First, lets make sure that the name x is not assigned a value..
| > | x := 'x'; |
"expand" takes expressions and multiplies them through. It also expands powers.
| > | expand( (x+2)*(x-3) ); expand((x+2)^3); |
Parts of expressions: "coeff" finds the coefficient of a particular term in a polynomial.
"numer" finds the numerator of an expression,
"denom" finds the denominator.
| > | coeff(x^3 + 6*x^2 + 12*x + 8,x^2); |
| > | expr := (x^2 + 5)/(x^3 - 1); numer(expr); denom(expr); |
Solving an equation with "solve"
First, let's make sure the name x is not assigned a value:
| > | x:='x'; |
Give "solve" the equation to be solved, and the variable you want to solve for:
| > | solve( 2*x + 10 = 0, x); |
Depending on the equation, there may be more than one solution..
| > | solve( x^2 + 5*x - 6 = 0 ); |
It is useful to give the collection of solutions a name, and then pick off the individual solutions:
| > | xsolns := solve( x^2 + 5*x - 6 = 0 ,x); |
| > | x1 := xsolns[1]; x2 := xsolns[2]; |
| > | expand((x-x1)*(x-x2)); # should give back the quadratic |
More on solving algebraic equations -- sets of them
First, let's make sure that names x and y are not assigned values..
| > | x:='x': y:='y': x,y; |
Give "solve" the set of equations you want to solve, and the set of variables you want to solve for.
| > | solve( { x + y = 3, x + 2*y = 9} , {x,y} ); |
The curly brackets { } indicate sets, and set elements are separated by commas.
When there are several solutions, it is useful to given the collection of solutions a name,
and then pick off the individual solutions:
| > | solns := solve( { x + y = 3, x^2 + y^2 = 9} , {x,y} ); |
| > | solns[2]; |
By specifying solns[2], we have picked off the second solution. This solution is the set
of equations y = 3 and x = 0.
"subs" substitutes values given by such sets of equations, into an expression.
To get the value of y given by the solution pair solns[2],
| > | subs(solns[2], y); |
This works since the result of substituting the values y = 3 and x = 0 into the expression y ,
is the value 3.
(We could use subs(solns[2],x+y=3) to check that the pair solns[2] satisfies the equation x+y=3.)
To make x1, y1 the coordinates of the solution pair solns[1],
| > | x1 := subs(solns[1],x); y1 := subs(solns[1],y); |
and to make x2, y2 the coordinates of the solution pair solns[2],
| > | x2 := subs(solns[2],x); y2 := subs(solns[2],y); |
At this point, the names x1, y1, x2, and y2 are assigned values, but x and y are unassigned.
It is best to leave common variable names like x, y, z, t, s etc. unassigned,
so that it is not necessary to unassign them before using "solve" or other Maple procedures.
Calculus
You can differentiate expressions:
| > | diff( x^3 + x^2 + x + 1 + sin(x), x ); |
or integrate them:
| > | int( x^3 + x^2 + x + 1 + sin(x), x ); # an antiderivative |
| > | int( x^3 + x^2 + x + 1 + sin(x), x=0..Pi);# a definite integral |
Procedures
"proc" and "end" mark the beginning and end of the definition of a proc (procedure).
Statements are separated by semicolons.
Here's an example that sets up a proc named A to evaluate the area of a circle of
radius r.
| > | A := proc(r); Pi*r^2; end; |
| > | A(10); A(R); A(r); |
| > |
| > | B(r) := r^2; B(10); |
| > | subs(r=10,B(r)); |
| > |
Getting help from Maple
The ? ?? and ??? commands give help. If you know the topic, use ?topic, for example ?int .
Note that by using cut and paste (from the Edit menu), you can take the examples that
help provides, paste them into your current workspace, and run them.
Try ?int
| > | ?int |
| > |
| > |