\documentclass{article}

\newenvironment{problem}[1]{\begin{framed}\noindent{\bf\LARGE #1}\\*[1em]}{\end{framed}}
\newenvironment{subproblem}[1]{\begin{framed}\noindent{\bf(#1)} }{\end{framed}}
\newenvironment{solution}{}{}
\newcommand{\firstsub}[1][a]{${}$\\\noindent{\bf(#1)} }

\usepackage{fullpage}
\usepackage{framed}
\usepackage{amsmath}
\usepackage{color}
\usepackage{pstricks}
\usepackage{pst-plot}
\usepackage{pst-coil}
\usepackage{multido}
\usepackage{epsfig}
\newcommand{\gp}[1]{{\left({#1}\right)}}
\newcommand{\px}[2]{\frac{\partial #1}{\partial #2}}
\newcommand{\dx}{\Delta x}

\begin{document}

\title{Math 142-2, Project 1}
\author{Both partners' names here}
\date{}
\maketitle

\begin{problem}{Introduction}
  This project looks at the equation for the undamped nonlinear pendulum
  \begin{align*}
    m \theta'' + k \sin \theta &= 0 \qquad \theta(0) = \theta_0 \qquad \theta'(0) = 0
  \end{align*}
  using a mixture of analytic and numerical techniques.
\end{problem}

\begin{problem}{Problem 1}
  Show that this problem can be reduced to the simpler ODE
  \begin{align*}
    \theta'' + \sin \theta &= 0 \qquad \theta(0) = \theta_0 \qquad \theta'(0) = 0
  \end{align*}
  in the sense that the solution to the original problem can be readily deduced
  from the solution to this simpler problem.
\end{problem}

\begin{solution}
  \textbf{\textcolor{red}{Your solution goes here}}
\end{solution}

\begin{problem}{Programming}
  To complete the remainder of this project, you will need to use a computer to
  numerically approximate the solution to the simplified ODE $\theta'' + \sin
  \theta = 0$, $\theta(0) = \theta_0$, $\theta'(0)=0$.  Use fourth order
  Runge-Kutta to approximate the ODE.  The fourth order Runge-Kutta method for
  approximating the solution to an ODE $z' = f(z,t)$ is given by
   \begin{align*}
    z_0 &= \langle x(0),x'(0) \rangle \\
    z_{n+1} &= z_n + \frac{h}{6} (a + 2 b + 2 c + d) \\
    a &= f(t_n, z_n) \\
    b &= f\gp{t_n + \frac{h}{2}, z_n + \frac{h}{2} a} \\
    c &= f\gp{t_n + \frac{h}{2}, z_n + \frac{h}{2} b} \\
    d &= f(t_n + h, z_n + h c)
   \end{align*}
  You will also need to compute an estimate of the period of your solution.  A
  good way to do this is to compute the time when the sign of the solution first
  changes.  An accurate estimate is obtained by connecting the last positive
  value and first negative value with a straight line and then choosing the time
  when this line crosses zero.  You can use this information to estimate the
  period fairly accurately.  \textbf{Please print out and submit your code with
    your solutions.}
\end{problem}

\begin{problem}{Problem 2}
  For each $\theta_0 \in \{0.2, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.1, 3.14\}$,
  produce one plot showing (a) the solution $x_{sol}$ to the nonlinear ODE, (b)
  the solution $x_{simp} = \theta_0 \cos t$ to the simplified linear ODE, and
  (c) an \textit{adjusted} solution $x_{adj} = \theta_0 \cos \beta t$, where
  $\beta$ is chosen so that the period matches the solution to the original ODE.
  (Note that the period is $2 \pi/\beta$.)  Observe that the period begins to
  deviate well before the shape does.
\end{problem}

\begin{solution}
  \textbf{\textcolor{red}{Your solution goes here}}
\end{solution}

\begin{problem}{Problem 3}
  Produce a plot showing the error $E_p$ in the period of the nonlinear pendulum
  and the error $E_a$ in the adjusted approximation, where
  \begin{align*}
    E_p &= \frac{1}{\beta} - 1 \\
    E_a &= \frac{1}{\theta_0} \max_t |x_{sol}(t) - x_{adj}(t)|
  \end{align*}
\end{problem}


\begin{solution}
  \textbf{\textcolor{red}{Your solution goes here}}
\end{solution}


\begin{problem}{Problem 4}
  At (approximately) what initial angle $\theta_0$ does the period error $E_p$
  reach $1\%$? $10\%$?
\end{problem}

\begin{solution}
  \textbf{\textcolor{red}{Your solution goes here}}
\end{solution}

\begin{problem}{Problem 5}
  At (approximately) what initial angle $\theta_0$ does the adjusted error $E_a$
  reach $1\%$? $10\%$?
\end{problem}

\begin{solution}
  \textbf{\textcolor{red}{Your solution goes here}}
\end{solution}

\begin{problem}{Problem 6}
  Why does the period get longer when the initial displacement is increased?
  (An intuitive explanation is sufficient.)
\end{problem}

\begin{solution}
  \textbf{\textcolor{red}{Your solution goes here}}
\end{solution}

\begin{problem}{Problem 7}
  Provide an explanation for why a pendulum spends far more time with $|\theta|$
  near its maximum than near zero, when the initial displacement is close to
  $\pi$.  (An intuitive explanation is sufficient.)
\end{problem}

\begin{solution}
  \textbf{\textcolor{red}{Your solution goes here}}
\end{solution}

\end{document}
