How to derive a formula for the period of a simple pendulum? The following formula is given in our lab manual:
$$ T = 2 \pi \sqrt{\frac{L}{g}} \left( 1 + \frac{1}{4}\sin^2 \frac{\theta}{2} + \frac{9}{64}\sin^4 \frac{\theta}{2}+\cdots \right) $$
for the period of a simple pendulum with length $L$ under the influence of gravitational acceleration with magnitude $g$. We ignore friction. I understand the solution of Newton's Equation via the small angle approximation $\sin \theta \approxeq \theta$ and why that gives the usual elementary formula $T = 2 \pi \sqrt{\frac{L}{g}}$. What I don't understand is how one derives the above formula for higher-order corrections to the period. I think the $\theta$ in the formula is the maximum angle to which the pendulum in question is swinging.
Any insight into the origin or derivation of this formula is appreciated.  
 A: If we take the zero of gravitational potential energy to be at the pivot, then by conservation of energy,
$$\frac{1}{2}m(L\dot{\theta})^2-m g L\cos{\theta}=-m g L\cos{\theta_0}$$
where $\theta_0$ is the maximum angle (where the kinetic energy is zero). This gives the differential equation
$$\frac{d\theta}{dt}=\sqrt{\frac{2g}{L}(\cos{\theta}-\cos{\theta_0}})$$
which gives the period as four times the time to go from 0 to $\theta_0$:
$$T=4\sqrt\frac{L}{2g}\int_0^{\theta_0}\frac{d\theta}{\sqrt{\cos{\theta}-\cos{\theta_0}}}.$$
Using the trigonometric identity
$$\cos\theta=1-2\sin^2{\frac{\theta}{2}}$$
this becomes
$$T=2\sqrt\frac{L}{g}\int_0^{\theta_0}\frac{d\theta}{\sqrt{\sin^2{\frac{\theta_0}{2}}-\sin^2{\frac{\theta}{2}}}}.$$
With the change of integration variable to $u$ where
$$\sin{u}=\frac{\sin{\frac{\theta}{2}}}{\sin{\frac{\theta_0}{2}}}$$
this becomes
$$T=4\sqrt\frac{L}{g}\int_0^{\pi/2}\frac{du}{\sqrt{1-k^2\sin^2{u}}}$$
where
$$k=\sin\frac{\theta_0}{2}.$$
Now use a Taylor expansion and integrate term-by-term to get the result you were given:
$$\begin{align}
T&=4\sqrt\frac{L}{g}\int_0^{\pi/2}du\;\left(1+\frac{1}{2}k^2\sin^2{u}+\frac{3}{8}k^4\sin^4{u}+...\right)\\
&=4\sqrt\frac{L}{g}\left(\frac{\pi}{2}+\frac{1}{2}k^2\frac{\pi}{4}+\frac{3}{8}k^4\frac{3\pi}{16}+...\right) \\
&=2\pi\sqrt\frac{L}{g}\left(1+\frac{1}{4}k^2+\frac{9}{64}k^4+...\right).
\end{align}$$
