Session 01
Some Arithmetic: Factoring and Simplifying
The syntax for multiply is *, add is +, divide is / , minus is - and power is ^
> ((2*a^2-4*a-6)/(9*a^2-16))*((6*a-8)/(a+1));
> simplify(%);
Maple can do lots of factoring as well. Note the use of % to indicate the output of the last calculation.
> a*c+b*d-a*d-b*c;
> factor(%);
> (a+b)^7;
> expand(%);
> factor(%);
Solving Equations and Inequalities:
Maple can solve many equations, systems of equations, and inequalities explicitly
> eq1:=4*x^2+5*x-21=0;
> solve(eq1,x);solve(eq1); # note that if the variable is obvious you don't have to specify it
> eq2:=sqrt(8*x-7)-x=0;
> solve(eq2,x);
Here are some systems of equations.
> eq3:={2*x-y=5,x-3*y=5};
> solve(eq3,{x,y});
> eq5:={x^2-5*x-y+4=0,x-4*y=1};
> solve(eq5,{x,y});solve(eq5); # again note that if the arguments are obvious they don't need to be specified
For polynomials solve tries to find all theroots.
> eq6:=2*x^3-3*x^2-11*x+6;
> r:=solve(eq6,x); # note that we have assigned the roots to a name r
> r[1]; r[2]; r[3];
Check to see if these are really zeros of the polynomial. Use the command subs for substitution.
> subs(x=r[1],eq6); subs(x=r[2],eq6); subs(x=r[3],eq6);
> plot(eq6,x=-4..4);
Here is another example.
> eq7:=x^4-16*x^3+86*x^2-176*x+105;
> plot(eq7,x=-3..3);
> solve(eq7,x);
> plot(eq7,x=0..8);
> eq:=x^3+x+1;
> r:=solve(eq);
In this case it is better to find answers that are floating point approximations to the exact answers. To do this use fsolve.
> fsolve(eq);
Notice that it only gave one answer. In general, fsolve only find one answer unless you supply extra information.
> r:=fsolve(eq,x,complex); # use complex parameter to search for complex solutions
> subs(x=r[1],eq);subs(x=r[2],eq);subs(x=r[3],eq);
> eq:=x^4-x^2-1;
> solve(eq,x);
> evalf(%);
Note the result when fsolve is used.
> fsolve(eq,x);
Here are some inequalities.
> ineq1:=6*x^2-x>35;
> solve(ineq1,x);
Examples from Trigonometry:
> evalf(Pi,50);
> t1:=sin(2*theta)=2*sin(theta)*cos(theta);
> testeq(t1);
> t2:=sin(2*theta)=2*sin(theta);
> testeq(%);
> t3:=tan(x)*sin(x)=sec(x)-cos(x);
> testeq(t3);
> t4:= cos(x)^2-sin(x)^2=(1-tan(x)^2)/(1+tan(x)^2);
> testeq(t4);
> t5:=sin(3*x)=3*sin(x)-4*sin(x)^3;
> testeq(t5);
> t6:=sin(a+b);
> expand(t6);
> t7:=tan(a+b);
> expand(t7);
> t8:=sin(x)^2-2*sin(x)-3=0;
> solve(t8,x);
More on Plotting
> f:=sin(2*x)*x;
> plot(f,x=-3..3,y=-2..1);
Here's how one plots a set of parametric equations.
> x:= 1+t^3; y:=1-t^2;
> plot([x,y,t=-2..2]);
> f:=1-2*cos(theta);
> plot(f,theta=-Pi..Pi);
Note the difference if we plot in polar coordinates.
> plot(f,theta=-Pi..Pi,coords=polar);
3D Plotting
> x:='x'; y:='y'; # clear the content of x and y
> f:=(x^2+y^2)*exp(-(x^2+y^2));
> plot3d(f,x=-2..2,y=-2..2);

Exercises
Use the Maple commands factor, solve, fsolve, evalf, subs, plot to answer the following questions:
a) Plot the function to help determine where the zeros are located.
b) Try to factor the polynomial.
c) Use solve or fsolve to find all the roots. You may want to use evalf to see what the numerical value is in some cases.
d) Plug the answers into the function to verify that you have found the zeros.
1) x^4-x^3-5*x^2+12;
2) 2*x^3-13*x^2-4*x+60;
3) 8*x^2+2*x^3-x^4;
4) 2*x^4-5*x^3+10*x-12;
5) x^5-x^4-15*x^3+x^2+38*x+24;
6) x^5-x^4-15*x^3+x^2+38*x+10;
Next >>
|