0.0 Introduction to Maple6

The objective of this lab is for you to familiarize and learn some of the Maple commands

Try the following Maple commands to explore what they do.

e.g.

> evalf((4/9)^(3/2)); Evaluatest he expression using floating-point arithmetic (approximation).

> eval((4/9)^(3/2)); Evaluates the expression exactly.

> (4./9)^(3/2); evaluates the expression using floating-point arithmetic because of the decimal.

1) Arithmetic

> 2.1*3.2;

> 3**2;

> 3^2;

2) Constants and Functions

> evalf (exp(1));

> evalf(Pi,10);

> evalf(Pi,100);

> sqrt(9);

> ln(-1);

> tan(Pi/4);

> arcsin(1);

> sin(25);

> evalf(%);

> sin(25.);

3) Defining Variables and Functions

> a=2; does not assign the value of 2 to a

> a;

> a:=2; assings the value of 2 to a

> a; recalls the value of a

> sqrt(a);

> evalf(%);

> f:=x^2; stores the expression x^2 in f

> f; recalls the expression in f

> subs(x=3,f);

> f:=unapply(f,x); converts an expression into a function.

> f(2);

> g:=(x)->x^3; defines a function directly

> g(2);

4) Algebra

> denom((x-1)/(x^2+1));

> numer((x-1)/(x^2+1));

> simplify((x^2-1)/(x+1));

> factor(x^3+1);

> expand((x+1)*(x-1));

> subs(x=2,y=3,2*x+5*y);

> convert(x/(x^2-1),parfrac,x);

Types of brackets used in Maple

( ) Used in computational procedures

> r:=solve(x^2-3*x-4=0);

[ ] Associated with coordinates or order (lists)

> r[1];

> r[2];

> expand((x-r[1])*(x-r[2])=0);

> restart;

{ } Used to group things together

> sol:=solve({x+y=0,2*x-y=2},{x,y}); solving a system

> assign(sol); assigns values to x and y

> x:=x;

> y:=y;

5) Plots

> plot(x^2-2,x=-3..3); x is the domain

> plot({x^2-2,x+4},x=-3..3); plotting a system

> plot(1/x,x=-2..2); the graph is not clear

> plot(1/x,x=-2..2,y=-5..5); giving the range, you get a better window

> pw:= piecewise(-1<x and x<=1,abs(x),x<=-1,x,x>1,-x^2); piecewise function

> plot(pw,x=-2..2,y=-2..2); This is not a function.Maple connects the discontinuities

> plot(pw,x=-2..2,y=-2..2,discont=true); this is the piecewise function

> with(plots); Maple package that contains the implicitplot command

> implicitplot(x^2-y^2=1,x=-2..2,y=-2..2); unit hyperbola

6) Solving Equations

> restart;

> fsolve(x^2-3*x-4=0); finds the solution in floating point arithmetic

> y1:=2*x+3*y=1;y2:=-3*x+2*y=6; two expressions

> sol:=solve ({y1,y2},{x,y}); solution

> f:=x^2-2;

> plot(f,x=-2..2,y=-5..5);

> fsolve(f=0,x); finds approximations for the zeros of f

> fsolve(f=0,x=1..2); finds an approximation for the zero of f between 1 and 2

> g:=x/2+1;

> plot({f,g},x=-3..3,y=-3..3);

> solve({y=x^2-2,y=x/2}); does not evaluate the roots

> allvalues(%); evaluates the roots

6) Calculus

Limits

> restart; reset Maple to default values

> Limit(sin(x)/x,x=0); capital L does not evaluate the limit

> value(%); evaluates the limit

> limit(sin(x)/x,x=0); evaluates the limit directly

> f:=x->sqrt(x); define a function

> limit((f(x+h)-f(x))/h,h=0);

Differentiation

> Diff(cos(2*x),x); capital D does not find the derivative (all derivative in Maple are partial)

> value(%); finds the derivative

> diff(cos(2*x),x); finds the derivative directly

> diff(sin(x^2),x$2);

> f:=x^2*sin(x); an expression

> diff(f,x); using a defined expression

> restart;

> f:=x->x^2*sin(x); this is now a function

> diff(f,x); will not find the derivative of a function

> D(f); finds the derivative

> D(f)(2); evaluates the derivative of the function

Integration

> Int(tan(x),x); capital I will not integrate

> value(%); finds the integral

> int(tan(x),x); integrates directly

> int(1/x,x=1..2); a definite integral

> f:=ln(x); an expression

> int(f,x); integrates the expression

> int(sqrt(x^5+1),x=0..1); returns the integral because can not find a closed form (analytic solution)

> evalf(%); finds a numeric approximation

Taylor approximation

> sum(k^2,k=1..5);

> sum(1/2^k,k=1..infinity); geometric r = 1/2

> f:=sin(x);

> t:=taylor(f,x=-1,3); where O((x+1)^3) is the error in the second order Taylor polynomial

> t2:= convert( t,polynom); second order Taylor polynomial

> plot({f,t2},x=-3..1);

The best way to learn the Maple commands is through the examples in the help. From the Help tool bar go to Using Help then to Matematics. From there, you can choose any discipline. At the end of the different commands there are always examples using the command that can be cut and paste into a worksheet. If you know the Maple command, try the following :

> ?plot

> ??plot

> ???plot