Advanced classical mechanics and beyond: an explanation for Fidello.

Double pendulum animation frame.
In this article, I explain to Fidello from Foci's Discord server some prerequisite knowledge he needs to effectively derive the equations of motion for a double rigid pendulum and then cover more advanced topics for him. In theory, the derivation of the equations of motion for a double rigid pendulum can be done with Newtonian mechanics with F=ma\textbf{F}=m\mathbf{a}, but given our second pendulum is in a moving reference frame and Newtonian mechanics does not easily adapt to alternative coordinate systems, like polar coordinates, Lagrangian mechanics makes the equations of motion easier to derive. Lagrangian mechanics also leads nicely into Hamiltonian mechanics and the path integral formulation of quantum mechanics. Figure shows a frame from the double pendulum animation this page does by default.

Prerequisite mathematics

There are several pieces of prerequisite mathematics I need to cover in order for this article to make sense for you.

Maclaurin and Taylor series

If we have a function f(x)f(x), it is usually possible to write an infinite sum (or series) that equals f(x)f(x) using f(x)f(x)'s derivatives.Namely:

f(x)=∑n=0∞dnfdxn∣x=a(x−a)nn!=f(a)+∑n=1∞dnfdxn∣x=a(x−a)nn!.\begin{align} f(x) &= \sum_{n=0}^{\infty} \dfrac{d^n f}{dx^n}\Big|_{x=a} \dfrac{(x-a)^n}{n!} \tag{1} \\ &= f(a) + \sum_{n=1}^{\infty}\dfrac{d^n f}{dx^n}\Big|_{x=a} \dfrac{(x-a)^n}{n!} . \tag{2} \end{align}

Where we are using dnfdxn∣x=a\dfrac{d^n f}{dx^n}\Big|_{x=a} to denote the nnth derivative of f(x)f(x) evaluated at x=ax=a and n!n! denotes the factorial of nn. If you are unfamiliar, well n!=n×(n−1)×(n−2)×(n−3)×...×1n!=n\times (n-1) \times (n-2) \times(n-3) \times ... \times 1. For instance, 5!=5×4×3×2×1=1205!=5\times 4 \times 3 \times 2 \times 1=120. As for aa it is an arbitrary number we get to choose. Equation (1) is known as the Taylor series of f(x)f(x).

If a=0a=0, then we get the Maclaurin series:

f(x)=∑n=0∞dnfdxn∣x=0xnn!=f(0)+∑n=1∞dnfdxn∣x=0xnn!.\begin{align} f(x) &= \sum_{n=0}^{\infty} \dfrac{d^n f}{dx^n}\Big|_{x=0} \dfrac{x^n}{n!} \tag{3} \\ &= f(0) + \sum_{n=1}^{\infty} \dfrac{d^n f}{dx^n}\Big|_{x=0} \dfrac{x^n}{n!}. \tag{4} \end{align}

Why do these equations hold? Well, try taking the nnth derivative of Equations (1) and (3) and substituting x=ax=a and x=0x=0, respectively. You'll find that you get dnfdxn∣x=a\dfrac{d^n f}{dx^n}\Big|_{x=a} and dnfdxn∣x=0\dfrac{d^n f}{dx^n}\Big|_{x=0}, respectively. Consequently, our series matches our original function in its nnth derivative for n∈Z+n\in \mathbb{Z}^{+}. Likewise, if you substitute in x=ax=a and x=0x=0 into the Taylor and Maclaurin series, respectively, you should get f(a)f(a) and f(0)f(0), respectively. So we see that this is like a polynomial of infinite order that matches our original function for its value and derivatives value at one point. It turns out that this means it contains enough information to match our original function at other points, too.

There are exceptions where Taylor series do not accurately compute the function they pertain to. For instance, points where the function is undefined can mess things up. As an example, ln⁡(x+1)\ln{(x+1)}'s Maclaurin series will only approximate f(x)f(x) well for −1<x<1-1 < x < 1 as at x=−1x=-1 the function is undefined. Beyond these points it will fail to converge (meaning it will not equal some finite number as terms for higher nn will not get rapidly smaller as nn gets bigger).

Now, I know this probably seems pretty abstract to you right now. But let us try to figure out the Maclaurin series for some example functions for which the nnth derivative is fairly easy to calculate. Say, for instance, we calculate the Maclaurin series for exe^x. Why exe^x? Because the nnth derivative of exe^x is just exe^x, and evaluating this at x=0x=0 yields 1. Hence:

ex=∑n=0∞xnn!\begin{align} e^x &= \sum_{n=0}^{\infty} \dfrac{x^n}{n!} \tag{5} \end{align}
is the Maclaurin series of exe^x. Okay, let us try our hand at another function's Maclaurin series. How about cos⁡x\cos{x}? We know the first derivative of cos⁡x\cos{x} is −sin⁡x-\sin{x}. Hence the second derivative is −cos⁡x-\cos{x}. The third derivative would be sin⁡x\sin{x}. Fourth derivative would be cos⁡x\cos{x}. Fifth derivative would be −sin⁡x-\sin{x} and sixth derivative would be −cos⁡x-\cos{x}. Well, I have noticed a pattern here! Seems to me like (−1)⌊n+12⌋(-1)^{\lfloor\frac{n+1}{2}\rfloor} (where ⌊...⌋\lfloor ... \rfloor rounds down decimals, e.g. it would take 3.6 and return 3) will recreate the sign of this function. If nn is even, the trigonometric function will be cos⁡x\cos{x} and if it is odd it will be sin⁡x\sin{x}. Evaluating these functions at x=0x=0, we see that if nn is even we will get 11 from the trigonometric function and 0 if nn is odd. Hence:

dnfdxn∣x=0={(−1)⌊n+12⌋neven0nodd.\begin{aligned} \dfrac{d^nf}{dx^n}\Big|_{x=0} &= \begin{cases} (-1)^{\lfloor\frac{n+1}{2}\rfloor} & n\hspace{0.1cm}\mathrm{even} \\ 0 & n \hspace{0.1cm}\mathrm{odd}. \end{cases} \end{aligned}
So our sum will essentially just be over even numbers. One way we can denote a sum over even numbers is by replacing nn with 2n2n and summing over all numbers. As 22 times any integer is always an even number. In this event, our (−1)⌊n+12⌋(-1)^{\lfloor\frac{n+1}{2}\rfloor} becomes:

(−1)⌊2n+12⌋=(−1)⌊2n+12⌋=(−1)⌊n+12⌋=(−1)n.\begin{align} (-1)^{\lfloor\frac{2n+1}{2}\rfloor} &=(-1)^{\lfloor\frac{2n+1}{2}\rfloor} \notag \\ &= (-1)^{\lfloor n+\frac{1}{2}\rfloor} \notag \\ &= (-1)^{n}. \tag{6} \end{align}
We arrived at Equation (6) simply because nn is an integer so adding a half to it should make no difference when we are rounding down. Consequently, our Maclaurin series becomes:

cos⁡x=∑n=0∞(−1)nx2n(2n)!\begin{aligned} \cos{x} &= \sum_{n=0}^{\infty} \dfrac{(-1)^n x^{2n}}{(2n)!} \end{aligned}

So here is some homework for you: try constructing the Maclaurin series for sin⁡x\sin{x}. You should arrive at:

sin⁡x=∑n=0∞(−1)nx2n+1(2n+1)!.\begin{aligned} \sin{x} &= \sum_{n=0}^{\infty} \dfrac{(-1)^nx^{2n+1}}{(2n+1)!}. \end{aligned}

As another example, we will find the Maclaurin series for ln⁡(x+1)\ln{(x+1)} so we can see why it only converges well for ∣x∣<−1|x| < -1 where ∣x∣|x| is the absolute value of xx. The first derivative is 1x+1\dfrac{1}{x+1}. Second derivative is −1(x+1)2-\dfrac{1}{(x+1)^2}. Third derivative is 2(x+1)3\dfrac{2}{(x+1)^3}. Fourth derivative is −6(x+1)4-\dfrac{6}{(x+1)^4}. So it seems to me that the pattern is that the numerator is (−1)n−1(n−1)!(-1)^{n-1} (n-1)! and the denominator is (x+1)n(x+1)^n. Hence:

dndxnln⁡(x+1)=(−1)n−1(n−1)!(x+1)n,n≥1.\begin{align} \dfrac{d^n}{dx^n} \ln{(x+1)} &= \dfrac{(-1)^{n-1}(n-1)!}{(x+1)^n}, \hspace{0.1cm} n \geq 1. \tag{7} \end{align}
And:
dndxnln⁡(x+1)∣x=0=(−1)n−1(n−1)!,n≥1.\begin{align} \dfrac{d^n}{dx^n} \ln{(x+1)} \Big|_{x=0} &= (-1)^{n-1}(n-1)!, \hspace{0.1cm} n \geq 1. \tag{8} \end{align}
Hence our Maclaurin series is:
ln⁡(x+1)=ln⁡1+∑n=1∞(−1)n−1(n−1)!xnn!=∑n=1∞(−1)n−1xnn.\begin{align} \ln{(x+1)} &= \ln{1} + \sum_{n=1}^{\infty} \dfrac{(-1)^{n-1}(n-1)! x^n}{n!} \tag{9} \\ &= \sum_{n=1}^{\infty} \dfrac{(-1)^{n-1}x^n}{n}. \tag{10} \end{align}
If ∣x∣>1|x|>1, we would expect the power of xx in our numerator to potentially grow faster than nn and hence our terms could become progressively larger as n→∞n\rightarrow \infty. As for if x=±1x=\pm 1, well our numerator would be smaller than our denominator, but our denominator would grow rather slowly, which means we would have to calculate a lot of terms to figure out what value it ends up equalling, assuming it does converge. If x=1x=1, we get:
ln⁡2=∑n=1∞(−1)n−1n.\begin{align} \ln{2} &= \sum_{n=1}^{\infty} \dfrac{(-1)^{n-1}}{n}. \tag{11} \end{align}
Which is actually true. As this sum does, indeed, equal ln⁡2\ln{2}. But because the denominator grows very slowly, we would need a lot of terms in the series in order to get a good approximation for what it equals. If x=−1x=-1, then we get:
ln⁡0=∑n=1∞(−1)n−1(−1)nn=−∑n=1∞1n.\begin{align} \ln{0} &= \sum_{n=1}^{\infty} \dfrac{(-1)^{n-1} (-1)^{n}}{n} \tag{12} \\ &= -\sum_{n=1}^{\infty} \dfrac{1}{n}. \tag{13} \end{align}
This sum does not converge, hence it actually equals ∞\infty. Hence why ∣x∣<1|x| < 1 is a requirement for this Maclaurin series to converge, or at least converge at a reasonable pace, although it does also converge, albeit slowly, for x=1x=1.

Maclaurin and Taylor series have broad applications in physics. One application they have is in helping us connect more general and robust laws of physics to older approximations. For more on this, see the section on the classical limit of special relativity's kinetic energy.

Complex numbers

Complex numbers are numbers that involve both a real and an imaginary part. That is, they are of the form a+bia+bi where aa and bb are both real numbers and ii is the imaginary number. aa is called the real part of the number and bb is called the imaginary part of the number. Importantly, aa and bb can be zero, consequently all real numbers are technically complex numbers. We can display complex numbers in the complex plane (also known as the Argand plane) as vectors. Specifically, the yy component of this vector is the imaginary part of our number and the xx component is the real part of the number.

Number 2+3i displayed in the complex plane.

Figure shows the number 2+3i2+3i displayed in the complex plane. The length of the vector, ll, can be calculated using the Pythagorean theorem as l=22+32=13l=\sqrt{2^2+3^2}=\sqrt{13}. ll can also be called the modulus of our complex number. As for θ\theta, the angle from the positive xx-axis measure counterclockwise it can be found using the definition of the tangent function as θ=tan⁡−132\theta =\tan^{-1}{\dfrac{3}{2}}. Note also that 3=lsin⁡θ3=l\sin{\theta} and 2=lcos⁡θ2=l\cos{\theta} by the definition of these trigonometric functions.

Interestingly, these two qualities, the length of the complex number's vector and its angle, measured counterclockwise from the positive xx-axis, can be used to uniquely define it. To see how, I must first share with you an interesting quality of the exponential function. Namely, that:

eiz=cos⁡z+isin⁡z.\begin{aligned} e^{iz} &= \cos{z} + i\sin{z}. \end{aligned}
Why is this the case? Replacing xx with iziz in Equation (5) yields:
eiz=∑n=0∞(iz)nn!.\begin{aligned} e^{iz} &= \sum_{n=0}^{\infty} \dfrac{(iz)^n}{n!}. \end{aligned}
You may be thinking, so what? Well, powers of ii have interesting properties. Namely, i0=1i^0=1, i1=ii^1=i, i2=−1i^2=-1, i3=−ii^3=-i and i4=1i^4=1. Generally, i4ni^{4n} (where nn is an integer) is equal to 11, i4n+1i^{4n+1} is ii, i4n+2i^{4n+2} is −1-1 and i4n+3i^{4n+3} is −i-i. Focusing on even powers, we find that i2n=(−1)ni^{2n}=(-1)^n (where makes sense as i2=−1i^2=-1 and i2n=(i2)ni^{2n}=(i^2)^n). Whereas odd powers yields i2n+1=(−1)nii^{2n+1}=(-1)^n i. Consequently:
eiz=∑n=0∞(−1)nz2n(2n)!+(−1)niz2n+1(2n+1)!=∑n=0∞(−1)nz2n(2n)!+∑n=0∞(−1)niz2n+1(2n+1)!=∑n=0∞(−1)nz2n(2n)!+i∑n=0∞(−1)nz2n+1(2n+1)!.\begin{aligned} e^{iz} &= \sum_{n=0}^{\infty} \dfrac{(-1)^n z^{2n}}{(2n)!} + \dfrac{(-1)^n iz^{2n+1}}{(2n+1)!} \\ &= \sum_{n=0}^{\infty} \dfrac{(-1)^n z^{2n}}{(2n)!} + \sum_{n=0}^{\infty} \dfrac{(-1)^n iz^{2n+1}}{(2n+1)!} \\ &= \sum_{n=0}^{\infty} \dfrac{(-1)^n z^{2n}}{(2n)!} + i\sum_{n=0}^{\infty} \dfrac{(-1)^n z^{2n+1}}{(2n+1)!}. \end{aligned}
The first of these sums we can recognize as cos⁡z\cos{z} whereas the second is sin⁡z\sin{z}. Hence:
eiz=cos⁡z+isin⁡z.\begin{aligned} e^{iz} &= \cos{z} + i\sin{z}. \end{aligned}
An interesting thing to note that eize^{iz} is that its modulus is one. How do I know this? Well, the modulus is defined as just the length of the complex number's vector in the complex plane, right? So for eize^{iz} that would be:
l=cos⁡2z+sin⁡2z=1=1.\begin{aligned} l &= \sqrt{\cos^2{z}+\sin^2{z}} \\ &= \sqrt{1} \\ &= 1. \end{aligned}
Here I used the trigonometric identity:
cos⁡2z+sin⁡2z=1∀z∈R.\begin{align} \cos^2{z}+\sin^2{z}=1 \hspace{0.1cm} \forall z \in \mathbb{R}. \tag{14} \end{align}
Where R\mathbb{R} is the set of real numbers. Okay, so getting back to how ll and θ\theta can uniquely define a complex number. Well, interestingly you can write any complex number in the form leiθle^{i\theta}. Why? Well, recall that eiθe^{i\theta} is just cos⁡θ+isin⁡θ\cos{\theta}+i\sin{\theta}. Looking at Figure we can clearly see that the xx component of our vector is just lcos⁡θl\cos{\theta}, right? And we can also see that the yy component is just lsin⁡θl\sin{\theta} and if we expand our leiθle^{i\theta} we get:
leiθ=lcos⁡θ+isin⁡θ.\begin{aligned} le^{i\theta} &= l\cos{\theta} + i\sin{\theta}. \end{aligned}
Hence leiθ=x+iyle^{i\theta} = x+iy. For instance, for the complex number 2+3i2+3i we can rewrite it as:
2+3i=13eitan⁡−132.\begin{aligned} 2+3i &= \sqrt{13}e^{i\tan^{-1}{\frac{3}{2}}}. \end{aligned}

Complex analysis

I have definitely not covered everything within the field of complex numbers. There's a field of maths known as complex analysis where we combine calculus and complex numbers. In it, we learn, among other things, how to integrate along curves (or contours) in the complex plane and that there is an extension of Taylor series to the complex plane called the Laurent series. In it, we write:

f(z)=∑n=−∞∞an(z−z0)n\begin{align} f(z) &= \sum_{n=-\infty}^{\infty} a_n (z-z_0)^n \tag{15} \end{align}
where:
an=12πi∮Cf(z)(z−z0)n+1dz.\begin{align} a_n &= \dfrac{1}{2\pi i} \oint_C \dfrac{f(z)}{(z-z_0)^{n+1}} dz. \tag{16} \end{align}
This is a contour integral over a curve CC that includes the point z=z0z=z_0. z0z_0 is analogous to the aa in our Taylor series as it is arbitrary. There's a formula called Cauchy's differentiation formula that says that:
f(n)(z0)=n!2πi∮Cf(z)(z−z0)n+1dz,n∈{0,1,2,...}.\begin{align} f^{(n)}(z_0) &= \dfrac{n!}{2\pi i} \oint_C \dfrac{f(z)}{(z-z_0)^{n+1}} dz, \hspace{0.1cm}n \in \{0, 1, 2, ...\}. \tag{17} \end{align}
Where f(n)(z0)f^{(n)}(z_0) is the nnth derivative of f(z)f(z) evaluated at z=z0z=z_0. Which helps us see how the Laurent series is connected to the Taylor series as for non-negative nn, an=f(n)(z0)n!a_n = \dfrac{f^{(n)}(z_0)}{n!}. As for negative nn, an=0a_n=0 if f(z)f(z) is defined everywhere in the complex plane. Why do I mention this? Well, I personally consider complex analysis one of the most beautiful fields of mathematics and I thought I would mention it in case you are ever in a position to take a complex analysis class while at university.

Partial derivatives

Partial derivatives are just a straightforward extension of derivatives as you understand them already. The key difference is that they are derivatives of multivariable functions instead of single-variable functions. Further, when you differentiate with respect to one variable, all other variables are kept constant. If you would like to build a graphical image of what the partial derivative is, well recall that the derivative of a single-variable function is just the gradient of that function. Consequently, it is also the gradient of the tangent line to that function. The partial derivative is similar to that. As when we have a function with more than a single independent variable, we have the freedom to choose which variable or variables we wish to determine our function's gradient with respect to.

If you want to visualize this, imagine a surface defined by z=f(x,y)z=f(x,y) for example. Because a tangent line is two dimensional and we're in three dimensional space, there can be more than one tangent line to a given point. As when constructing the tangent line, we must answer a question: in which direction do we want our line to be tangential to our surface? It could be tangential in the xx direction or the yy direction, or even in any arbitrary direction in the xyxy plane. If we want the tangent line in the xx direction, we will need the partial derivative with respect to xx to get its gradient, whereas if we want the tangent line in the yy direction, we will need the partial derivative with respect to yy to get its gradient. More generally, for an arbitrary direction in the xyxy plane we would use the directional derivative as it is called.

Say ff is a function of two variables — xx and yy. Then its partial derivative with respect to xx is formally defined as:

∂f∂x=deflim⁡h→0f(x+h,y)−f(x,y)h.\begin{aligned} \dfrac{\partial f}{\partial x} &\stackrel{\text{def}}{=} \lim_{h\rightarrow 0} \dfrac{f(x+h, y)-f(x, y)}{h}. \end{aligned}

This is analogous to the first principles definition of the derivative you would have learned for standard derivatives. Namely, if we are differentiating f(x)f(x):

dfdx=lim⁡h→0f(x+h)−f(x)h.\begin{aligned} \dfrac{df}{dx} &= \lim_{h\rightarrow 0}\dfrac{f(x+h) - f(x)}{h}. \end{aligned}
The only difference is that now we also have a variable yy that our function f(x,y)f(x,y) depends on, but is kept constant when differentiating with respect to xx. Say f(x,y)=2x2yf(x,y)=2x^2y. Then ∂f∂x\dfrac{\partial f}{\partial x} would be:
∂f∂x=lim⁡h→02(x+h)2y−2x2yh.\begin{aligned} \dfrac{\partial f}{\partial x} &= \lim_{h\rightarrow 0} \dfrac{2(x+h)^2y - 2x^2y}{h}. \end{aligned}
Did you notice that 2y2y is a common factor of both terms in our numerator? Let us take it out of our limit altogether, as it is effectively a constant (it does not depend on hh, after all).

∂f∂x=2ylim⁡h→0(x+h)2−x2h\begin{aligned} \dfrac{\partial f}{\partial x} &= 2y\lim_{h\rightarrow 0} \dfrac{(x+h)^2-x^2}{h} \end{aligned}
Using the binomial theorem, we know that
(x+h)2=x2+2xh+h2.\begin{aligned} (x+h)^2 &= x^2 + 2xh + h^2. \end{aligned}

Hence:

∂f∂x=2ylim⁡h→0x2+2xh+h2−x2h=2ylim⁡h→02xh+h2h=2ylim⁡h→02x+h=2y⋅2x=4xy.\begin{aligned} \dfrac{\partial f}{\partial x} &= 2y\lim_{h\rightarrow 0} \dfrac{x^2+2xh + h^2-x^2}{h} \\ &= 2y\lim_{h\rightarrow 0} \dfrac{2xh + h^2}{h} \\ &= 2y\lim_{h\rightarrow 0} 2x + h \\ &= 2y \cdot 2x \\ &= 4xy. \end{aligned}
Okay, so that is the long way of finding out partial derivatives. Fortunately, there is also a faster way. Which is that we apply normal differentiation rules, but any variable we are not differentiating with respect to is treated like it is a constant. So for f(x,y)=2x2yf(x,y)=2x^2y we would treat the 2y2y as just a constant number and only differentiate the x2x^2. Applying the power rule, we see that ddxx2=2x\dfrac{d}{dx}x^2 = 2x and hence:
∂f∂x=2y⋅2x=4xy.\begin{aligned} \dfrac{\partial f}{\partial x} &= 2y \cdot 2x \\ &= 4xy. \end{aligned}

Heat equation

One of the simplest partial differential equations is the heat equation. In its simplest form it is:

∂u∂t=α∂2u∂x2\begin{align} \dfrac{\partial u}{\partial t} &= \alpha \dfrac{\partial^2 u}{\partial x^2} \tag{18} \end{align}
Where u(x,t)u(x,t) is a function describing the temperature of the one-dimensional object (only one dimensional as the above heat equation only has a single spatial dimension, if we want more spatial dimensions we'll have to add second partial derivatives with respect to those other dimensions, too) we're modelling and α\alpha is some constant. I know this equation may look confusing at first glance, but it is actually saying something rather intuitive to you.

Do you remember from your maths class that the second derivative of a function is its concavity? So if the second derivative is negative, that means our function is concave down — it is leading to some sort of maximum. Whereas if it is positive, the function is concave up, which means it is going up from some minimum. We have the second derivative with respect to space on the right-hand side of Equation (18), so it essentially returns positive if we have a localized colder area and neighbouring hotter points. Whereas it returns negative if we have a really hot point surrounded by cooler points. The left-hand side of Equation (18), however, represents the rate of change of our function in time.

Equation (18) therefore essentially says that if we are in a region where there is a really cold point surrounded by hotter points, the temperature will increase in the short-term for that colder point. Whereas the equation says that the temperature will decrease in a hotter region surrounded by colder points. If you've ever brought something hot out of the oven, or put something of room temperature into the fridge or freezer, this should make intuitive sense to you.

Lagrangian mechanics

Lagrangian mechanics is one of three major formulations of classical mechanics with the others being Newtonian mechanics and Hamiltonian mechanics. Classical mechanics as a whole is a branch of physics most applicable to the situations that humans most often encounter, as it does not account for quantum randomness (hence cannot be applied to very small scales), nor does it account for relativistic effects (which are most relevant when dealing with strong gravitational fields or velocities close to the speed of light). In Lagrangian mechanics, we define a quantity known as the Lagrangian of our physical system:

L=defT−V.\begin{align} L &\stackrel{\text{def}}{=} T - V. \tag{19} \end{align}
Where TT is kinetic energy and VV is potential energy of our entire physical system. It is important to note that only conservative forces contribute to VV. Lagrangian mechanics can account for non-conservative (i.e. dissipative) forces, too, but we will get to how one handles them later.

The distinction between conservative and non-conservative forces is whether they change the net energy of your system. For instance, gravity does not because any increase in kinetic energy it causes is balanced by a corresponding reduction in potential energy. Likewise, any loss of kinetic energy caused by gravity is balanced by an increase in potential energy. Consequently, it is a conservative force. Air resistance, however, is a non-conservative force because the losses it causes in kinetic energy are not balanced by increases in potential energy.

Euler-Lagrange equations

When there are no non-conservative forces, the equations of motion can be derived by first determining our system's Lagrangian and then applying a set of partial differential equations known as the Euler-Lagrange equations to this Lagrangian. The Euler-Lagrange equations are:

ddt∂L∂q˙i−∂L∂qi=0,i∈{1,2,3,...,n}.\begin{align} \hspace{4cm}\dfrac{d}{dt} \dfrac{\partial L}{\partial \dot{q}_i} - \dfrac{\partial L}{\partial q_i} &= 0, \hspace{2cm} i\in \{1,2,3,...,n\}. \tag{20} \end{align}
qiq_i are the nn degrees of freedom (or generalized coordinates) of our problem and q˙i\dot{q}_i are their time derivatives (or the generalized velocities). The ddt\dfrac{d}{dt} is not a partial derivative and this is purposeful, as when we differentiate ∂L∂q˙i\dfrac{\partial L}{\partial \dot{q}_i} with respect to tt, we treat qiq_i and q˙i\dot{q}_i as functions of tt and wherever they appear in ∂L∂q˙i\dfrac{\partial L}{\partial \dot{q}_i} we differentiate them against tt.

Next, I should explain what "degrees of freedom" are. They are essentially our variables of interest. For simpler problems, the degrees of freedom in our problem are often the spatial dimensions of our problem. For instance, if we were to study an object in free fall and we were to try to simplify our problem as much as possible and not consider any movement in the horizontal directions then nn could be 1 and q1q_1 would just be the height of the object above ground level.

Likewise, when we study the simple pendulum — which is a problem in which we have an idealized rigid pendulum whose rod has zero mass, zero friction and for which there is absolutely no air resistance — typically we only consider a single degree of freedom, which is the angle our pendulum's rod makes with either the negative yy axis or the positive xx axis, depending on the preferences of whoever is setting up the problem.

Derivation of Equations (20)

Some of the paths a system could take.
The derivation of Equations (20) requires knowledge of a field of mathematics known as the calculus of variations as well as a physics principle known as the stationary action principle. I will provide my own derivation here; although, I would suggest checking out Veritasium's video on this topic (https://www.youtube.com/watch?v=Q10_srZ-pbs) as it provides a more accessible introduction to this topic.

There is a quantity known as the action — which is denoted as SS — that is defined as:

S=def∫t0tfL(qi,q˙i,t)dt.\begin{align} S &\stackrel{\text{def}}{=} \int_{t_0}^{t_f} L(q_i, \dot{q}_i, t) dt. \tag{21} \end{align}

One interesting property of the action is that nature consistently sets it to its stationary point, and this is regardless of context. Regardless of whether we are examining the motion of planets with Newton's second law, or studying the behaviour of black holes with general relativity, or checking out the behaviour of subatomic particles, there is always an action that is at its stationary point. Traditionally, this stationary point is typically thought of as a minimum (hence why this is also known as the principle of least action), but strictly speaking it is not always a minimum.

Of all the paths that an object could explore, the one that it actually explores is the one that sets the action to its stationary point. Figure provides some example paths that we examine when applying the principle of stationary action. In the terminology of the calculus of variations, we can express the fact the action is at its stationary point as:

δS=0.\begin{align} \delta S &= 0. \tag{22} \end{align}
This is analogous to saying, in regular calculus, that our function's first derivative is zero. Which, as you may remember from your maths classes, is an equation we can solve to find the stationary point(s) of our function.

Say we add functions δqi\delta q_i to qiq_i, thereby adjusting the path our object takes. Crucially, however, the end times and end points of our path will be unchanged. The new, adjusted action we will denote by S′S' and it is:

S′=∫t0tfL(qi+δqi,q˙i+δq˙i,t)dt≈∫t0tfL(qi,q˙i,t)+∑i=1n∂L∂qiδqi+∂L∂q˙iδq˙idt.\begin{aligned} S' &= \int_{t_0}^{t_f} L(q_i+\delta q_i, \dot{q}_i+\delta \dot{q}_i, t) dt \\ &\approx \int_{t_0}^{t_f} L(q_i, \dot{q}_i, t) + \sum_{i=1}^n\dfrac{\partial L}{\partial q_i} \delta q_i + \dfrac{\partial L}{\partial \dot{q}_i}\delta \dot{q}_i dt. \end{aligned}

Next, we will apply integration by parts to the ∂L∂q˙iδq˙i\dfrac{\partial L}{\partial \dot{q}_i}\delta \dot{q}_i term:

S′≈∫t0tfL(qi,q˙i,t)+∑i=1n∂L∂qiδqidt+[∑i=1n∂L∂q˙iδqi]t0tf−∫t0tf∑i=1nddt∂L∂q˙iδqidt.\begin{aligned} S' &\approx \int_{t_0}^{t_f} L(q_i, \dot{q}_i, t) + \sum_{i=1}^n\dfrac{\partial L}{\partial q_i} \delta q_i dt + \left[\sum_{i=1}^n\dfrac{\partial L}{\partial \dot{q}_i}\delta q_i\right]_{t_0}^{t_f} - \int_{t_0}^{t_f} \sum_{i=1}^n\dfrac{d}{dt} \dfrac{\partial L}{\partial \dot{q}_i}\delta q_i dt. \end{aligned}
At the end times of our path, δqi\delta q_i should be zero, as the endpoints are fixed. Hence the term [∂L∂q˙iδqi]t0tf\left[\dfrac{\partial L}{\partial \dot{q}_i}\delta q_i\right]_{t_0}^{t_f} should evaluate to zero. Our expression then simplifies to:
S′≈∫t0tfL(qi,q˙i,t)+∑i=1n∂L∂qiδqidt+[∑i=1n∂L∂q˙iδqi]t0tf−∫t0tf∑i=1nddt∂L∂q˙iδqidt≈∫t0tfL(qi,q˙i,t)+∑i=1nδqi(∂L∂qi−ddt∂L∂q˙i)dt.\begin{aligned} S' &\approx \int_{t_0}^{t_f} L(q_i, \dot{q}_i, t) + \sum_{i=1}^n\dfrac{\partial L}{\partial q_i} \delta q_i dt + \left[\sum_{i=1}^n\dfrac{\partial L}{\partial \dot{q}_i}\delta q_i\right]_{t_0}^{t_f} - \int_{t_0}^{t_f} \sum_{i=1}^n\dfrac{d}{dt} \dfrac{\partial L}{\partial \dot{q}_i}\delta q_i dt \\ &\approx \int_{t_0}^{t_f} L(q_i, \dot{q}_i, t) + \sum_{i=1}^n\delta q_i \left(\dfrac{\partial L}{\partial q_i} - \dfrac{d}{dt} \dfrac{\partial L}{\partial \dot{q}_i}\right) dt. \end{aligned}
The first of these terms is present in SS, too. Hence:
S′−S≈∫t0tf∑i=1nδqi(∂L∂qi−ddt∂L∂q˙i)dt.\begin{aligned} S' - S &\approx \int_{t_0}^{t_f}\sum_{i=1}^n\delta q_i \left(\dfrac{\partial L}{\partial q_i} - \dfrac{d}{dt} \dfrac{\partial L}{\partial \dot{q}_i}\right) dt. \end{aligned}
We can denote this first-order approximation to how much SS changes as δS\delta S. Hence:
δS=∫t0tf∑i=1nδqi(∂L∂qi−ddt∂L∂q˙i)dt.\begin{align} \delta S &= \int_{t_0}^{t_f} \sum_{i=1}^n\delta q_i \left(\dfrac{\partial L}{\partial q_i} - \dfrac{d}{dt} \dfrac{\partial L}{\partial \dot{q}_i}\right) dt. \tag{23} \end{align}
Hence δS\delta S will equal zero irrespective of δqi\delta q_i if and only if Equations (20) hold. Hence from setting δS=0\delta S=0 we get the Euler-Lagrange equations.

Terminology

In Equation (20):

pi=def∂L∂q˙i\begin{align} p_i \stackrel{\text{def}}{=} \dfrac{\partial L}{\partial \dot{q}_i} \tag{24} \end{align}
is known as the canonical (or generalized) momentum. It becomes especially relevant later when we cover Hamiltonian mechanics.

Non-conservative forces

I guess next I should explain how we account for non-conservative forces. Essentially we replace the 00 in Equations (20) with the generalized force QiQ_i. It is defined as:

Qi=def∑j=1mFj⋅∂rj∂qi.\begin{align} Q_i &\stackrel{\text{def}}{=} \sum_{j=1}^m \textbf{F}_j \cdot \dfrac{\partial \textbf{r}_j}{\partial q_i}. \tag{25} \end{align}
Where Fj\textbf{F}_j represents the vector of the jjth non-conservative force we wish to account for in our equations of motion. As you can see by the summation bounds, we have mm non-conservative forces we wish to account for. rj\textbf{r}_j is the position vector for force jj. Fj⋅∂rj∂qi\textbf{F}_j\cdot\dfrac{\partial \textbf{r}_j}{\partial q_i} denotes the dot product between Fj\textbf{F}_j and ∂rj∂qi\dfrac{\partial \textbf{r}_j}{\partial q_i}. Alternatively, to calculate QiQ_i we can use velocities instead of positions:
Qi=def∑j=1mFj⋅∂r˙j∂q˙i.\begin{align} Q_i &\stackrel{\text{def}}{=} \sum_{j=1}^m \textbf{F}_j \cdot \dfrac{\partial \dot{\textbf{r}}_j}{\partial \dot{q}_i}. \tag{26} \end{align}
r˙j\dot{\textbf{r}}_j is the time derivative of the position vector (that is, the velocity vector) for force jj. Hence the more generalized form of Equations (20) is:
ddt∂L∂q˙i−∂L∂qi=∑j=1mFj⋅∂rj∂qi,i∈{1,2,3,...,n}.\begin{align} \hspace{4cm}\dfrac{d}{dt} \dfrac{\partial L}{\partial \dot{q}_i} - \dfrac{\partial L}{\partial q_i} &= \sum_{j=1}^m \textbf{F}_j \cdot \dfrac{\partial \textbf{r}_j}{\partial q_i}, \hspace{2cm} i\in\{1,2,3,...,n\}. \tag{27} \end{align}
The velocity-based definition of QiQ_i can also be used, which yields:
ddt∂L∂q˙i−∂L∂qi=∑j=1mFj⋅∂r˙j∂q˙i,i∈{1,2,3,...,n}.\begin{align} \hspace{4cm}\dfrac{d}{dt} \dfrac{\partial L}{\partial \dot{q}_i} - \dfrac{\partial L}{\partial q_i} &= \sum_{j=1}^m \textbf{F}_j \cdot \dfrac{\partial \dot{\textbf{r}}_j}{\partial \dot{q}_i}, \hspace{2cm} i\in\{1,2,3,...,n\}. \tag{28} \end{align}

Example: single pendulum

Single pendulum.
So to punctuate how one applies Equations (20) and (27), I thought I would give you a nice, simple example: the single pendulum.

Without air resistance

To apply Equations (20), we will treat it as a simple pendulum with no friction, a massless rod and no air resistance. The pendulum will consist of a rod with a bob at one end and freely rotating around a central point. We will define this central point as being the origin in Cartesian coordinates. Say the rod is of fixed length ll metres. The pendulum bob will be of mass mm kilograms. As you can see in Figure , we have defined θ\theta as the angle between the rod and the positive xx-axis going counter-clockwise. Hence the xx and yy coordinates of the pendulum bobs are:

x=lcos⁡θy=lsin⁡θ.\begin{aligned} x &= l\cos{\theta} \\ y &= l\sin{\theta}. \end{aligned}
Hence:
x˙=−lθ˙sin⁡θy˙=lθ˙cos⁡θ.\begin{aligned} \dot{x} &= -l\dot{\theta}\sin{\theta} \\ \dot{y} &= l\dot{\theta}\cos{\theta}. \end{aligned}
As for velocity squared, it is defined as:
v2=x˙2+y˙2=l2θ˙2sin⁡2θ+l2θ˙2cos⁡2θ=l2θ˙2.\begin{aligned} v^2 &= \dot{x}^2+\dot{y}^2 \\ &= l^2\dot{\theta}^2\sin^2{\theta} + l^2\dot{\theta}^2\cos^2{\theta} \\ &= l^2\dot{\theta}^2. \end{aligned}
Hence v=lθ˙v=l\dot{\theta}. The kinetic energy is:
T=mv22=ml2θ˙22.\begin{aligned} T &= \dfrac{mv^2}{2} \\ &= \dfrac{ml^2\dot{\theta}^2}{2}. \end{aligned}
As for potential energy, given this bob is moving solely under the force of gravity:
V=mgy=mglsin⁡θ.\begin{aligned} V &= mgy \\ &= mgl\sin{\theta}. \end{aligned}
Hence:
L=T−V=ml2θ˙22−mglsin⁡θ.\begin{aligned} L &= T - V \\ &= \dfrac{ml^2\dot{\theta}^2}{2} - mgl\sin{\theta}. \end{aligned}
∂L∂θ˙\dfrac{\partial L}{\partial \dot{\theta}} is hence:
∂L∂θ˙=ml2θ˙.\begin{aligned} \dfrac{\partial L}{\partial \dot{\theta}} &= ml^2 \dot{\theta}. \end{aligned}
And its time derivative is:
ddt∂L∂θ˙=ml2θ¨.\begin{aligned} \dfrac{d}{dt}\dfrac{\partial L}{\partial \dot{\theta}} = ml^2 \ddot{\theta}. \end{aligned}
As for the ∂L∂θ\dfrac{\partial L}{\partial \theta} term it is:
∂L∂θ=−mglcos⁡θ.\begin{aligned} \dfrac{\partial L}{\partial \theta} &= -mgl\cos{\theta}. \end{aligned}
So Equations (20) becomes:
ml2θ¨+mglcos⁡θ=0.\begin{aligned} ml^2 \ddot{\theta} + mgl\cos{\theta} &= 0. \end{aligned}
Dividing by ml2ml^2 and taking the second term to the right-hand side yields:
θ¨=−glcos⁡θ.\begin{align} \ddot{\theta} &= -\dfrac{g}{l}\cos{\theta}. \tag{29} \end{align}
Equation (29) has, as its highest order derivative, a second-order derivative. It also only involves ordinary derivatives (not partial derivatives). Hence it is a second-order ordinary differential equation (ODE). Second-order ODEs are typically obtained in both Newtonian and Lagrangian mechanics. The number of second-order ODEs obtained for a given system depends on the number of degrees of freedom of the system.

Technically speaking it is possible to analytically solve Equation (29), but it requires the use of non-standard functions called elliptic integrals. If you would like to check out numerical solutions to this equation, see this page.

With air resistance

For the sake of simplicity, we will only consider the air resistance experienced by the pendulum bob itself, not by the rod. The air resistance force vector for the pendulum bob would be:

FD=−ρCDA∣v∣v2.\begin{aligned} \textbf{F}_D &= -\dfrac{\rho C_D A|v|\textbf{v}}{2}. \end{aligned}
Where v\textbf{v} is the velocity vector of the bob. It is equal to (x˙,y˙)(\dot{x}, \dot{y}). Hence:
FD=−ρCDAl∣θ˙∣2(x˙,y˙)=−ρCDAl∣θ˙∣2(−lθ˙sin⁡θ,lθ˙cos⁡θ)=ρCDAl2∣θ˙∣θ˙2(sin⁡θ,−cos⁡θ).\begin{aligned} \textbf{F}_D &= -\dfrac{\rho C_D Al|\dot{\theta}|}{2}(\dot{x}, \dot{y}) \\ &= -\dfrac{\rho C_D Al|\dot{\theta}|}{2} (-l\dot{\theta}\sin{\theta}, l\dot{\theta}\cos{\theta}) \\ &= \dfrac{\rho C_D Al^2|\dot{\theta}|\dot{\theta}}{2} (\sin{\theta}, -\cos{\theta}). \end{aligned}
To find the generalized force term, we need to find ∂r∂θ\dfrac{\partial \textbf{r}}{\partial \theta}:
∂r∂θ=(∂x∂θ,∂y∂θ)=(−lsin⁡θ,lcos⁡θ).\begin{aligned} \dfrac{\partial \textbf{r}}{\partial \theta} &= \left(\dfrac{\partial x}{\partial \theta}, \dfrac{\partial y}{\partial \theta}\right) \\ &= (-l\sin{\theta}, l\cos{\theta}). \end{aligned}
Hence:
Qθ=FD⋅∂r∂θ=ρCDAl2∣θ˙∣θ˙2(sin⁡θ,−cos⁡θ)⋅(−lsin⁡θ,lcos⁡θ)=ρCDAl2∣θ˙∣θ˙2(−lsin⁡2θ−lcos⁡2θ)=−ρCDAl3∣θ˙∣θ˙2.\begin{aligned} Q_{\theta} &= \textbf{F}_D \cdot \dfrac{\partial \textbf{r}}{\partial \theta} \\ &= \dfrac{\rho C_D Al^2|\dot{\theta}|\dot{\theta}}{2} (\sin{\theta}, -\cos{\theta}) \cdot (-l\sin{\theta}, l\cos{\theta}) \\ &= \dfrac{\rho C_D Al^2|\dot{\theta}|\dot{\theta}}{2}(-l\sin^2{\theta}-l\cos^2{\theta}) \\ &= -\dfrac{\rho C_D Al^3|\dot{\theta}|\dot{\theta}}{2}. \end{aligned}
Hence Equations (27) become:
ml2θ¨+mglcos⁡θ=−ρCDAl3∣θ˙∣θ˙2.\begin{aligned} ml^2 \ddot{\theta} + mgl\cos{\theta} &= -\dfrac{\rho C_D Al^3|\dot{\theta}|\dot{\theta}}{2}. \end{aligned}
Dividing by ml2ml^2 yields:
θ¨+glcos⁡θ=−ρCDAl∣θ˙∣θ˙2m.\begin{aligned} \ddot{\theta} + \dfrac{g}{l}\cos{\theta} &= -\dfrac{\rho C_D Al|\dot{\theta}|\dot{\theta}}{2m}. \end{aligned}
Subtracting glcos⁡θ\dfrac{g}{l}\cos{\theta} from both sides yields:
θ¨=−glcos⁡θ−ρCDAl∣θ˙∣θ˙2m.\begin{aligned} \ddot{\theta} &= -\dfrac{g}{l}\cos{\theta} -\dfrac{\rho C_D Al|\dot{\theta}|\dot{\theta}}{2m}. \end{aligned}
This equation cannot be analytically solved, so numerical solutions are necessary. I numerically solve an even more complex version of the single pendulum equation here.

If you would like to see my derivation of the double rigid pendulum equations, it is here.

Hamiltonian mechanics

In Hamiltonian mechanics, we define the Hamiltonian as:

H=T+V.\begin{align} H &= T + V. \tag{30} \end{align}
Which is the total energy of our system. I should say that this is usually the form of the Hamiltonian, more generally it is defined as:
H=def∑i=1npiq˙i−L.\begin{align} H &\stackrel{\text{def}}{=} \sum_{i=1}^n p_i \dot{q}_i - L. \tag{31} \end{align}
Equation (31) is called the Legendre transformation of the Lagrangian. So when are Equations (30) and (31) not equivalent? The answer is when our potential energy depends, at least in part, on the generalized velocities. Another difference from Lagrangian mechanics is that we define HH in terms of pip_i and qiq_i instead of qiq_i and q˙i\dot{q}_i.

So what is the Legendre transformation? It takes a function, say f(x)f(x), and it uses its tangent lines and their yy intercepts to create a new function, g(p)g(p) that incorporates all the information that f(x)f(x) contained. Here is a great video that explains the Legendre transformation and its derivation.

The equations of motion with no non-conservative forces are:

p˙i=−∂H∂qiq˙i=∂H∂pi.\begin{align} \dot{p}_i &= -\dfrac{\partial H}{\partial q_i} \tag{32} \\ \dot{q}_i &= \dfrac{\partial H}{\partial p_i}. \tag{33} \end{align}
We can derive these equations of motion by considering an infinitesimal change to our path and its effect on HH, which we will denote as dHdH:
dH=∑i=1nd(piq˙i)−dL=∑i=1ndpiq˙i+pidq˙i−dL=∑i=1nq˙idpi+pidq˙i−∂L∂qidqi−∂L∂q˙idq˙i.\begin{align} dH &= \sum_{i=1}^n d(p_i\dot{q}_i) - dL \tag{34} \\ &= \sum_{i=1}^n dp_i \dot{q}_i + p_i d\dot{q}_i - dL \tag{35} \\ &= \sum_{i=1}^n \dot{q}_i dp_i + p_i d\dot{q}_i - \dfrac{\partial L}{\partial q_i} dq_i - \dfrac{\partial L}{\partial \dot{q}_i}d\dot{q}_i. \notag \end{align}
To go from Equations (34) to (35), we used the product rule of differentiation, in case you were wondering. Next we use the definition of canonical momentum:
dH=∑i=1nq˙idpi+pidq˙i−∂L∂qidqi−pidq˙i=∑i=1nq˙idpi−∂L∂qidqi=∑i=1n−∂L∂qidqi+q˙idpi.\begin{aligned} dH &= \sum_{i=1}^n \dot{q}_i dp_i + p_i d\dot{q}_i - \dfrac{\partial L}{\partial q_i} dq_i - p_i d\dot{q}_i \\ &= \sum_{i=1}^n \dot{q}_i dp_i - \dfrac{\partial L}{\partial q_i} dq_i \\ &= \sum_{i=1}^n - \dfrac{\partial L}{\partial q_i} dq_i + \dot{q}_i dp_i. \end{aligned}
Next we can use Equations (20) to simplify our ∂L∂qi\dfrac{\partial L}{\partial q_i} term. As remember this, according to Equations (20) is equal to ddt∂L∂q˙i\dfrac{d}{dt}\dfrac{\partial L}{\partial \dot{q}_i} which can also be written as p˙i\dot{p}_i:
dH=∑i=1nq˙idpi−p˙idqi.\begin{align} dH &= \sum_{i=1}^n \dot{q}_i dp_i - \dot{p}_i dq_i. \tag{36} \end{align}
Assuming our Hamiltonian does not explicitly depend on tt, we can also write dHdH as:
dH=∑i=1n∂H∂qidqi+∂H∂pidpi.\begin{align} dH &= \sum_{i=1}^n \dfrac{\partial H}{\partial q_i} dq_i + \dfrac{\partial H}{\partial p_i}dp_i. \tag{37} \end{align}
As this is just the change in HH caused directly by the change in qiq_i plus the change in HH that is directly caused by the change in pip_i. Equating like terms in the right-hand sides of Equations (36) and (37) yields:
p˙i=−∂H∂qiq˙i=∂H∂pi.\begin{aligned} \dot{p}_i &= -\dfrac{\partial H}{\partial q_i} \\ \dot{q}_i &= \dfrac{\partial H}{\partial p_i}. \end{aligned}
Which are Equations (32) and (33), which are known as Hamilton's equations. I should mention this is not the only way to derive Hamilton's equations; it is also possible to derive them directly from the stationary action principle, for instance.

To account for non-conservative forces, we merely add the corresponding generalized force terms to the right-hand side of Equation (32). In other words:

p˙i=−∂H∂qi+Qi.\begin{align} \dot{p}_i &= -\dfrac{\partial H}{\partial q_i} + Q_i. \tag{38} \end{align}
This creates a new kind of space that we can visualize our solution on that has dimensions qiq_i and pip_i. This type of space is known as phase space.

Example: simple pendulum

The Hamiltonian for the simple pendulum is:

H=T+V=ml2θ˙22+mglsin⁡θ.\begin{align} H &= T + V \tag{39} \\ &= \dfrac{ml^2 \dot{\theta}^2}{2} + mgl\sin{\theta}. \tag{40} \end{align}
We can use Equation (30) to determine our Hamiltonian here because our potential energy, VV, is independent of the generalized velocities. Problem is, however, that this is written in terms of qiq_i and q˙i\dot{q}_i not qiq_i and pip_i. First we need to determine what our canonical momentum is. Equations (24) yields:
pθ=∂L∂θ˙pθ=ml2θ˙.\begin{align} p_{\theta} &= \dfrac{\partial L}{\partial \dot{\theta}} \notag \\ p_{\theta} &= ml^2\dot{\theta}. \tag{41} \end{align}
Rewriting Equation (41) with θ˙\dot{\theta} as its subject:
θ˙=pθml2.\begin{align} \dot{\theta} &= \dfrac{p_{\theta}}{ml^2}. \tag{42} \end{align}
Substituting Equation (45) into Equation (40) yields:
H=ml22(pθml2)2+mglsin⁡θ=ml22pθ2m2l4+mglsin⁡θ.\begin{aligned} H &= \dfrac{ml^2}{2} \left( \dfrac{p_{\theta}}{ml^2} \right)^2 + mgl\sin{\theta} \\ &= \dfrac{ml^2}{2} \dfrac{p_{\theta}^2}{m^2l^4} + mgl\sin{\theta}. \end{aligned}
Cancelling out common factors in the numerator and denominator of the kinetic energy term yields:
H=pθ22ml2+mglsin⁡θ.\begin{align} H &= \dfrac{p_{\theta}^2}{2ml^2} + mgl\sin{\theta}. \tag{43} \end{align}
Hence the equations of motion are:
p˙θ=−∂H∂θ=−mglcos⁡θθ˙=∂H∂pθ=pθml2.\begin{align} \dot{p}_{\theta} &= -\dfrac{\partial H}{\partial \theta} \notag \\ &= - mgl\cos{\theta} \tag{44} \\ \dot{\theta} &= \dfrac{\partial H}{\partial p_{\theta}} \notag \\ &= \dfrac{p_{\theta}}{ml^2}. \tag{45} \end{align}
As we can see, Hamiltonian mechanics yields a series of first-order ordinary differential equations (ODEs) instead of second-order ODEs. Which is important because Lagrangian mechanics and Newtonian mechanics both yield second-order ODE systems. That being said, if you rewrite Equation (45) to make pθp_{\theta} its subject and substitute it into Equation (44) and rearrange it to make θ¨\ddot{\theta} the subject, you will obtain Equation (29).

Poisson brackets

Poisson brackets provide us an elegant and powerful way to rewrite Hamilton's equations. If we have nn degrees of freedom and two functions ff and gg that depend on pip_i and qiq_i:[1]

{f,g}=def∑i=1n(∂f∂qi∂g∂pi−∂f∂pi∂g∂qi).\begin{align} \{f, g\} &\stackrel{\text{def}}{=} \sum_{i=1}^n \left( \dfrac{\partial f}{\partial q_i} \dfrac{\partial g}{\partial p_i} - \dfrac{\partial f}{\partial p_i}\dfrac{\partial g}{\partial q_i} \right). \tag{46} \end{align}

Poisson brackets also have several interesting properties, such as antisymmetry:

{A,B}=−{B,A}.\begin{align} \{A, B\} &= -\{B, A\}. \tag{47} \end{align}
Consequently:
{A,A}=0.\begin{align} \{A,A\} &= 0. \tag{48} \end{align}
Further, assuming each of the coordinates of the phase space are independent, it follows that:
{qj,pk}=∑i=1n(∂qj∂qi∂pk∂pi−∂qj∂pi∂pk∂qi)=∑i=1nδjkδik=δij.\begin{align} \{q_j, p_k\} &= \sum_{i=1}^n \left( \dfrac{\partial q_j}{\partial q_i} \dfrac{\partial p_k}{\partial p_i} - \dfrac{\partial q_j}{\partial p_i} \dfrac{\partial p_k}{\partial q_i} \right) \notag \\ &= \sum_{i=1}^n \delta_{jk}\delta_{ik} \notag \\ &= \delta_{ij}. \tag{49} \end{align}
Above we used δik\delta_{ik} to denote the Kronecker delta function. It is equal to one if its arguments are equal and zero otherwise.
{qj,qk}=∑i=1n(∂qj∂qi∂qk∂pi−∂qj∂pi∂qk∂qi)=0{pj,pk}=∑i=1n(∂pj∂qi∂pk∂pi−∂pj∂pi∂pk∂qi)=0.\begin{align} \{q_j, q_k\} &= \sum_{i=1}^n \left( \dfrac{\partial q_j}{\partial q_i} \dfrac{\partial q_k}{\partial p_i} - \dfrac{\partial q_j}{\partial p_i} \dfrac{\partial q_k}{\partial q_i} \right) \notag \\ &= 0 \tag{50} \\ \{p_j, p_k\} &= \sum_{i=1}^n \left(\dfrac{\partial p_j}{\partial q_i}\dfrac{\partial p_k}{\partial p_i} - \dfrac{\partial p_j}{\partial p_i}\dfrac{\partial p_k}{\partial q_i}\right) \notag \\ &= 0. \tag{51} \end{align}
The quality of two functions, say ff and gg, having a Poisson bracket that equals zero is phrased as ff and gg commuting under the Poisson bracket.

If a function f(qi,pi)f(q_i, p_i) is not explicitly dependent on tt and only depends on tt indirectly through qiq_i and pip_i, then, via the chain rule:

dfdt=∑i=1n∂f∂qidqidt+∂f∂pidpidt.\begin{align} \dfrac{df}{dt} &= \sum_{i=1}^n \dfrac{\partial f}{\partial q_i}\dfrac{d q_i}{dt} + \dfrac{\partial f}{\partial p_i}\dfrac{dp_i}{dt}. \tag{52} \end{align}
We can use Hamilton's equations to replace dqidt\dfrac{dq_i}{dt} and dpidt\dfrac{dp_i}{dt}:
dfdt=∑i=1n∂f∂qi∂H∂pi−∂f∂pi∂H∂qi.\begin{align} \dfrac{df}{dt} &= \sum_{i=1}^n \dfrac{\partial f}{\partial q_i}\dfrac{\partial H}{\partial p_i} - \dfrac{\partial f}{\partial p_i}\dfrac{\partial H}{\partial q_i}. \tag{53} \end{align}
Interestingly, the right-hand side is equal to the Poisson bracket of ff with HH, in other words:
dfdt={f,H}.\begin{align} \dfrac{df}{dt} &= \{f, H\}. \tag{54} \end{align}
Hence commuting with the Hamiltonian under the Poisson bracket is a sufficient condition for a quantity that does not explicitly depend on time to have a zero time derivative. A zero time derivative means the quantity is static over time which means it is conserved.

This quality makes it unsurprising that Hamilton's equations can be rewritten as:

q˙k={qk,H}p˙k=−{pk,H}.\begin{align} \dot{q}_k &= \{q_k, H\} \tag{55} \\ \dot{p}_k &= -\{p_k, H\}. \tag{56} \end{align}

Noether's theorem

Noether's theorem essentially states that for every continuous symmetry in the Lagrangian, there is a corresponding conservation law. For instance, time translation symmetry of the Lagrangian yields the conservation of energy. To show this, we will assume our Lagrangian does not explicitly depend on tt. That is, tt itself does not appear directly in our Lagrangian. The only time dependence LL has on tt is through the dependence of qiq_i and q˙i\dot{q}_i on time. If the Lagrangian did explicitly depend on time, we would expect it not to have time translation symmetry. Say we increase time according to the transformation: t→t+dtt\rightarrow t+dt where dtdt is an infinitesimal change in tt.

L(qi(t+dt),q˙i(t+dt))=L(qi(t),q˙i(t))+dLdtdt=L(qi(t),q˙i(t))+∑i=1n∂L∂qidqidtdt+∂L∂q˙idq˙idtdt.\begin{align} L(q_i(t+dt), \dot{q}_i(t+dt)) &= L(q_i(t), \dot{q}_i(t)) + \dfrac{dL}{dt} dt \tag{57} \\ &= L(q_i(t), \dot{q}_i(t)) + \sum_{i=1}^n\dfrac{\partial L}{\partial q_i} \dfrac{dq_i}{dt} dt + \dfrac{\partial L}{\partial \dot{q}_i} \dfrac{d\dot{q}_i}{dt} dt . \tag{58} \end{align}
Subtracting L(qi(t),q˙i(t))L(q_i(t), \dot{q}_i(t)) from both sides of Equation (58) yields:
L(qi(t+dt),q˙i(t+dt))−L(qi(t),q˙i(t))=∑i=1n∂L∂qidqidtdt+∂L∂q˙idq˙idtdt.\begin{align} L(q_i(t+dt), \dot{q}_i(t+dt)) - L(q_i(t), \dot{q}_i(t)) &= \sum_{i=1}^n\dfrac{\partial L}{\partial q_i} \dfrac{dq_i}{dt} dt + \dfrac{\partial L}{\partial \dot{q}_i} \dfrac{d\dot{q}_i}{dt} dt. \tag{59} \end{align}
We will call the left-hand side of Equation (59) dLdL, hence Equation (59) becomes:
dL=∑i=1n∂L∂qidqidtdt+∂L∂q˙idq˙idtdt.\begin{align} dL &= \sum_{i=1}^n \dfrac{\partial L}{\partial q_i} \dfrac{dq_i}{dt} dt + \dfrac{\partial L}{\partial \dot{q}_i} \dfrac{d\dot{q}_i}{dt} dt. \tag{60} \end{align}
Rearranging Equations (20) yields that:
∂L∂qi=ddt(∂L∂q˙i).\begin{align} \dfrac{\partial L}{\partial q_i} = \dfrac{d}{dt}\left(\dfrac{\partial L}{\partial \dot{q}_i}\right). \tag{61} \end{align}
If you are wondering what about if we have non-conservative forces? Would that not mean Equations (61) would not hold as there would be a missing generalized force term? Yes and in that event the Lagrangian would indeed change in time and conservation of energy would not hold, as our system would be losing energy to those non-conservative forces.

Substituting Equations (61) into Equation (60) yields:

dL=∑i=1ndt(ddt∂L∂q˙iq˙i+∂L∂q˙iq¨i).\begin{align} dL &= \sum_{i=1}^n dt\left(\dfrac{d}{dt}\dfrac{\partial L}{\partial \dot{q}_i}\dot{q}_i + \dfrac{\partial L}{\partial \dot{q}_i}\ddot{q}_i\right). \tag{62} \end{align}
Substituting Equations (24) into Equation (62) yields:
dL=dt∑i=1n(dpidtq˙i+piq¨i)=dt∑i=1n(p˙iq˙i+piq¨i).\begin{align} dL &= dt\sum_{i=1}^n \left(\dfrac{dp_i}{dt} \dot{q}_i + p_i \ddot{q}_i\right) \notag \\ &= dt\sum_{i=1}^n \left(\dot{p}_i \dot{q}_i + p_i \ddot{q}_i\right). \tag{63} \end{align}
We can rewrite the bracketed expression on the right-hand side of Equation (63) using the product rule of differentiation as:
dL=dt∑i=1nddt(piq˙i)=dtddt∑i=1npiq˙i.\begin{aligned} dL &= dt\sum_{i=1}^n \dfrac{d}{dt}\left(p_i \dot{q}_i\right) \\ &= dt\dfrac{d}{dt}\sum_{i=1}^n p_i \dot{q}_i. \end{aligned}
If LL does not change in time, ΔL=0\Delta L=0, and hence:
dtddt∑i=1npiq˙i=0.\begin{align} dt \dfrac{d}{dt} \sum_{i=1}^n p_i \dot{q}_i &= 0. \tag{64} \end{align}
Dividing both sides of Equations (64) by dtdt yields:
ddt∑i=1npiq˙i=0.\begin{aligned} \dfrac{d}{dt} \sum_{i=1}^n p_i \dot{q}_i &= 0. \end{aligned}
LL does not change, so dLdt=0\dfrac{dL}{dt}=0, too. Hence:
ddt(∑i=1npiq˙i−L)=0.\begin{align} \dfrac{d}{dt} \left(\sum_{i=1}^n p_i \dot{q}_i - L\right) &= 0. \tag{65} \end{align}
We could now use Equation (31) to simplify Equation (65), but I would like to use this as an opportunity to show you how Equations (30) and (31) are usually equivalent. Interestingly, ∑i=1npiq˙i=2T\displaystyle\sum_{i=1}^n p_i \dot{q}_i=2T, that is it is twice the kinetic energy of our system. We can establish this identity using Euler's theorem for homogeneous functions.

Say we have a homogeneous function ff of degree mm of the form:

f=am+1,1,1,...,1x1m+am,2,1,...,1x1m−1x2+am−1,2,2,...,1x1m−2x2x3+...+a1,m+1,1,...,1x2m+...+a1,1,1,...,m+1xnm\begin{aligned} f = a_{m+1,1,1,...,1} x_1^m + a_{m,2,1,...,1}x_1^{m-1}x_2 + a_{m-1,2,2,...,1}x_1^{m-2}x_2 x_3 + ... + a_{1,m+1,1,...,1}x_2^m + ... + a_{1, 1, 1, ..., m+1}x_n^m \end{aligned}
where ai,j,k,...,a_{i,j,k,...,} are coefficients that do not depend on our variables. In other words, ff is a polynomial function of xix_i (i∈{1,2,3,...,n}i\in\{1, 2, 3, ..., n\}) with a maximum total power of mm. Then Euler's theorem states that:[2]
∑i=1nxi∂f∂xi=mf.\begin{align} \sum_{i=1}^n x_i \dfrac{\partial f}{\partial x_i} &= mf. \tag{66} \end{align}
Kinetic energy is a homogeneous function, in terms of q˙i\dot{q}_i, of second order, specifically it can be written as:
T=∑i=1n∑j=1naijq˙iq˙j.\begin{align} T &= \sum_{i=1}^n \sum_{j=1}^n a_{ij} \dot{q}_i \dot{q}_j. \tag{67} \end{align}
Here also aija_{ij} refers to coefficients that do not depend on q˙i\dot{q}_i. Hence:
∑i=1nq˙i∂T∂q˙i=2T.\begin{align} \sum_{i=1}^n \dot{q}_i \dfrac{\partial T}{\partial \dot{q}_i} &= 2T. \tag{68} \end{align}
If we assume that potential energy is independent of q˙i\dot{q}_i, then:
∂L∂q˙i=∂T∂q˙i.\begin{align} \dfrac{\partial L}{\partial \dot{q}_i}&=\dfrac{\partial T}{\partial \dot{q}_i}. \tag{69} \end{align}
Plugging Equations (69) into Equations (68) gives:
∑i=1nq˙i∂L∂q˙i=2T.\begin{align} \sum_{i=1}^n \dot{q}_i \dfrac{\partial L}{\partial \dot{q}_i} &= 2T. \tag{70} \end{align}
Substituting Equations (24) into Equations (70) we get:
∑i=1npiq˙i=2T\begin{align} \sum_{i=1}^n p_i \dot{q}_i &= 2T \tag{71} \end{align}

Hence if we substitute Equation (19) into Equation (65), we obtain:

ddt(2T−(T−V))=0ddt(T+V)=0.\begin{align} \dfrac{d}{dt} \left(2T-(T-V)\right) &= 0 \notag \\ \dfrac{d}{dt} \left(T+V\right) &= 0. \tag{72} \end{align}
Hence substituting Equation (30) into Equation (72) yields:
dHdt=0.\begin{align} \dfrac{dH}{dt} &= 0. \tag{73} \end{align}
So we see that Equations (30) and (31) are equivalent if and only if potential energy is independent of generalized velocity. We also obtain that the Hamiltonian — which is the total energy of the system if potential energy is independent of generalized velocity — does not change when the Lagrangian is time symmetric, hence it is conserved.

I should also mention that the Hamiltonian formulation of Noether's theorem uses Equation (54). As if a quantity that does not explictly depend on time commutes with the Hamiltonian under the Poisson bracket, this means it does not change over time and hence is conserved.

Hamilton-Jacobi equation

There is a final formulation of classical mechanics that I should probably cover. It is based around the so called Hamilton-Jacobi equation which is of the form:

∂S∂t+H(qi,∂S∂qi,t)=0.\begin{align} \dfrac{\partial S}{\partial t} + H\left(q_i, \dfrac{\partial S}{\partial q_i}, t\right) &= 0. \tag{74} \end{align}
Where SS is the action, which is also called Hamilton's principal function. In this approach, we essentially write our Hamiltonian in terms of pip_i and qiq_i and then replace the pip_i with ∂S∂qi\dfrac{\partial S}{\partial q_i}. If our Hamiltonian does not explicitly depend on time, which is usually the case, we then use a separation of variables of the form:
S(qi,t)=W(qi)−Et.\begin{align} S(q_i, t) &= W(q_i)-Et. \tag{75} \end{align}
Where WW is called Hamilton's characteristic function or the abbreviated action and EE is the constant energy.

This approach to mechanics actually lead directly to the Schrödinger equation. Schrödinger actually derived his equation from the Hamilton-Jacobi equation. Why? Well, out of the formulations of classical mechanics, the Hamilton-Jacobi equation allows us to describe mechanical systems in a way that is analogous to light waves. The wave-particle duality — the idea that every quantum particle, including electrons and photons, exhibit both wave and particle properties — is a fundamental part of quantum mechanics and hence the Hamilton-Jacobi equation provides a particularly natural starting point for the development of the central equation of quantum mechanics. For an explanation for how we can describe a mechanical system in a way analogous to light waves, I suggest you check out this excellent video by Abide by Reason.

Example: simple pendulum

To see the Hamilton-Jacobi equation in action, let us apply it to the simple pendulum. Replacing pθp_{\theta} with ∂S∂θ\dfrac{\partial S}{\partial \theta}:

H=(∂S∂θ)22ml2+mglsin⁡θ.\begin{aligned} H &= \dfrac{\left(\dfrac{\partial S}{\partial \theta}\right)^2}{2ml^2}+mgl\sin{\theta}. \end{aligned}

Substituting into Equation (74) yields:

(∂S∂θ)22ml2+mglsin⁡θ+∂S∂t=0.\begin{aligned} \dfrac{\left(\dfrac{\partial S}{\partial \theta}\right)^2}{2ml^2}+mgl\sin{\theta} + \dfrac{\partial S}{\partial t} &= 0. \end{aligned}

Substituting Equation (75) yields:

(dWdθ)22ml2+mglsin⁡θ−E=0.\begin{aligned} \dfrac{\left(\dfrac{dW}{d\theta}\right)^2}{2ml^2}+mgl\sin{\theta} -E &= 0. \end{aligned}

Multiplying both sides by 2ml22ml^2:

(dWdθ)2+2m2gl3sin⁡θ−2ml2E=0.\begin{aligned} \left(\dfrac{dW}{d\theta}\right)^2 + 2m^2gl^3\sin{\theta}-2ml^2E &=0. \end{aligned}

Rearranging yields:

(dWdθ)2=2ml2E−2m2gl3sin⁡θ.\begin{aligned} \left(\dfrac{dW}{d\theta}\right)^2 &= 2ml^2E - 2m^2gl^3\sin{\theta}. \end{aligned}

Square-rooting both sides yields:

dWdθ=±2ml2E−2m2gl3sin⁡θ=±2ml2(E−mglsin⁡θ).\begin{aligned} \dfrac{dW}{d\theta} &= \pm\sqrt{2ml^2E-2m^2gl^3\sin{\theta}} \\ &= \pm \sqrt{2ml^2(E-mgl\sin{\theta})}. \end{aligned}

Integrating yields:

W(θ)=±2ml∫E−mglsin⁡θdθ.\begin{aligned} W(\theta) &= \pm\sqrt{2m}l \int \sqrt{E-mgl\sin{\theta}} d\theta. \end{aligned}

Next, we assume ∂S∂E\dfrac{\partial S}{\partial E} will equal a constant, say β\beta. Then we differentiate Equation (75):

∂W∂E−t=β.\begin{aligned} \dfrac{\partial W}{\partial E} - t &= \beta. \end{aligned}

Rearranging yields:

t+β=∂W∂E.\begin{aligned} t+\beta &= \dfrac{\partial W}{\partial E}. \end{aligned}

Hence:

t+β=±2ml∫12E−mglsin⁡θdθ=±∫ml22(E−mglsin⁡θ)dθ.\begin{aligned} t+\beta &= \pm \sqrt{2m}l\int \dfrac{1}{2\sqrt{E-mgl\sin{\theta}}} d\theta \\ &= \pm \int \sqrt{\dfrac{ml^2}{2(E-mgl\sin{\theta})}} d\theta. \end{aligned}
The integrand — given it is integrated with respect to θ\theta to obtain tt (plus some constant) — must be dtdθ\dfrac{dt}{d\theta} which is one over dθdt\dfrac{d\theta}{dt} or θ˙\dot{\theta}. Therefore:

dtdθ=±ml22(E−mglsin⁡θ).\begin{aligned} \dfrac{dt}{d\theta} &= \pm \sqrt{\dfrac{ml^2}{2(E-mgl\sin{\theta})}}. \end{aligned}

Hence θ˙\dot{\theta} is:

θ˙=±2(E−mglsin⁡θ)ml2.\begin{align} \dot{\theta} &= \pm \sqrt{\dfrac{2(E-mgl\sin{\theta})}{ml^2}}. \tag{76} \end{align}

Squaring Equation (76) yields:

θ˙2=2(E−mglsin⁡θ)ml2.\begin{align} \dot{\theta}^2 &= \dfrac{2(E-mgl\sin{\theta})}{ml^2}. \tag{77} \end{align}
Differentiating the left-hand side of Equation (77) with respect to θ\theta:
dθ˙2dθ=2θ˙dθ˙dθ=2dθ˙dθdθdt=2dθ˙dt=2θ¨.\begin{align} \dfrac{d\dot{\theta}^2}{d\theta} &= 2\dot{\theta}\dfrac{d\dot{\theta}}{d\theta} \notag \\ &= 2\dfrac{d\dot{\theta}}{d\theta}\dfrac{d\theta}{dt} \notag \\ &= 2\dfrac{d\dot{\theta}}{dt} \notag \\ &= 2\ddot{\theta}. \tag{78} \end{align}
Differentiating the right-hand side of Equation (77) and equating to the right-hand side of Equation (78) yields:
2θ¨=−−2mglcos⁡θml2=−2gcos⁡θl.\begin{align} 2\ddot{\theta} &= -\dfrac{-2mgl\cos{\theta}}{ml^2} \notag \\ &= \dfrac{-2g\cos{\theta}}{l}. \notag \end{align}
Dividing both sides by 22 yields:
θ¨=−glcos⁡θ.\begin{align} \ddot{\theta} &= -\dfrac{g}{l}\cos{\theta}. \notag \end{align}
Which we can see matches Equation (29).

Connections to other branches of physics

Classical mechanics provides the foundation that other fields of physics build on.

For instance, special relativity provides corrections (often called relativistic corrections) to classical mechanics to account for effects that become pronounced at speeds comparable to cc, the speed of light in a vacuum. General relativity accounts for these effects, too, but also accounts for effects most noticeable in strong gravitational fields.

Quantum mechanics instead focuses on what happens on small scales, namely the scale of atoms and subatomic particles. Like classical mechanics, quantum mechanics does not account for effects that become pronounced at speeds comparable to cc.

Quantum field theory focuses on quantum fields, such as those pertaining to electromagnetism, the strong nuclear force and the weak nuclear force. It also has the distinction of being relativistic — that is, it accounts for effects that become pronounced at speeds comparable to cc.

Special relativity

As previously mentioned, in special relativity we can make relativistic corrections to kinetic energy in our Lagrangian and Hamiltonians. Namely, we can define it as:

T(v)=mc21−v2c2−mc2=mc2(11−v2c2−1).\begin{aligned} T(v) &= \dfrac{mc^2}{\sqrt{1-\dfrac{v^2}{c^2}}} - mc^2 \\ &= mc^2\left(\dfrac{1}{\sqrt{1-\dfrac{v^2}{c^2}}}-1\right). \end{aligned}

Classical limit of special relativity's kinetic energy

Using the Maclaurin series, we are going to show that T(v)T(v) is well approximated by T=mv22T=\dfrac{mv^2}{2} when v<<cv << c. To make things simpler for ourselves, we will consider the Maclaurin series of the function:

f(x)=11−x=(1−x)−1/2.\begin{aligned} f(x) &= \dfrac{1}{\sqrt{1-x}} \\ &= (1-x)^{-1/2}. \end{aligned}

(This is as opposed to directly calculating the Maclaurin series of our T(v)T(v). If we directly applied the Maclaurin series formula to T(v)T(v) the derivatives we would need to calculate would get a bit unruly.) In this case:

f′(x)=−12(1−x)−3/2⋅−1=(1−x)−3/22f′′(x)=−3(1−x)−5/24⋅−1=3(1−x)−5/24f(3)(x)=−15(1−x)−7/28⋅−1=15(1−x)−7/28\begin{aligned} f'(x) &= -\dfrac{1}{2}(1-x)^{-3/2} \cdot -1 \\ &= \dfrac{(1-x)^{-3/2}}{2} \\ f''(x) &= -\dfrac{3(1-x)^{-5/2}}{4} \cdot -1 \\ &= \dfrac{3(1-x)^{-5/2}}{4} \\ f^{(3)}(x) &= -\dfrac{15(1-x)^{-7/2}}{8} \cdot -1 \\ &= \dfrac{15(1-x)^{-7/2}}{8} \end{aligned}
Where f(3)(x)f^{(3)}(x) denotes the 3rd derivative of ff with respect to xx. Note how for the first derivative the coefficient is just 12\dfrac{1}{2}, for the second derivative it is 34\dfrac{3}{4} and for the third it is 158\dfrac{15}{8}. Seems to me that the denominator is just 2n2^n where nn is the order of the derivative and the numerator of the coefficient is (2n−1)×(2n−3)×(2n−5)×...×1(2n-1) \times (2n-3) \times (2n-5)\times ... \times 1. Hence:
dnfdxn=(∏i=1n2i−1)(1−x)−(2n+1)/22n∀n∈Z+.\begin{aligned} \dfrac{d^nf}{dx^n} &= \dfrac{\left(\displaystyle \prod_{i=1}^n 2i-1\right)(1-x)^{-(2n+1)/2}}{2^{n}} \hspace{0.1cm}\forall n\in \mathbb{Z}^{+}. \end{aligned}
∏i=1n2i−1\displaystyle \prod_{i=1}^n 2i-1 is a way of writing a multi-term product that is somewhat analogous to the summation notation ∑i=1n2i−1\displaystyle \sum_{i=1}^n 2i-1. In this sum, we add up 2i−12i-1 for i=1i=1, i=2i=2, i=3i=3, and so forth, all the way up until i=ni=n. Whereas in the product ∏i=1n2i−1\displaystyle \prod_{i=1}^n 2i-1 we would multiply 2i−12i-1 for i=1i=1, i=2i=2, i=3i=3, and so forth up until i=ni=n. Likewise Z+\mathbb{Z}^{+} denotes the set of all positive integers (so {1,2,3,...}\{1, 2, 3, ...\}). For instance if n=3n=3:
∏i=132i−1=(2(1)−1)×(2(2)−1)×(2(3)−1)=1×3×5=15.\begin{aligned} \displaystyle \prod_{i=1}^3 2i-1 &= (2(1)-1) \times (2(2)-1) \times (2(3)-1) \\ &= 1 \times 3 \times 5 \\ &= 15. \end{aligned}

Substituting in x=0x=0 into f(x)f(x) and our derivatives yields:

f(0)=1f′(0)=12dnfdxn∣x=0=∏i=1n2i−12n.\begin{aligned} f(0) &= 1 \\ f'(0) &= \dfrac{1}{2} \\ \dfrac{d^nf}{dx^n}\Big|_{x=0} &= \dfrac{\displaystyle \prod_{i=1}^n 2i-1}{2^{n}}. \end{aligned}

In this case, x=v2c2x=\dfrac{v^2}{c^2}, and we need to multiply by mc2mc^2 and subtract mc2mc^2 to obtain a Maclaurin series for T(v)T(v) and hence:

T(v)=mc2(1+∑n=1∞(∏i=1n2i−1)(v2c2)n2nn!−1)=mc2∑n=1∞(∏i=1n2i−1)(v2c2)n2nn!.\begin{aligned} T(v) &= mc^2 \left(1 + \sum_{n=1}^{\infty} \dfrac{\left(\displaystyle \prod_{i=1}^n 2i-1\right)\left(\dfrac{v^2}{c^2}\right)^n}{2^{n}n!}-1\right) \\ &= mc^2 \sum_{n=1}^{\infty} \dfrac{\left(\displaystyle \prod_{i=1}^n 2i-1\right)\left(\dfrac{v^2}{c^2}\right)^n}{2^{n}n!}. \end{aligned}
Hence the first few terms of our Maclaurin series are:
T(v)=mc2(v22c2+3v48c4+15v648c6+… )=mv22+3mv48c2+15mv648c4+… .\begin{aligned} T(v) &= mc^2 \left(\dfrac{v^2}{2c^2}+\dfrac{3v^4}{8c^4}+\dfrac{15v^6}{48c^6}+\dots\right) \\ &= \dfrac{mv^2}{2} + \dfrac{3mv^4}{8c^2} + \dfrac{15mv^6}{48c^4} + \dots. \end{aligned}
So what happens when vv is much smaller than cc? Well, we would expect every term with a non-zero power of cc in the denominator to be negligible in its contribution to TT and this leaves only the first term. Hence we obtain that for v<<cv << c:
T(v)≈mv22.\begin{aligned} T(v) &\approx \dfrac{mv^2}{2}. \end{aligned}

General relativity

In general relativity, we can use the Einstein-Hilbert action to derive the Einstein field equations (EFE). The EFE are a series of partial differential equations that can be used to calculate the components of the metric tensor, gμνg_{\mu\nu}. The metric tensor is a type of matrix with sixteen total components that allow us to define proper time in curved spacetime. It has sixteen components because μ\mu and ν\nu can take on four different values each, corresponding to the four dimensions of spacetime (e.g. in Cartesian coordinates they are tt, xx, yy and zz), so that gives us 4×4=164\times 4=16 combinations of possible μ\mu and ν\nu values. Proper time is analogous to distance in spacetime and is the time that passes locally for an observer.

I should mention, in case you are unfamiliar, that in relativity, the passage of time itself is relative. Objects travelling close to the speed of light or in powerful gravitational fields have time pass substantially slower for them than those at lower velocities and in weaker gravitational fields.

The Einstein-Hilbert action is:

S=c416πG∫R4R∣det⁡gμν∣d4x.\begin{align} S &= \dfrac{c^4}{16\pi G} \int_{\mathbb{R}^4} R \sqrt{\left|\det{g_{\mu\nu}}\right|} d^4 x. \tag{79} \end{align}
One major difference you may notice between the classical action and the Einstein-Hilbert action is that the classical action is integrated over time whereas the Einstein-Hilbert action is integrated over spacetime (that is what the d4xd^4x and R4\mathbb{R}^4 are about). RR is the Ricci scalar which is calculated based on gμνg_{\mu\nu} and det⁡gμν\det{g_{\mu\nu}} is the determinant of the metric tensor matrix.

Another application of action in general relativity is that it can be used to calculate the path an object will take in curved spacetime. As the path the object follows will be the path that maximizes its proper time. The action for this calculation is:

S=−mc∫λ0λf∣gμνdxμdλdxνdλ∣dλ.\begin{align} S &= -mc \int_{\lambda_0}^{\lambda_f} \sqrt{\Big| g_{\mu\nu} \dfrac{dx^{\mu}}{d\lambda} \dfrac{dx^{\nu}}{d\lambda}\Big|}d\lambda. \tag{80} \end{align}

Why the −mc-mc coefficient? Well, the negative sign is to ensure that minimizing SS corresponds to maximizing the proper time. As for the mcmc, it is to get our units right. See the integral itself is in units of metres. mm is in units of kilograms and cc is in units of metres per second. Consequently our units overall are kg⋅m2⋅s−1\mathrm{kg} \cdot \mathrm{m}^2 \cdot \mathrm{s}^{-1}. Action is in units of J⋅s\mathrm{J}\cdot \mathrm{s}, where J\mathrm{J} denotes Joules, the SI standard units of energy. Joules are, in turn, defined as kg⋅m2⋅s−2\mathrm{kg}\cdot \mathrm{m}^2 \cdot \mathrm{s}^{-2}. So J⋅s\mathrm{J}\cdot \mathrm{s} is kg⋅m2⋅s−1\mathrm{kg}\cdot \mathrm{m}^2 \cdot \mathrm{s}^{-1}, which matches the units of our SS. I should also explain that in this integral, λ\lambda is an arbitrary parameter. Often we choose it to be proper time. Setting δS=0\delta S=0 yields the geodesic equations which are a series of ordinary differential equations that maximize proper time.

Quantum mechanics

We have seen in this article that there are multiple different formulations of classical mechanics. Similarly, there are multiple different formulations of quantum mechanics.

Path-integral formulation

One formulation of quantum mechanics is the path-integral formulation developed by Richard Feynmann. In it, we expect our particle or wave to explore all possible paths and we integrate (or sum) over all those paths in order to compute the probability amplitude of our particle. The exploration of all possible paths is a consequence of the randomness of quantum mechanics. Specifically, we compute the integral:

K(xf,tf;x0,t0)=∫x(t0)=x0x(tf)=xfeiS(x)ℏDx.\begin{align} K(\mathbf{x}_f, t_f; \mathbf{x}_0, t_0) &= \int_{\mathbf{x}(t_0)=\mathbf{x}_0}^{\mathbf{x}(t_f)=\mathbf{x}_f} e^{\frac{iS(\mathbf{x})}{\hbar}} \mathcal{D}\mathbf{x}. \tag{81} \end{align}

Where KK is the propagator, which specifies the probability amplitude for travelling from x0\mathbf{x}_0 at time t0t_0 to xf\mathbf{x}_f at time tft_f. SS is the action of the particle, ℏ\hbar is the reduced Planck's constant, ii is the imaginary number and Dx\mathcal{D}\mathbf{x} refers to the fact we are integrating over all possible paths. The probability amplitude is a quantity that, if you take the absolute value of, and square this quantity you get the probability of the particle travelling from x0\mathbf{x}_0 at time t0t_0 to xf\mathbf{x}_f at time tft_f.

One major strength of the path-integral formulation of quantum mechanics is that it provides an explanation for how quantum mechanics gives rise to classical mechanics on larger scales.

So, with the background information covered in Prerequisite mathematics in mind, we now know that eiSℏe^{\frac{iS}{\hbar}} is like a 2D unit vector as it points in particular direction in the xyxy plane and has unit length. Specifically, it points in the direction Sℏ\dfrac{S}{\hbar} radians counterclockwise from the positive xx axis. Each integer multiple of 2π2\pi, which corresponds to a complete revolution around the Cartesian plane, that is present in Sℏ\dfrac{S}{\hbar} makes no difference to its overall direction. What matters is what is left after subtracting these integer multiples of 2π2\pi.

Interestingly, when we integrate over all possible paths on classical mechanics scales we find that the eiSℏe^{\frac{iS}{\hbar}}, for most paths, cancel each other out. To see why, we must first start with the fact that ℏ\hbar is a very tiny number — it is approximately 1.055×10−34J⋅s1.055\times 10^{-34}\mathrm{J}\cdot \mathrm{s}. Consequently, Sℏ\dfrac{S}{\hbar} is a massive number when we are analysing classical mechanical systems. As typically in these scenarios SS is >0.01J⋅s\gt0.01J\cdot s. Consequently, even a relatively small difference in SS, can lead to a majorly different direction for eiSℏe^{\frac{iS}{\hbar}}.

This leads to the actions of nearby paths often being in opposite directions and cancelling each other when we calculate the path integral. The one exception is the path corresponding to the stationary action. Remember the equation δS=0\delta S=0 that we solve to find the path of our classical mechanical system? It says that a tiny change to the stationary action path should make no change (to first order) to the action and consequently, when we integrate eiSℏe^{\frac{iS}{\hbar}} for that path and its neighbours, the stationary action path term is the only one that survives. Consequently, in the classical limit our object only explores the path that extremizes the action, and as we have seen an extremized action leads to the equations of motion in classical mechanics.

Operator formalism

Another connection between what we have covered and quantum mechanics is in the operator formalism of quantum mechanics. In it, we represent the state of our physical system using a function called the wavefunction which is denoted as ψ\psi, which can also thought of as a vector, as it is a complex number. We can calculate the wavefunction using Schrödinger's equation:

iℏ∂ψ∂t=(−ℏ22mΔ+V(x))ψ.\begin{align} i\hbar \dfrac{\partial \psi}{\partial t} &= \left(-\dfrac{\hbar^2}{2m}\Delta + V(\mathbf{x})\right)\psi. \tag{82} \end{align}

V(x)V(\mathbf{x}) is the potential energy and Δ\Delta is the Laplacian which is essentially just ∂2∂x2+∂2∂y2+∂2∂z2\dfrac{\partial^2}{\partial x^2} + \dfrac{\partial^2}{\partial y^2}+\dfrac{\partial^2}{\partial z^2}. The right-hand side of Equation (82) can also be represented by H^ψ\hat{H}\psi where H^\hat{H} is the Hamiltonian operator and calculates, from the wavefunction, the total energy of our system. Another important link to classical mechanics that I have already alluded to is that Schrödinger's equation was derived using the Hamilton-Jacobi equation. Specifically, Schrödinger used the Hamilton-Jacobi equation to derive an action that he then extremized and out from that popped his equation.

Quantum field theory

Lagrangians, Hamiltonians and actions also appear in quantum field theory, including The Standard Model of particle physics. In fact, if you want to see a dauntingly long and complex Lagrangian, Google The Standard Model Lagrangian.

Reference list

[1] Cline D (2026). 15.2: Poisson bracket Representation of Hamiltonian Mechanics. In Variational Principles in Classical Mechanics. LibreTexts.
[2] Tatum J (2026). 2.6: Euler’s Theorem for Homogeneous Functions. In Heat and Thermodynamics. LibreTexts.