\magnification = \magstep1
\centerline{Mathematics 36, section 3 -- AP Analysis}
\centerline{Lab Day 4:  Applications of Integration: Arc Length of Curves}
\centerline{November 2, 1999}
\bigskip
\noindent
{\it Goals}
\bigskip
Today we will learn Maple's commands for symbolic and approximate
integration, and apply them to an additional type of integration problem.
\bigskip
\noindent
\bigskip
\noindent
{\it The {\tt int} Command in Maple}
\bigskip
\noindent
{\it 1. Indefinite Integrals}
\bigskip
To ask Maple calculate an indefinite integral such as 
$$\int { x - 4 \over x^2 + 2x + 5}\ dx$$
we could use a command such as
\medskip
\centerline{\tt int((x-4)/(x\^{}2+2*x+5),x);}
\medskip
\noindent
Try this and differentiate the output by hand to 
check that it is correct.  Also try differentiating 
using Maple's {\tt diff} command.  (Note: by completing the 
square, $x^2 + 2x + 5 = (x+1)^2 + 4$ which has no real roots.
This is an integral of the form \# 25 from the table in the text, 
if you substitute $u = x+1$ and convert the entire integrand to an expression
in $u$.)

\bigskip
The general format of the indefinite integral command is
\medskip
\centerline{\tt int(expression,var);}
\medskip
\noindent
where {\tt expression} is the formula for the integrand, and 
{\tt var} is the variable you are integrating with respect to.  (It may 
help to think of this as corresponding to the ``$dx$'' in the 
mathematical notation.)  The variable can be any variable appearing 
(or not) in the expression.  What do you think happens if the variable
{\it doesn't} appear?  Try it out!

\bigskip
On many examples, Maple will not be able to do anything 
to get an indefinite integral in terms of the usual elementary functions.
When this happens it will just echo your input.  (For instance, 
you can try $\int e^x/\cos(x)\ dx$.)  In {\it some cases}, doing some
preliminary substitution ``by hand'' will give Maple something it
can work with.  But be aware that even though some functions 
can be handled by our general methods (and others we have not 
discussed), {\it very few functions actually
have elementary antiderivatives.\/}  

\bigskip
\noindent
{\it 2. Definite Integrals}
\bigskip
To do definite integrals in Maple, you use the same {\it int} command, 
but in a slightly different format.  For instance, suppose we want
to compute
$$\int_1^2 { x - 4 \over x^2 + 2x + 5}\ dx$$
We can use the command
\medskip
\centerline{\tt int((x-4)/(x\^{}2+2*x+5),x=1..2);}
\medskip
\noindent
(Note the limits of integration added to the previous command, in the 
same format as a range of values for plotting.) Your output from this
command should be
$${1\over 2} \ln(13) - {5 \over 2} \arctan({3\over 2}) - {1\over 2} \ln(8)
+ {5\over 8} \pi$$
As you can easily verify, this is just the result of applying the 
Fundamental Theorem of Calculus with the antiderivative (indefinite
integral) from before.
\bigskip
\item{} {\it If Maple can generate an exact, symbolic expression
for a definite integral it will do that and give that as the output,
unless directed otherwise.}
\bigskip
\noindent
If you want a {\it decimal approximation\/} to the value, rather than an 
exact, symbolic expression you can put the whole integrate
command, capitalized to {\tt Int},
``inside'' a call to the {\tt evalf} function:
\medskip
\centerline{\tt evalf(Int((x-4)/(x\^{}2+2*x+5),x=1..2));}
\medskip
\noindent
This will use a numerical method (basically a {\it Riemann sum\/} with varying
$\Delta x$'s chosen to yield an approximation good to 
a large number of decimal places) to compute an approximate value.
\bigskip
\noindent
{\it Another Application of Integrals -- Background}
\bigskip
Imagine a thin, curved wire in a plane.  A basic measurement problem
is to determine the {\it length\/} of the wire (if possible without
deforming its shape!)  If we knew the density of the wire at
each point, we could also ask what its {\it total mass\/} is.

We can {\it model\/} the shape of the wire 
mathematically by giving  
a curve in the plane -- in simple cases, the graph of a
function $y = f(x)$ for $x \in [a,b]$.  The length of the graph (measured
``along the curve'' is called its {\it arc length\/}.
 Today we will learn how to compute
the {\it arc length\/} of a graph in mathematical terms.  As with other
problems we have studied, the basic approach is to {\it subdivide and
approximate}.  Suppose we subdivide $[a,b]$ into $n$ smaller intervals
with endpoints
$$a=x_0 < x_1 < x_2 < \cdots < x_{n-1} < x_n = b$$
If $\Delta x$ is small enough (and $f$ is a ``nice'' function), the
segment $s_i$ of the graph from $(x_{i-1},f(x_{i-1}))$ to $(x_{i},f(x_{i}))$
will be {\it nearly straight}, hence can be approximated by a 
the straight line segment $\ell_i$ joining the two points on the graph.  Writing
$\Delta y_i = f(x_i) - f(x_{i-1})$, we have by the Pythagorean theorem:
$$\eqalign{{\rm length\ of\ } s_i &\doteq \sqrt{\Delta x^2 + \Delta y_i^2}\cr
    &= \sqrt{1 + \left({\Delta y_i\over\Delta x}\right)^2}\cdot \Delta x.\cr}$$
So the total length is approximated by a sum 
$${\rm total\ length} = \sum_{i=1}^n\sqrt{1+\left({\Delta y_i\over\Delta x}\right)^2}\cdot \Delta x$$
Even though this is not exactly a Riemann sum as it stands
(because the expression 
${\Delta y_i\over\Delta x}$ is not formed by evaluating a particular 
function at a chosen point $x_i^*$), it is still true that
as $n \to \infty$ and $\Delta x \to 0$ the limit of this sum gives a 
definite integral.  Since 
$$\lim_{\Delta x \to 0} {\Delta y_i\over\Delta x} = f'(x),$$ 
the derivative of $f$,
the integral for arclength of the graph $y = f(x)$ is
$${\rm arc\ length} = \int_a^b \sqrt{1 + (f'(x))^2}\ dx$$
\bigskip
\noindent
{\it A Worked Example}
\bigskip
Suppose we wanted to find the arc length of $y = f(x) = (e^x + e^{-x})/2$
from $x = 0$ to $x = 1$.  We can use Maple to attack this as follows.
First we can define the function $f(x)$ using
\medskip
\centerline{\tt f := (exp(x) + exp(-x))/2;}
\medskip
\noindent

Then the arclength integral (indefinite) is 
\medskip
\centerline{\tt int(sqrt(1 + diff(f,x)\^{}2),x);}
\medskip
\noindent
Maple should give you as output:
$${1\over 2}e^x - {1\over 2}{1\over e^x}$$
This is one of the (rare!!) cases where an arclength integral actually
has an elementary antiderivative.  If you enter the Maple command
to find the definite integral:
\medskip
\centerline{\tt int(sqrt(1 + diff(f,x)\^{}2),x=0..1);}
\medskip
\noindent
then Maple will use the Fundamental Theorem of Calculus and the indefinite
integral above to compute the definite integral.  

\bigskip
{\it In most cases, this will not be possible, though, and the best 
we will be able to do is to generate a numerical appoximation
to the arclength, using a command of the form:}
\medskip
\centerline{\tt evalf(int(sqrt(1 + diff(f,x)\^{}2),x=a..b));}
\medskip
\noindent
{\it This command instructs Maple to approximate the definite 
integral using a Riemann sum method.}

\bigskip
For instance, if you do this on the integral above, you should get 
a numerical approximation $1.175201194$ to 
$$\int_0^1 \sqrt{1 + (f'(x))^2}\ dx$$
for $f(x) = (e^x + e^{-x})/2$.
\bigskip
\noindent
{\it Lab Questions}
\bigskip
\item{A)}  Using Maple as above, get decimal numerical 
approximation the length of the 
graphs $y = x^n$, $x = 0$ to $x = 1$, for $n = 1,2,10,20,100$.

\bigskip
\item{B)}  For which of the $n$'s in question A is there an 
elementary antiderivative for the arc length integrand
$\sqrt{1 + (nx^{n-1})^2}$ (or at least one that Maple can find)?  Note: It
can also be shown that the functions here that Maple cannot integrate
symbolically actually {\it have no elementary antiderivatives}.

\bigskip
\item{C)}  Discuss any patterns or trends you see in the calculations
in question A.  In particular, can you guess something about the arc lengths
of the graphs $y = x^n$, ($x = 0$ to $x = 1$), as $n \to \infty$?  
Plotting the graphs
$y = x^n$, $n = 1,2,10,20,100$
together may help to visualize and/or explain this.

\bigskip
\item{D)}  A thin wire in the shape of the graph $y = x^3$, $x \in [-1,1]$
(in cm's)
has density $d(x) = 3+x$ g/cm at the point $(x,x^3)$.  
\itemitem{1)} Develop, and {\it fully explain\/} in your solution, a method
for approximating the {\it total mass of the wire\/} using the 
ideas about arclength above.  Note that different portions of the 
wire will have different densities.  Hence segments of the same 
length can have different masses.
\itemitem{2)} Use your method
and Maple to approximate the total mass.  ({\it Answer:} $\doteq 9.29$ g)

\bigskip
\noindent
{\it Lab Assignment:}  Writeups for questions A) - D) due in 
class on Tuesday, November 9.
\bye

