Lecture 3
PHY 313, Mechanics
September 9, 2026
Calculus of variations
Next week we will introduce Lagrangian mechanics, which is a technique that will allow us to avoid complicated directional contact forces and approach motion from a scalar, energy perspective. This involves minimizing something called the “action” (more next week), using the calculus of variations.
Calculus of variations allows us to solve variational problems, which are everywhere in physics. Some examples include finding the shortest time of travel through some medium (Fermat’s principle leading to the law of refraction), finding minimal surface energy configurations, optimizing the number of connections on a graph, semi-classical methods for solving wavefunctions at complicated boundaries in quantum mechanics, and Feynman path integrals. Let’s start with a simple example: finding the shortest distance path for a reflection.
Reflection
We want to find the shortest distance path between two points, A and B, requiring that the path reflects off a planar boundary that does not contain A or B (like a mirror).
Our first step is to parameterize the problem to describe the path. We will require that the path consists of straight lines from A, to the mirror (M), and then to B. But the location where the path hits the mirror is unknown. Let the distance between A and B be $d$ and the horizontal distance between A and the endpoint of path \(A\rightarrow M\) be \(x\). The vertical distance will be \(y\). Then the horizontal distance between \(B\) and the endpoint of the path \(M\rightarrow B\) is \(d-x\).
We can now write the total path length, \(s = \sqrt{x^2 + y^2} + \sqrt{(d-x)^2 + y^2}\). We can find extreme values of this path length for the parameter \(x\) by finding its stationary points, \(\frac{ds}{dx} = 0\).
\[\begin{align*} \frac{ds}{dx} &= \frac{d}{dx}\left( \sqrt{x^2 + y^2} + \sqrt{(d-x)^2 + y^2} \right) \\ 0 &= \frac{x}{\sqrt{x^2 + y^2}} + \frac{-(d-x)}{\sqrt{(d-x)^2 + y^2}} \\ x^2 \left[ (d-x)^2 + y^2 \right] &= (d-x)^2 \left[ x^2 + y^2 \right] \\ x^2 \left[ d^2 - 2dx + x^2 + y^2 \right] &= (d^2 - 2dx + x^2) (x^2 + y^2) \\ 0 &= d^2 y^2 - 2dxy^2 \\ d &= 2x \end{align*}\]Using minimization, we have found that the path must hit the midpoint between A and B in the mirror. This means the angle of incidence must be equal to the angle of reflection.
Shortest path between two points
There were a lot of rules in the previous example. Let’s try something more general: given any arbitrary two points defined by \((x_1, y_1)\) and \((x_2, y_2)\), find the shortest distance path between them.
Let the path be defined by \(y = y(x)\), such that it is a function of \(x\). For a path of some arbitrary function \(y(x)\) we will need to integrate over the short-segment length \(ds = \sqrt{dx^2 + dy^2}\). Since we have defined \(y(x)\), our length element \(dy \neq \Delta y\). Instead, it can be found in linear approximation with its variation in \(x\): \(dy = \frac{dy}{dx} dx = y'(x) dx\), where \(y'(x)\) is the first derivative of \(y\) in \(x\).
\[\begin{align*} ds &= \sqrt{dx^2 + y'^2dx^2} = \sqrt{1+y'^2}dx \\ S = \int_1^2 ds &= \int_{x_1}^{x_2} \sqrt{1+y'^2}dx \end{align*}\]Our goal is to minimize \(S\). But what does that mean? What is the parameter over which we will minimize \(S\)?
What does minimizing mean?
Suppose we have some function \(f(x)\) and we want to find the set of points \({x_{min}}\) for which \(f(x)\) is at some minimum. As we did in the reflection problem, we would take \(\frac{\partial f}{\partial x} = 0\) to find the stationary points \(x_0\) such that \(f(x)\) is at a minimum, maximum, or saddle point. In other words, all the points where the slope of \(f(x)\) is zero.
When we minimize our path, we are looking for stationary paths instead of stationary points. A stationary path is \(y=f(x)\) such that infinitessimal variations do not change the integral value of the path. To find this, we will add some small change to the path and check its sensitivity to variation.
We will define the true path to be \(y(0,x) = f(y, y', x)\), where \(y(x_1) = y_1\) and \(y(x_2) = y_2\) and \(y\), \(y'\) are functions of \(x\).
Then the altered path will be \(y(\alpha, x) = y(0,x) + \alpha\eta(x)\). \(\eta(x)\) is some function of x that will alter the path according to some multiplier \(\alpha\) while maintaining the boundary conditions so that \(\eta(x_1) = \eta(x_2) = 0\). If \(\alpha=0\) we get the original path back. \(\alpha\) parameterizes the deviation from the true path, just like \(x\) in the mirror problem. Our goal is to show that around stationary points of \(\alpha\), the path is completely insensitive to our choice of \(\eta(x)\). In other words, \(\eta\) could be anything and we will still get the same path integral.
Given some path \(S(\alpha) = \int_{x_1}^{x_2} f(y, y', x)dx\), recalling that \(y = y(\alpha,x)\), we know that \(S\) must be minimized at \(\alpha=0\) since we have defined \(y(0,x)\) to be the minimal path. To minimize \(S\), we will find the stationary points in \(\alpha\) by taking its partial derivative in \(\alpha\).
To find \(\frac{\partial S}{\partial \alpha}\), we first need to find \(\frac{\partial f}{\partial \alpha}\). Using the chain rule,
\[\begin{align*} \frac{\partial f}{\partial \alpha} &= \frac{\partial f}{\partial y} \frac{\partial y}{\partial \alpha} + \frac{\partial f}{\partial y'} \frac{\partial y'}{\partial \alpha}\\ &= \frac{\partial f}{\partial y} \eta + \frac{\partial f}{\partial y'}\eta' \\ \end{align*}\]Then,
\[\begin{align*} \frac{\partial S}{\partial\alpha} = \frac{\partial}{\partial\alpha} \int_{x_1}^{x_2} f(y, y', x)dx = \int_{x_1}^{x_2} \frac{\partial f}{\partial\alpha} = \int_{x_1}^{x_2} \left( \frac{\partial f}{\partial y} \eta + \frac{\partial f}{\partial y'}\eta' \right) \end{align*}\]We can integrate the second term by parts. \(\int udv = uv - \int vdu\). Let \(u = \frac{\partial f}{\partial y'}\) and \(dv = \frac{\partial\eta}{\partial x}\).
\[\begin{align*} \cancelto{0}{ \frac{\partial f}{\partial y'} \eta(x) \Biggr|_{1}^{2} } - \int_{x_1}^{x_2} \eta(x) \frac{d}{dx}\left( \frac{\partial f}{\partial y'} \right) dx \\ = \int_{x_1}^{x_2} \left[ \frac{\partial f}{\partial y} \eta - \frac{d}{dx}\left( \frac{\partial f}{\partial y'}\right) \eta \right] dx \\ \end{align*}\]We do not actually need to solve this integral! Since we want \(\frac{\partial S}{\partial \alpha} = 0\) for any \(\eta(x)\), we can factor out \(\eta\) from the integrand and set the remaining factor to zero to make the integrand vanish. This is called the Euler-Lagrange equation.
\[\frac{\partial f}{\partial\ y} - \frac{d}{dx}\left( \frac{\partial f}{\partial y'}\right) = 0\]The Euler-Lagrange equation is a condition that must be met for \(S\) to have a minimum in \(\alpha\).
Now let’s revisit our original problem, finding the shortest distance between two points:
\[S = \int_1^2 ds = \int_{x_1}^{x_2} \sqrt{1 + y'^2} dx\]In this problem, our function \(f(y, y', x) = \left(1 + y'^2 \right)^{1/2}\). Solving for the two terms in the E-L equation,
\(\frac{\partial f}{\partial y} = 0\) because there is no direct dependence on \(y\). This means that we must have \(\frac{d}{dx} \left( \frac{\partial f}{\partial y'} \right) = 0\), and we can say that \(\frac{\partial f}{\partial y'}=c\) where \(c\) is some constant.
\(\frac{d}{dx} \left( \frac{\partial f}{\partial y'} \right) = \frac{y'}{\sqrt{1+y'^2}} = c\). We could rewrite this to find \(y' = m\) where \(m\) is some other constant. Recall that \(y'\) is the slope of \(y\) with respect to \(x\), so we have found the equation of a line \(y = mx+b\). The shortest distance between two points is a line!