Part II. Calculations and Calculus with Maple

Section 1. Getting Started: Maple as a Calculator

Section 2. Symbolics: Equations and Assignments

6.* Plot the expression

x^3-x^2+Float(5, -2)*x+cos(x)-Float(7, -1)

with the entry

y := x^3 - x^2 + 0.05*x + cos(x) - 0.7;   plot( y, x=-2..2, -2..2);

Enter fsolve(y=0,x) to see which zero fsolve finds.

Using the graph as a guide, obtain an approximation to the largest positive zero using fsolve(y=0,{x},a..b).

> y := x^3 - x^2 + 0.05*x + cos(x) - 0.7;   plot( y, x=-2..2, -2..2);

y := x^3-x^2+0.5e-1*x+cos(x)-.7

[Plot]

> fsolve(y=0,x);

.6180709010

> fsolve(y=0,x,1..2);

1.189778784

9. Graph the function

y = cos(x^2)-sin(2*x)

over the interval from x = 0 to x = 2. Define yp as its derivative and find the zero of yp near x = 1.5. Name it xmin. Then find the minimum value of y over this interval using eval(y,x=xmin). Name it ymin.

Use the following entry to plot the graph and the low point.

plot( [y, [ [xmin,ymin] ]  ], x=0..2, style=[line,point]);

10.* Find the area of the region between the graph in Exercise 9 and the x-axis.

Hint: Numerically integrate the absolute value of y from x = 0 to x = 2 via the entry

evalf( Int( abs(y), x=0..2) );

> y := cos(x^2) - sin(2*x);
plot(y, x=0..2);

y := cos(x^2)-sin(2*x)

[Plot]

> evalf(Int(abs(y),x=0..2));

.9147700913

Section 3. Functions as Transformations

5.* An animation.

The tangent line plot in Exercise 3 can easily be animated as follows.

First define the function T(a,x) whose value at (a,x) is the formula for the tangent line to the graph of f at (a,f(a)).

T := (a,x) -> f(a) + g(a)*(x - a);

Then use

plots[animate](plot,[ [f(x), [t,T(a,t),t=a-0.5..a+0.5] ],x=-1..1,-1..2,color=[red,blue]],a = -1..1);

Once the plot appears, click on it with the mouse and the context bar becomes a row of video controls; enjoy.

Read the Help page for plots[animate].

> f := x -> cos(x) - x*tan(x): g := D(f):
T := (a,x) -> f(a) + g(a)*(x - a);

T := proc (a, x) options operator, arrow; f(a)+g(a)*(x-a) end proc

> plots[animate](plot,[ [f(x), [t,T(a,t),t=a-0.5..a+0.5] ], x=-1..1,
                     -1..2, color=[red,blue] ], a = -1..1);

[Plot]

8.* Using unapply and Matrix.

Convert the second solution in Exercise 6 into a function f using

f := unapply(rhs(soln),x);

Evaluate the solution at x = 0, 0.2, 0.4, ... , 1.0 to 4 digits as follows

evalf[4](  f(0.2*k) $ k=0..5 );

Make a table of function values with the following Matrix entry

Matrix( [ [x, 0.2*k $ k=0..5] , [ 'f(x)', % ] ] );

> restart: deqn := diff(y(x),x) + x*y(x) = x:
soln := dsolve( {deqn,y(0)=0} ):

f := unapply(rhs(soln),x);

f := proc (x) options operator, arrow; 1-exp(-1/2*x^2) end proc

> evalf[4](f(0.2*k) $ k=0..5);

0., 0.198e-1, 0.769e-1, .1647, .2739, .3935

> Matrix( [ [x, 0.2*k $ k=0..5] , [ 'f(x)', % ] ] );

Matrix([[x, 0., .2, .4, .6, .8, 1.0], [f(x), 0., 0.198e-1, 0.769e-1, .1647, .2739, .3935]])