Introduction to Maple

advertisement
Introduction to Maple
All commands should end with a semicolon or a colon.
; asks Maple to perform and lets you see the result
: asks Maple to perform but does not let you see the result
Important symbols:
:=
assigns a name or value
%
accesses the last item calculated
+ , - addition & subtraction
*,/
multiplication ( must have! --- it's 3*x and not 3x ) & division
^
exponentiation ( x cubed is written as x^3)
evalf evaluates a number to floating point (decimal) form
Examples:
> a:= 5 + 6;
Maple computed the sum, stored it in variable a, and showed the result.
> b:= 3 * 4:
Maple computed the product and stored it in variable b, but did not show the result
since the command ended with a colon.
> c:= a + b;
Maple remembers that a is 11 and b is 12 to compute c .
Suppose we want to divide c by 7.
> c/7;
Notice that Maple gives an exact value for this quotient.
Suppose we want a decimal approximation for the quotient. Use "evalf".
> evalf(%);
I asked for a decimal approximation of the last item calculated. Notice it gave me
10 digits (default). If I only wanted 5 digits I could change the command slightly.
> evalf[5](%);
Another way to show Maple you want your answer in decimal form is to include a decimal
point in the computation.
> c/7.;
Notice that when I replaced 7 with 7. Maple changed from giving an exact answer to giving
a decimal approximation.
> Pi;
Maple constant --- Pi for 
> evalf(Pi);
Suppose you want to see 30 digits for  . Here are two ways to do it.
> evalf(Pi,30);
> evalf[30](Pi);
The following command will square 5 and also take the square root of 5.
> 5^2; sqrt(5);
Consider the polynomial x 2  4 x  3 .
Suppose you want to factor it, and find its zeros.
> poly:= x^2 - 4*x + 3;
> factor( poly );
> solve( poly = 0 , x );
This last command asks Maple to set the polynomial to zero, and solve the equation for x.
Maple will also multiply polynomials as follows.
> ( x + 2 ) * ( 2*x - 1 ) * ( x - 3 ) ;
> expand( % );
Double-check to see if this is correct.
> factor( % );
FUNCTIONS --- f : = x -> expression
defines f as a function of x
> f:=x-> x^2 + 1;
The function f has been defined. You may now evaluate it at various points.
> f(0) ; f(3);
Suppose you want to define the function g (t ) 
> g:=t-> sqrt( t - 5 );
What about solving the equation
> solve( g(t) = 2 , t );
t 5  2 ?
t 5 .
Download