\nopagenumbers
\magnification=1200
\advance\vsize .2truein

\def \d{\displaystyle}
\def \h{\hfill}
\def \v{\vfill}
\def \title#1{\line{\h{\bf Math 151  #1}\h}}
\def \namdat#1{\line {Name and Section \vrule height .4pt width2in depth0pt\h#1\par}}
\def \frac #1#2{{\d #1\over \d #2}}
\parindent=0pt
\font \bigbf = cmr10 scaled 1200
\def \i{\item}
\def \vs{\vskip 5pt}
\def \vss{\vskip 10pt}
\def \hs{\hskip 10pt}
\def \c{\circ}
\def \t{\theta}
\def \vc#1{ {\bf\vec#1} }
\def \q{\quad}


\baselineskip = 13pt
\line{\h  Spring 1998}
\line{\h \bigbf Maple Lab, Week 26 \h}
\vss
\line{\h \bigbf The Pendulum Equation and Maple's {\tt dsolve} Command\h}
\vss
{\bf Background:} The second order differential equation
$$\frac{d^2\t}{dt^2} + c\frac{d\t}{dt} + \frac g l\sin(\t) = 0\leqno(1)$$
is a mathematical model for the motion of a pendulum.  
The pendulum consists of a rigid, weightless rod of length $l$, pinned at one end,
 and with a mass $m$ at the other end.  
The rod pivots about the pinned end, O, and is assumed to move in a single plane. 
The angular position of the rod at time $t$, measured counterclockwise from 
vertically downward,  is $\t = \t(t)$.  The term 
$c\frac{d\t}{dt}$ accounts for the drag on the mass due to air resistance.  You
will be asked to derive the equation (1) in the exercises.

If we simplify (1) by assuming $\frac g l = 1$ and $c = 0$, we get
$$\frac{d^2\t}{dt^2} + \sin(\t) = 0.\leqno(2)$$

Maple has a command, {\tt dsolve}, for solving differential equations.  
The following example illustrates the use of {\tt dsolve} to solve the simple 
initial value
problem $y' + 3y = 0,\,\,y(0)=2$.  
Additional examples may be found in the online help.
\vs
$>$ {\tt de1 := diff(y(t),t) + 3*y(t) = 0;}

$>$ {\tt init1 := y(0) = 2;}

$>$ {\tt sol1 := dsolve(}$\{${\tt de1,init1}$\}${\tt ,y(t));}
\vs
Note that the solution is an equation.  
If we would like to plot the solution, for example, we could use the {\tt plot} 
command together with the {\tt rhs} 
command (for {\tt r}ight {\tt h}and {\tt s}ide):
\vs
$>$ {\tt ysol1 := rhs(sol1);}

$>$ {\tt plot(ysol1, t=0..1);}
\vs

Sometimes {\tt dsolve} can't solve a differential equation.  For example, 
the equation (2) is nonlinear and happens to be too difficult for Maple,
 as the following commands illustrate:
\vs
$>$ {\tt de2 := diff(th(t),t,t) + sin(th(t)) = 0;}

$>$ {\tt init2 := th(0) = 0, D(th)(0) = 2;}

$>$ {\tt sol2 := dsolve(}$\{${\tt de2,init2}$\}${\tt ,th(t));}
\vs

There are at least two things which can be done to remedy the situation: 
 simplify the differential equation, or seek an approximate (i.e., numerical)
solution.

As an example of the first approach, we can approximate $\sin(\t)$ by the 
linear approximation $L(\t) = \t$  near $\t = 0$.  
This gives  the equation $\t'' + \t = 0$, which is easy for Maple to solve 
(and easy to solve by hand, as well):
\vs
$>$ {\tt de3 := diff(th(t),t,t) + th(t) = 0;}

$>$ {\tt sol3 := dsolve(}$\{${\tt de3,init2}$\}${\tt,th(t));}
\vs
To obtain a numerical solution, include {\tt type = numeric}, or simply
{\tt numeric}, in the calling sequence:
\vs
$>$ {\tt sol2 := dsolve(}$\{${\tt de2,init2}$\}${\tt,th(t),numeric);}
\vs
The solution is a procedure which can be evaluated at any value of the independent variable:
\vs
$>$ {\tt sol2(0); sol2(1);}
\vs
One way to plot the solution is to create a list of ordered pairs and 
use the {\tt plot} command:
\vs
$>$ {\tt plt := NULL:}

$>$ {\tt for i from 0 by .1 to 10 do}

$>$ {\tt plt := plt, [rhs(sol2(i)[1]), rhs(sol2(i)[2])]: od: plot([plt]);}
\vs
Notice that $\t(t) \to \pi$ as $t$ increases.  What motion of the pendulum is 
represented by this solution? 

\vs
{\bf Exercises:}  All graphs in the following exercises are to be produced
using the {\tt plot} command, as in the examples above. 
\vs
{\bf 1.}  Derive the equation (1), when there is no drag, i.e., $c=0$. 
 [Hint:  Recall {\it torque = I}$\cdot${\it alpha}.
\vs
{\bf 2.}  Display graphs of the solutions {\tt sol2} and {\tt sol3} 
on the same coordinate system, for $0\leq t \leq 10$. 
[Hint: Recall the {\tt display} command in the {\tt plots} package.]
\vs
{\bf 3.}  Repeat Exercise 2, but for the initial condition $\t(0)=0$, $\t'(0)=.5$,
on the interval  $0\leq t \leq 40$.  Identify which graph is which. 
[Hint: How long does it take the solution to $\t'' + \t = 0$ to complete six periods?]
\vs
{\bf 4.}  Use conservation of energy to explain why the initial condition
$\t(0)=0$, $\t'(0)=2$ corresponds to the solution of (2) for which the pendulum 
converges to the vertically upright position,
as $t\to\infty$.
\vs
{\bf Do either Exercise 5 or Exercise 6; extra credit for doing both.}
\vs
{\bf 5.}  Repeat Exercise 2, but add a solution {\tt sol4} of the higher-order Taylor 
approximation to (2), 
$$ \frac{d^2\t}{dt^2} + \t - \frac16 \t^3 + \frac1{120} \t^5 = 0.
\leqno(3)$$
Comment on the result.  Try also the approximation with the $\t^3$ term included but
the $\t^5$ term omitted; why does this case give trouble?

\vs
{\bf 6.}  Solve (1) numerically with $g/l = 1$ and $c=.5$, using the initial 
condition $\t(0)=0$, $\t'(0)=2$.  Plot the solution in the $\t,\t'$ plane.  
Repeat for different values of $\t'(0)$ until you obtain the solution that 
corresponds to the pendulum converging to the vertically upright position.   
 
\bye




