Most people learn about Newton's 2nd law back in grade school. It isn't until we've learned multivariate calculus before we tackle alternatives to the Newtonian framework like Lagrangian mechanics. I want to look at deriving the Euler-Lagrange equations. I also want to motivate the form of the Lagrangian. Then at the end I'll work some examples before finally talking about why Lagrangians are important.
Action Principle
We utiize the language of math to describe physical principles. In our first physics classes we learn simple relations such as
$$ v = d/t $$
This statement says that the velocity of something is the distance traveled divided by the time it took. As we progress in physics we start using derivatives to express our ideas. Instead we use something like
$$ v = \frac{dx}{dt} $$
This says the velocity is the time derivative of position. We write almost all laws of nature as differential equations. Perhaps most famously Newton's 2nd law is a differential equation.
$$ F = m\frac{d^2 x}{dt^2} $$
or alternatively
$$ F = \frac{dp}{dt} $$
Unsurprisingly, simple functions and differential equations are not the only mathematical ways to describe physics (That's not to say we won't be using differential equations at all). Instead we will look at functionals. Historically one of the first such problems was the
brachistochrone problem. The problems asks "What curve between two points would allow a frictionless bead to travel in the shortest amount of time?". The problem can be cast as a functional by asking you to find the minimum of
$$ t_{12} = \int_{P_1}^{P_2}\frac{ds}{v} $$
where s is the arc length and v is the velocity. Another problem is finding the surface with minimum area that fits inside a curve. This is the shape a bubble will take if a wireframe with curve's shape is dipped in a soapy solution. The law for minimal area can be stated as finding the minimum of the functional
$$ A[u] = \int\int_{\Omega}\sqrt{1+{(\frac{\partial u}{\partial x})}^2+{(\frac{\partial u}{\partial x})}^2} dx dy $$
for some function $z = u(x,y)$. Fermat's principle in optics says that light travels along the path that locally minimizes the optical length between its endpoints. In functional form we are asked to minimize
$$ L[f] = \int_{x_0}^{x_1} n(x, f(x))\sqrt{1+f'(x)} dx $$
for some function $y = f(x)$
The question (if you couldn't tell by the lead up already) is can we cast mechanics as the minimization (or maximization or some extremum) of some functional? The answer of course is a resounding yes. We say that the motion that a particle takes is the one that minimizes the action functional (denoted by S)
$$ S[q(t)] = \int_{t_0}^{t_1}L(q(t),\dot{q}(t),t) dt $$
The particle can take an infinite number of paths between two points, but nature makes it take the one that makes the action S a minimum. The "L" inside the integral is called the Lagrangian after Joseph-Louis Lagrange who first studied this approach to classical mechanics. We shall see later that the Lagrangian can be written in the form $L = T - V$ with T being the kinetic energy and V the potential. This may seem strange at first sight, but I'm going to show how to derive the Euler-Lagrange equations before showing you why the Lagrangian takes this form.
The Euler-Lagrange Equations
We will now investigate how to do calculus with functionals. When we first work with derivatives we move the coordinates by a little bit (dx) then ask how the function changes (df) $df = f(x+dx) - f(x)$ For functionals we carry out the exact same process. The action S is a function of the path which the particle takes. So we perturb the path $q(t)$ by the amount $\delta q(t)$. Then we look at the change in S.
$$ \delta S = \int_{t_0}^{t_1}[L(q(t)+\delta q(t),\dot{q}(t)+\delta \dot{q}(t),t)-L(q(t),\dot{q}(t),t)] dt $$
I'll skip the boring stuff around the exact mathematical definition of these
variational derivatives and just say that the variation of the functional is equal to the integral of the sum of the partial derivatives of the Lagrangian (L) times their respective variation (similar to the definition of the total derivative).
$$ \delta S = \int_{t_0}^{t_1}[\frac{\partial L}{\partial q}\delta q(t) + \frac{\partial L}{\partial \dot{q}}\delta \dot{q}(t)] dt $$
For now we will ignore the variation of the time coordinate. We now need to establish a few important facts. For one the variations disappear on the boundary i.e.
$$ \delta q(t_0) = \delta q(t_1) = 0 $$
Another important fact is that the variation and time derivatives are interchangeable. In other words
$$ \delta \dot{q}(t) = \frac{d}{dt}\delta q(t) $$
If we focus on the second term
$$ I = \int_{t_0}^{t_1}\frac{\partial L}{\partial \dot{q}}\delta \dot{q}(t) dt \\
= \int_{t_0}^{t_1}\frac{\partial L}{\partial \dot{q}}\frac{d}{dt}\delta q(t) dt \\
= [\frac{\partial L}{\partial \dot{q}}\delta q(t)]|_{t_0}^{t_1} - \int_{t_0}^{t_1}\frac{d}{dt}(\frac{\partial L}{\partial \dot{q}})\delta q(t) dt $$
by integration by parts. We already said that the variations ($\delta q$) disappear on the boundary. So now the variation of the action is
$$ \delta S = \int_{t_0}^{t_1}\frac{\partial L}{\partial q}\delta q(t) - \frac{d}{dt}(\frac{\partial L}{\partial \dot{q}})\delta q(t) dt \\
= \int_{t_0}^{t_1}[\frac{\partial L}{\partial q} - \frac{d}{dt}(\frac{\partial L}{\partial \dot{q}})]\delta q(t) dt $$
Now to find the extrema we set $\delta S = 0$. The variation $\delta q$ is an arbitrary function, so we can say that the quantity in the brackets must be zero.
$$ \frac{\partial L}{\partial q} - \frac{d}{dt}(\frac{\partial L}{\partial \dot{q}}) = 0 $$
If we allow the Lagrangian to be a function of multiple coordinates and their first derivatives then it is easy to see that we get one equation for each coordinate like so
$$ \frac{\partial L}{\partial q^i} - \frac{d}{dt}(\frac{\partial L}{\partial \dot{q}^i}) = 0 $$
These are the celebrated Euler-Lagrange equations of motion.
Let us instead write the Euler-Lagrange equations (henceforth ELE) in the following form
$$ \frac{\partial L}{\partial q^i} = \frac{d}{dt}(\frac{\partial L}{\partial \dot{q}^i}) $$
which I claim has the same form as Newton's 2nd law
$$ F_i = \frac{dp_i}{dt} $$
if we identify $F_i = \frac{\partial L}{\partial q^i}$ and $p_i = \frac{\partial L}{\partial \dot{q}^i}$. Now consider the fact that the Lagrangian is a function of the positions and the velocities only $L = L(x,v)$. Therefore the total differential of the Lagrangian is
$$ dL = \frac{\partial L}{\partial v}dv + \frac{\partial L}{\partial x}dx \\
= pdv + Fdx $$
$$ \int dL = \int p dv + \int F dx $$
In the simplest case $p = mv$ so the first term on the right becomes $\frac{1}{2}mv^2$. For a conservative force we know it is the negative derivative of the potential. Now $\int F dx = \int -\frac{\partial V}{\partial x} dx = -V$. To sum everything up the Lagrangian in the simplest case is
$$ L(x,v) = T(v) - V(x) $$
We now define the Lagrangian in all coordinates to be $L = T - V$.
Examples
What have we just derived? First we stated that the laws of mechanics can be derived from an action principle. We wrote down a general form of an action that depends on the coordinates, their first derivatives, and time. Next we derived what the laws of mechanics would look like if derived from a Lagrangian. By observing the form of the ELE we saw that we could get back Newton's 2nd law if we wrote down the Lagrangian as difference between the kinetic and potential energy. Let's see this in action.
1. Free Particle
$$ L = \frac{1}{2}m(\dot{x}^2 + \dot{y}^2 + \dot{z}^2) $$
$$ 0 = \frac{d}{dt}(\frac{\partial L}{\partial \dot{x}}) = \frac{d}{dt}(m\dot{x}) ...$$
$$ \ddot{x} = \ddot{y} = \ddot{z} = 0 $$
2. 1D Particle with Potential
$$ L = \frac{1}{2}m\dot{x}^2 - V(x) $$
$$ \frac{\partial L}{\partial x} = -\frac{\partial V}{\partial x} = m\ddot{x} = \frac{d}{dt}(\frac{\partial L}{\partial \dot{x}}) $$
as was expected.
3. Particle in Polar Coordinates
$$ L = \frac{1}{2}m(\dot{r}^2 + r^2{\dot{\theta}}^2) - V(r) $$
In the angular coordinate:
$$ \frac{d}{dt}(mr^2\dot{\theta}) = 0 $$
$$ p_\theta := mr^2\dot{\theta} = constant $$
In the radial coordinate:
$$ m\ddot{r} = -\frac{\partial V}{\partial r} + m{\dot{\theta}}^2r \\
= -\frac{\partial V}{\partial r} + \frac{mh^2}{r^3} $$
4. Particle in Rotating System
Define the z-coordinate to not change. The new x and y axes become
$$ \hat{x}' = cos(\Omega t)\hat{x} + sin(\Omega t)\hat{y} \\
\hat{y}' = -sin(\Omega t)\hat{x} + cos(\Omega t)\hat{y} $$
$$ L = \frac{1}{2}m[{(\dot{x}' - \Omega y')}^2 + {(\dot{y}' + \Omega x')}^2 + \dot{z}^2] - V(x',y',z) $$
$$ m\ddot{x}' = -\frac{\partial V}{\partial x'} + m\Omega^2x' + 2m\Omega\dot{y}' \\
m\ddot{y}' = -\frac{\partial V}{\partial y'} + m\Omega^2y' - 2m\Omega\dot{x}' \\
m\ddot{z} = -\frac{\partial V}{\partial z} $$
The second term in the first two coordinates represents the centripetal force. The third term is the Coriolis force. (Derive that from Newton's laws!)
Advantages
Lagrangian mechanics doesn't introduce any new physics. Instead it gives us a simple way to write down the equations of motion for any system with conservative forces. This is often quick and nearly mindless really. Side note: the Lagrangian approach can also include non-conservative forces as well as constraint forces. I will talk about these in another post. One of the advantages from the Lagrangian view is that the equations of motion are invariant under changes of coordinates. If one coordinate system uses $q^1,...,q^n$ while another uses $Q^1,...Q^n$ we can rewrite the ELE
$$ 0 = \frac{\partial L}{\partial q^i} - \frac{d}{dt}(\frac{\partial L}{\partial \dot{q}^i}) \\
= \sum_{j = 1}^{n} [ \frac{\partial L}{\partial Q^j}\frac{\partial Q^j}{\partial q^i}
+ \frac{\partial L}{\partial \dot{Q}^j}\frac{\partial \dot{Q}^j}{\partial q^i}
- \frac{d}{dt}(\frac{\partial L}{\partial \dot{Q}^j}\frac{\partial \dot{Q}^j}{\partial \dot{q}^i}) ] $$
From the relation $Q^j = Q^j(q^1,...,q^n,t)$ we can derive $\dot{Q}^j = \sum_{i = 1}^{n} \frac{\partial Q^j}{\partial q^i}\dot{q}^i + \frac{\partial Q^j}{\partial t}$. We can then see that $\frac{\partial \dot{Q}^j}{\partial \dot{q}^i} = \frac{\partial Q^j}{\partial q^i}$. Next
$$ \frac{\partial \dot{Q}^j}{\partial q^i} = \sum_{k = 1}^{n} \frac{\partial^2 Q^j}{\partial q^i \partial q^k}\dot{q}^k + \frac{\partial^2 Q^j}{\partial q^i \partial t} $$
and similarly
$$ \frac{d}{dt}(\frac{\partial Q^j}{\partial q^i}) = \sum_{k = 1}^{n} \frac{\partial^2 Q^j}{\partial q^i \partial q^k}\dot{q}^k + \frac{\partial^2 Q^j}{\partial q^i \partial t} $$
Skipping some painful algebra we now see that
$$ \sum_{j = 1}^{n} [ (\frac{\partial L}{\partial Q^j} - \frac{d}{dt}(\frac{\partial L}{\partial \dot{Q}^j}))\frac{\partial Q^j}{\partial q^i} ] = 0 $$
So even in the new coordinates Q the ELE still hold
$$ \frac{\partial L}{\partial Q^j} - \frac{d}{dt}(\frac{\partial L}{\partial \dot{Q}^j}) = 0 $$
This is important. We can see that the ELE hold no matter if the coordinates are normal, angular, or even accelerating. Newton's 2nd law changes form depending on the coordinates. It is $ F = ma $ in cartesian, $ \tau = I\alpha $ in angular, and much more complicated in rotating coordinates. The invariance of the ELE takes on an even more important role once we move to Lagrangian densities.
The Lagrangian also gives rise to Noether's theorem. Noether's theorem is a beautiful result that allows us to write down the conserved quantities of a system based on the symmetries of the Lagrangian. We saw in example 3 that if the Lagrangian does not depend on a coordinate $q^i$ then the corresponding momentum $p_i = \frac{\partial L}{\partial \dot{q}^i}$ is conserved. Another result of Noether's theorem is if $ \frac{\partial L}{\partial t} = 0 $ then the energy is conserved! In another blog post I'll go through a simple proof of Noether's theorem sometime in the future.
It may not be all that important, but I find it quite beautiful that the laws of mechanics can be derived from the principle of least action. The idea that nature is constantly trying to minimize the action is stunning. Interestingly once we move on to quantum mechanics the principle of least action is no longer preserved. Instead particles/fields can take on any path/configuration; however, their probability is proportional to the phase of the action. These values are dominated by the minimal actions since larger actions tend to cancel each other out. Classical mechanics is recovered since the particles will stick very closely to the classical value.