DISP Mathematics (Scie 1500R)

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


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

\begin{displaymath}\lim_{x \rightarrow a} f(x) \end{displaymath}

use the command > limit(f(x), x=a); . Note that what goes in the first place (before the comma) is an expression.

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(x$\,^{\wedge}$3,x=2);
> Limit(x$\,^{\wedge}$3,x=2);
> value(%);
> evalf(%%);
> Limit(x$\,^{\wedge}$3,x=2) = limit(x$\,^{\wedge}$3,x=2);
> limit((x$\,^{\wedge}$2-9)/(x-3), x=3);
> Limit((x$\,^{\wedge}$2-9)/(x-3), x=3) = limit((x$\,^{\wedge}$2-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);


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


Before you start these exercises type restart;.

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


\begin{displaymath}\lim_{x\rightarrow 4}\frac{x^3 - 7x^2 + 14x - 8}{x^2 - 16} =\ldots\ldots\ldots\end{displaymath}


\begin{displaymath}\lim_{x\rightarrow 0}\frac{\sin(3x)}{4x} = \ldots\ldots\ldots\end{displaymath}

(Hint: Put brackets round $(4*x)$.)


\begin{displaymath}\lim_{x\rightarrow 0}\frac{\sin(mx)}{nx} = \ldots\ldots\ldots\end{displaymath}


\begin{displaymath}\lim_{x\rightarrow 2}\frac{x^2 - 4}{\vert x-2\vert} = \ldots\ldots\ldots\end{displaymath}


\begin{displaymath}\lim_{x\rightarrow 2^+}\frac{x^2 - 4}{\vert x-2\vert} = \ldots\ldots\ldots\end{displaymath}


\begin{displaymath}\lim_{x\rightarrow 2^-}\frac{x^2 - 4}{\vert x-2\vert} = \ldots\ldots\ldots\end{displaymath}

2. Here is a procedure to calculate the derivative of a function $f$ at a point $a$, 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):

> f := x -> x$\,^{\wedge}$2;
> 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) $\sqrt{x}$ at the point $x = 4$.

(ii) $\log(x^2 + x)$ at the point $x = a$.

3. Here is a procedure which takes as input a function $f$ and a point $a$, and returns the equation of the tangent line to the curve $y = f(x)$ at the point $(a,f(a))$, along with a plot.
> tanline := proc(f,a)
local x,y,m,b:
m := D(f)(a):
b := f(a) - m*a:

> h := x -> x$\,^{\wedge}$2 - 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:


\begin{displaymath}y = 3 \sin(x) \mbox{\quad at the point } x = \pi/4\end{displaymath}


\begin{displaymath}y = e^{x/4} \mbox{\quad at the point } x = 3/2\end{displaymath}

Tony Thompson