# Solution to pendulum differential equation

In a chapter on oscillations in a physics book, the differential equation $$\ddot{\theta}=-\frac{g}{L}\sin(\theta)$$ is found and solved using the small-angle-approximation $$\sin(\theta)\approx\theta$$ for small values of $$\theta$$, which yields the solution $$\theta=\sin\left(t\sqrt{\frac{g}{L}}\right).$$ It also mentions that this solution tends to work best with angles smaller than $$15^\circ$$.

My question is: Is it possible to solve the pendulum differential equation/do any solutions exist to it without the use of the small-angle-approximation?

• – uhoh
Commented Jul 28, 2021 at 12:05
• @uhoh this is not really solving, but re-expressing ODE in terms of integral that still requires numerical evaluation. Technically one could call it an exact solution... by by this measure any ode of type $\ddot{x} + f(x)=0$ is exatcly solvable. Commented Jul 28, 2021 at 17:05
• If you go back to the early 20th century, this sort of thing was routine. Eg, Whittaker's A Treatise on the Analytical Dynamics of Particles and Rigid Bodies doesn't bother with small angles at all. If you choose how you measure the height y sensibly, then y is something like k sn(sqr(g/R) t, k), where k < 1 is a constant depending on the initial energy etc, and sn is the function sinus amplitudinus or sin amp. It is just no-one bothers with sn any more, so when people try to tell you the "exact" solution it looks more complicated than it is. Commented Feb 14 at 12:50

The pendulum problem can be solved exactly if an elliptic integral is used.

The elliptic integral in question is defined via $$$$F(\phi,k)=\int_{0}^{\phi}\frac{dt}{\sqrt{1-k^{2}\sin^{2}t}}\, .$$$$ This integral originated when mathematicians investigated elliptic curves.

In the case of the pendulum problem, the conservation of energy yields the equation of motion $$$$\frac{1}{2}l\dot{\theta}^{2}-g\cos\theta=-g\cos\theta_{m}$$$$ where $$\theta_{m}$$ denote the angle of highest height, then the equation can be inverted to $$$$\frac{d\theta}{dt}=\sqrt{\frac{2g}{l}}\sqrt{\cos\theta-\cos\theta_{m}}$$$$ this expression can be simplified by using a trigonometric identity, $$$$\cos\theta=1-2\sin^{2}(\theta/2),$$$$ and then changing variables according to $$$$\sin\left(\frac{\theta}{2}\right)=\sin\left(\frac{\theta_{m}}{2}\right)\sin s.$$$$ Now differentiate this variable with respect to $$t$$ and use the chain rule, then revert to integrate with respect to $$t$$. This gives $$$$t=\sqrt{\frac{l}{g}}{\int_{0}^{\phi}}\frac{ds}{\sqrt{1-\sin^{2}(\theta_{m}/2) \sin^{2}s}}\, ,$$$$ the solution of which is given by the elliptic integral stated earlier.

• you still need to invert a highly non-linear function to find $\theta$ as a function of $t$, rather than the form you have which is $t$ as a function of $\theta$. Commented Jul 28, 2021 at 21:45
• It's good to know, but it only shifts the problem, doesn't it? Commented Jul 29, 2021 at 6:55
• As I have already noted in the comments to the OP, this procedure is technically applicable to any equation of type $\ddot{x}+f(x)=0$. Commented Jul 29, 2021 at 7:56
• In principle, one can expand the integral in the form of Taylor series, integrate each terms, then invert the equation, solve perturbatively to obtain $\theta(t)$. Commented Jul 29, 2021 at 17:51
• I've developed this answer further in my answer. Commented Jan 8, 2023 at 2:48

It is not possible to express the solution of the equation in terms of elementary functions. Nonetheless, you can obtain an approximate solution via numerical integration.

The figure shows the numerical solution $$\theta(t)$$ for different initial conditions. I have set $$\frac{g}{L}=1$$ and $$\dot{\theta}_0 = \dot{\theta}(t=0) = 0$$.

The initial position $$\theta_0 = \theta(t=0)$$ assumes the values 1°, 5°, 15°, 30°, 60° and 120°.

In each subplot, the blue curve represents the solution of the exact equation

$$\ddot{\theta} = -\sin{\theta}$$

while the orange curve is the solution of the approximate equation

$$\ddot{\theta} = -\theta$$

As you can see, for $$\theta_0 < 15°$$ the two solutions are visually indistinguishable in this time range and level of detail of the image.

• “no closed form solutions” isn’t really accurate, as it is possible to solve by quadrature as done by @wongtom, and this is technically a closed form. Better wording would be “no solutions in terms of elementary functions“. If your figures were in radians they’d be perfect. Commented Jul 28, 2021 at 20:05
• @ZeroTheHero Since "closed form solution" is a vague term that depends on the set of function considered elementary (mathworld.wolfram.com/Closed-FormSolution.html), I have specified which functions I am considering. But “no solutions in terms of elementary functions“ is definitely more concise, thanks for the suggestion. Commented Jul 28, 2021 at 20:21

It is impossible to solve this equation in general case, but it has been extensively studied in the context of

Note that Floquet theory and Bloch theorem are mathematically very similar (some would even say identical). I did not add the link to the Wikipedia article on Floquet theory, since it takes rather abstract view, far away from the OP might be interested in. However, the materials are abundant via googling.

Update

• Note that sine-Gordon is actually a partial differential equation, which, in some cases, is reducible to the equation in the OP
• The comments to this answer and the OP have pointed out that the equation can be solved in terms of elliptic functions. I suppose that this is not what was meant in the OP, but I do agree that what we define as an exact solution is open to interpretations. There are even PSE questions discussing this, e.g., this one: Why can't many models be solved exactly
• Sine-Gordon is a partial differential equation, whereas the differential equation for the mathematical pendulum is an ODE. Furthermore I thought that there actually is an exact solution to OPs ODE, see e.g. : sbfisica.org.br/rbef/pdf/070707.pdf Commented Jul 28, 2021 at 16:54
• @AlmostClueless 1) I know that sine-Gordon is a PDE - and have I never said that they were the same thing. I stand by my wording in this regard. 2) What you cite as "exact solution" is a solution in terms of elliptic functions, which are special functions. It is just a mathematical manipulation to move the difficulty from one place to another - one could just as well tabulate the ODE solution and call it exact solution. Commented Jul 28, 2021 at 16:59
• After rereading your answer I agree with what you are saying about Sine-Gordon and Floquet theory. But I want to stress that what you call an exact solution really depends on what you accept as an "elementary" function. And while most of us would agree that the exponential function, the logarithm, sine and cosine and so on are "elementary" functions these are also evaluated by numerical techniques! And these are often not that trivial, too. (if pushed to a certain level of precision and efficiency) So I think often the argument "this only kicks the can further down the road" is not "true". Commented Jul 29, 2021 at 7:47
• @AlmostClueless Indeed, what is called an exact solution is open to interpretation. I have updated the answer to take into account both points that you raised. Commented Jul 29, 2021 at 7:54

This answer continues on from the answer by wong tom and uses the same notation.

As Tom said, the equation of motion of the simple undamped pendulum with maximum swing angle $$\theta_m$$ leads to this integral: $$t=\sqrt{\frac{l}{g}}{\Large\int_{0}^{\phi}}\frac{ds}{\sqrt{1-\sin^{2}(\theta_{m}/2) \sin^{2}s}}$$

which is an incomplete elliptic integral of the first kind.

Although elliptic integrals cannot be solved using the standard elementary functions they can be evaluated numerically very efficiently using algorithms based on the arithmetic-geometric mean (AGM), which converges quadratically. Elliptic integrals can be inverted using the Jacobi elliptic functions, which can also be computed rapidly using AGM-based algorithms.

These integrals and functions have been studied extensively since the 18th century; eg Gauss did important work on them, including investigating the AGM connection, which had been discovered earlier by Landen. (Perhaps the AGM-based algorithms didn't receive a lot of attention in the past because they are less amenable to analysis than power series are, and because they involve swapping back & forth between addition and multiplication & square root extraction, which is a bit tedious when you're working with log tables. But in the modern era of electronic computers, they are trivial to implement, and advanced mathematics libraries routinely use the AGM).

The substitution $$\sin\left(\frac{\theta}{2}\right)=\sin\left(\frac{\theta_{m}}{2}\right)\sin s$$

means that $$\phi=\pi/2$$ corresponds to $$\theta=\theta_m$$, so evaluating the above integral for $$\phi=\pi/2$$ gives the quarter period of the pendulum.

Let $$k=\sin(\theta_m/2)$$ and $$k'=\cos(\theta_m/2)$$.

Now $${\Large\int_{0}^{\pi/2}}\frac{ds}{\sqrt{1-k^2\sin^2 s}}$$ is the complete elliptic integral of the first kind.

It can also be written as $${\Large\int_{0}^{\pi/2}}\frac{ds}{\sqrt{k'^2\sin^2 s + \cos^2 s}}$$

Landen and Gauss realised that if $$I={\Large\int_{0}^{\pi/2}}\frac{ds}{\sqrt{a^2\sin^2 s + b^2\cos^2 s}}$$ then $$I={\Large\int_{0}^{\pi/2}}\frac{ds}{\sqrt{a'^2\sin^2 s + b'^2\cos^2 s}}$$ where $$a'=(a+b)/2, \, b'=\sqrt{ab}$$ which is the AGM transformation. So we just need to find $$\operatorname{AGM}(a,b)$$ to transform the integral to the trivial

$$I={\Large\int_{0}^{\pi/2}}\frac{ds}{\operatorname{AGM}(a,b)\sqrt{\sin^2 s + \cos^2 s}}$$ i.e., $$I=\frac{\pi}{2\operatorname{AGM}(a,b)}$$

This same technique can be applied to computing the incomplete integrals, we just need to do a little bit of bookkeeping to keep track of the transformations of the upper integral limit. And it can also be applied to the elliptic functions. Please see the Wikipedia links for further details. Also see
Numerical computation of real or complex elliptic integrals, Bille C. Carlson (1994)
doi: 10.48550/arXiv.math/9409227

Applying this to the pendulum integral, we now have an expression for the true period:

$$T=\frac{2\pi\sqrt{\frac{l}{g}}}{AGM(1, k')}$$ or $$T=T_0 / \operatorname{AGM}(1,k')$$ where

$$T_0=2\pi \sqrt{\frac{l}{g}}$$ is the simple period computed using the $$\sin(\theta)\approx\theta$$ approximation. As $$\theta_m\to 0, k\to 0, k'\to 1$$, and of course $$\operatorname{AGM}(1,1)=1$$.

If $$u={\Large\int_{0}^{\phi}}\frac{ds}{\sqrt{1-k^2\sin^2 s}}$$ then $$\phi=\operatorname{am}(u, k^2)$$ where $$\operatorname{am}$$ is the Jacobi elliptic amplitude function.

Let $$u=t\sqrt{\frac{l}{g}}$$ Now $$\sin\left(\frac{\theta}{2}\right)=k\sin\phi$$ So $$\theta=2\arcsin(k\sin\phi)$$ gives us $$\theta$$ as a function of $$t$$ with parameter $$k$$.

Note that $$\operatorname{am}(u,0)=u$$, so in the small angle approximation we recover the simple equation $$\theta=\theta_m\sin(2\pi t/T)$$

Conveniently, the AGM algorithm for $$\operatorname{am}$$ is in two parts. The first part computes a list of AGM terms using $$k$$ and $$k'$$, the second part uses that list and $$u$$ to compute $$\phi$$. So for a fixed $$k$$ we can compute multiple $$\phi$$ values without having to repeat the AGM list calculation.

Here's a short Python program which implements this algorithm to graph pendulum angle as a function of time. It's running on the SageMathCell server, and uses Sage plotting functions, but the core arithmetic is done in plain Python, only using standard math library functions. (Sage actually provides a full complement of arbitrary precision elliptic integrals and functions, as well as the AGM).

Pendulum demo

The program plots the true pendulum function in red. It can also plot the simple sine function (in green) or a sine function with its period corrected to the true period (in blue).

For smallish $$\theta_m$$, it's hard to see the difference between the true curve and the simple sines. Even for angles approaching $$90°$$, the period-corrected sine is still quite close to the true curve. Here are a few examples for a pendulum of length $$1$$ m.