DISP Mathematics (Scie 1500R)

MAPLE Lab. Tutorial 4 Limits and Maple Programming
Monday February 7.

** 1** LIMITS.

MAPLE can evaluate most of the limits that one finds in Calculus books.
To evaluate

use the command

There is a useful way of getting MAPLE to write out such things nicely (we
shall see the same thing with integrals next week). This is to use the
command ` > Limit(f(x), x=a);` This returns a nicely formatted expression
for the limit. Therefore, if you want the whole thing to look good, try
` > Limit(f(x), x=a) = limit(f(x), x=a);`.

Try the following commands:

` > limit(x3,x=2);
> Limit(x3,x=2);
> value(%);
> evalf(%%);
> Limit(x3,x=2) = limit(x3,x=2);
> limit((x2-9)/(x-3), x=3);
> Limit((x2-9)/(x-3), x=3) = limit((x2-9)/(x-3), x=3);`

If you want to do one-sided limits then insert ` right` or ` left` as
an option (commas separate things):

` > Limit( abs(x-2)/(x-2) , x=2, right)= limit( abs(x-2)/(x-2) , x=2, right);`

One can use ` infinity` as both a ``value'' for the variable, and MAPLE
may give it as a ``value'' for a limit:

` > limit(sin(x)/x, x=infinity);
> limit(2*x/(x-1), x=1, right);
`

** 2** PROGRAMMING

Sometimes one wishes to do several steps in a mathematical computation. If it
is a ``one-off'' computation then one can just go through step by step with MAPLE.
However, if it is a computation you wish to do several times, then you may
wish to automate it with a little program. In MAPLE this is done with
a * procedure*.

A procedure begins with ` proc( parameters )` and ends with ` end;`.
In a formal sense, a procedure is a * function* and the parameters are
the variables that you will feed into this function once it is set up.
We saw in an earlier tutorial how functions that are defined in several
pieces need a procedure to define them.

If the procedure uses other variables these should be listed on line 2
as ``* locals*'': ` locals list of variables`. Lines of the procedure end
with either a : or a ; (in the one's below we used :) but so that MAPLE knows
there is more to follow use SHIFT + ENTER, until you come to ` end;`

Examples may make this clearer.
** 2** EXERCISES

** NAME STUDENT # **

Before you start these exercises type ` restart;`.

1. Use MAPLE to evaluate the following limits (if they exist):

(i)

(ii)

(Hint: Put brackets round .)

(iii)

(iv)

(v)

(iv)

2. Here is a procedure to calculate the derivative of a function at a point , using only the definition of derivative.

Note: No (semi)colon after first line. After "end" hit ENTER, but in
between use SHIFT+ENTER.)

`
> der := proc(f,a)
local h:
Limit((f(a+h)-f(a))/h,h=0) = limit((f(a+h)-f(a))/h,h=0):
end;
> f := x -> x2;
> der(f,2);
> g := exp;
> der(g,a);`

** [OVER]**
Use the procedure ``der'' to find the derivatives of the following functions at
the following points:

(i) at the point .

(ii) at the point .

3. Here is a procedure which takes as input a function and a point , and
returns the equation of the tangent line to the curve at the point
, along with a plot.

`
> tanline := proc(f,a)
local x,y,m,b:
m := D(f)(a):
b := f(a) - m*a:
print(y=m*x+b):
plot({f(x),m*x+b},x=a-3..a+3):
end;
> h := x -> x2 - 3*x + 1;
> tanline(h,-1);
`

Use the procedure ``tanline'' to find the equation of the tangent to the following curves at the following points:

(i)

(ii)