Section 3. Functions as Transformations

Functions play a key role in many applications of mathematics. The arrow notation is used to make functions and the unapply procedure can turn any expression into a function. The Matrix procedure can be used to make tables of data.

0. Pull down the Help menu, choose New Users/Full Tour, then click on the third item: Algebraic Calculations and work through the examples in that worksheet; pay special attention to function notation and solving equations.

Open a new Maple worksheet and do the following

1. Use arrow notation to define the function f(x)=cos(x) - x tan(x). Then use the entry

g := D(f);

to obtain g as the derivative function.

2. Continuing 1. Plot f over the interval x = -1 to x = 1 using plot( f(x), x=-1..1).

Then find the area of the region below the graph of f and above the x axis.

Hint. This will require the values b where f(b) = 0. Find the positive value using

b := fsolve(f(x)=0,x,0..1);

Check that  f(-b) = 0  also. Once b is found, the area is the integral of f(x) from -b to b.

3. Continuing 2. Plot the graph of f from -1 to 1 and the tangent line segment to the graph at the point x = 0.5, y = f(0.5) over the interval x = 0 to x = 1.

Hint. You already have the derivative function g. Use it to define the tangent line function using

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

Then execute

plot( [f(x), [(t,T(t),t=0..1] ], x=-1..1);

You will see that Maple's default colors for two curves are red and green. The second curve is easier to see with the optional equation color=[red,blue]. Try it, you will like it.

4. Continuing 3. Find the length of the curve plotted in Exercise 2.

Hint. Do the integration numerically using evalf( Int( .... ) ).

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].

6. Solving a differential equation.

The dsolve procedure solves differential equations. The syntax is simply

dsolve( deqn )

where deqn is a differential equation or the name of one. Do a restart and define a simple first order differential equation as follows

restart;  deqn := diff(y(x),x) + x*y(x) = x;

Get the general solution with the entry

dsolve( deqn );

Now obtain the solution satisfying y(0) = 0 using

soln := dsolve( {deqn, y(0)=0} );

7. Plot the last solution using

plot( rhs(soln), x=-2..2);

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)', % ] ] );