====== Math 445 lab 7: the pendulum (numerical integration of differential eqns) ======
**Problem 1:** In class we developed a linear system of differential equations of the form $dx/dt = f(x) = Ax$ for the plane pendulum, where
x = \left(\begin{array}{l} x_1\\ x_2\end{array} \right) = \left(\begin{array}{l} \theta \\ v_{\theta} \end{array} \right)
We used the approximation $\sin \theta \approx \theta$ for small $\theta$, i.e. small amplitude oscillations. A chief result of this derivation was that the frequency of oscillation of the pendulum is given by $\omega = \sqrt{g/l}$, where $g$ is the acceleration due to gravity and $l$ is the length of the pendulum.
However if $\theta$ gets large the approximation $\sin \theta \approx \theta$ is no longer valid. This lab problem is an investigation of how the frequency of oscillation of the pendulum changes when the amplitude of the oscillation is large.
**(a)** Revise the derivation from class to develop a nonlinear system of differential equations $dx/dt= f(x)$ that is valid for large $\theta$.
**(b)** Set up Matlab code to integrate this system of equations numerically, using Matlab's ''ode45'' function.
**%%(c)%%** Determine the frequency of oscillation of the nonlinear pendulum for
for the constants $g=9.8 \; m/s^2$ and $l=1.0 \; m$ and a variety of oscillation amplitudes.
The oscillation amplitude is given by the angle $\theta_0$ at which the pendulum is released at time $t=0$, with no initial velocity. Determine the frequency $\omega$ for
$\theta_0 = 0.05, 0.10, ..., 0.30$ and plot $\omega$ versus $\theta_0$.
**(d)** For moderate amplitudes, the frequency $\omega$ of the nonlinear pendulum should vary with $\theta_0$ as
\omega = \sqrt{g/l} + c \; \theta_0^2
for some value of $c$. Determine what the value of $c$ is from your graph in %%(c)%%.
----
**Problem 2:** For the linear pendulum, we produced in lecture //time series// plots of position $\theta$ and (angular) velocity $d\theta/dt$ as a function of time, and a //phase portrait// of $\theta$ versus $d\theta/dt$.
**With no damping** from air resistance, the equations of motion of the linear pendulum are
\begin{eqnarray*}
\frac{d}{dt} \left( \begin{array}{c} x_1 \\ x_2 \end{array} \right) = \left[ \begin{array}{cc} 0 & 1 \\ -g/l & 0 \end{array} \right] \left( \begin{array}{c} x_1 \\ x_2 \end{array} \right)
\end{eqnarray*}
where $(x_1, x_2) = (\theta, d\theta/dt$). The time series and phase portrait (for $g=9.8$ and $l=1$) look like
{{:gibson:teaching:fall-2014:math445:timeseries_linear_nodamp.png?nolink&400}} {{:gibson:teaching:fall-2014:math445:phaseportrait_linear_nodamp.png?nolink&400}}
Note that the temporal oscillations look like perfect sines and cosines, and the phase portrait shows that trajectories circle around the origin indefinitely.
However, **if we include the damping of air resistance**, the equations of motion of the linear pendulum are
\begin{eqnarray*}
\frac{d}{dt} \left( \begin{array}{c} x_1 \\ x_2 \end{array} \right) = \left[ \begin{array}{cc} 0 & 1 \\ -g/l & -\alpha/m \end{array} \right] \left( \begin{array}{c} x_1 \\ x_2 \end{array} \right)
\end{eqnarray*}
and the time series and phase portrait for (for $g=9.8$, $l=1$, and $\alpha=1$) look like
{{:gibson:teaching:fall-2014:math445:timeseries_linear_damp.png?nolink&400}} {{:gibson:teaching:fall-2014:math445:phaseportrait_linear_damp.png?nolink&400}}
Now the temporal oscillations get smaller and smaller as time goes on. The phase portrait shows that all initial conditions eventually spiral into the origin, i.e. the pendulum hangs straight down ($\theta = 0$) and doesn't move $d\theta/dt = 0$).
For this lab problem, you are to recreate the previous four plots for the nonlinear pendulum, whose equations of motion are
\begin{eqnarray*}
\frac{d}{dt} \left( \begin{array}{c} x_1 \\ x_2 \end{array} \right) = \left( \begin{array}{c} x_2 \\ -g/l \, \sin x_1 - \alpha/m \, x_2 \end{array} \right)
\end{eqnarray*}
Use parameter values $g=9.8, l=1$ and $\alpha = 0$ or $1$ for no damping or damping, respectively. For the time series plots, initiate the pendulum with $x_1 = \theta=0$ and $x_2 = d\theta/dt = 2$. For the phase portraits, show the range $8 \leq \theta \leq 8$ on the horizontal axis and $-10 \leq d\theta/dt \leq 10$ on the vertical. On top of the quiver plots, show trajectories with initial conditions $\theta=0$ and a variety of $d\theta/dt$ ranging from -10 to 10 in steps of 1.
Turn in your code, your plots, and answer the following questions
**(a)** Describe the differences that you see in the phase portraits of the nonlinear pendulum compared to the linear pendulum.
**(b)** For the undamped nonlinear pendulum, you should see trajectories with three distinctly different types of behavior. Give a physical interpretation of each of those three types of trajectories in terms of the motion of the pendulum.
**%%(c)%%** You should also see three distinct type of trajectories for damped nonlinear pendulum. Give a physical interpretation of each of those types of trajectories.
**(d)** The damped nonlinear pendulum has quite a few more distinct groups of trajectories than the ones shown in shown in your phase portrait. Based on your physical interpretation, what would those be? Revise your nonlinear damped phase portrait to show some of these other trajectories.