# Calculus of Variations

Relevant Wikipedia Articles:

## Local Lagrangian Densities

Extremize over $f \colon \mathcal{X} \to \mathbb{R}$, where $x \in \mathcal{X}$:

$\begin{equation} \label{eqn-1}\tag{1} S(f) = \int_{\mathcal{X}} \mathcal{L}\big(x, f(x), \nabla f(x)\big) {~\rm d}{V}, \end{equation}$

where $\mathcal{L}$ is a real-valued Lagrangian density and $V$ is the measure for $\mathcal{X}$. Specifically, we wish to solve for this extremization in terms of the functional derivative

$\begin{equation} \label{eqn-2}\tag{2} \frac{\delta S}{\delta f} = \frac{\rm d}{{\rm d}\epsilon} S(f + \epsilon g) \bigg \rvert_{\epsilon{=}0}= 0, \end{equation}$

where the function $g \colon \mathcal{X} \to \mathbb{R}$ is arbitrary up being zero on the boundary (denoted $\partial$) of $\mathcal{X}$, and $\mathcal{L}$, $f$, and $g$ are differentiable. $\forall x \in \partial \mathcal{X}, \quad g(x) = 0.$ Let us expand the induced perturbation ${\rm d}S$ to first order in ${\rm d}\epsilon$ about $\epsilon=0$:

\begin{align*} {\rm d}S &= \int_{\mathcal{X}} \bigg[ \frac{\partial \mathcal{L}}{\partial f} {\rm d} f + \sum_{i} \frac{\partial \mathcal{L}}{\partial f^{\prime}_{i}} {\rm d} f^{\prime}_{i} \bigg] {~\rm d}{V} \\ &= {\rm d}\epsilon \int_{\mathcal{X}} \bigg[ \frac{\partial \mathcal{L}}{\partial f} g + \sum_{i} \frac{\partial \mathcal{L}}{\partial f^{\prime}_{i}} \frac{\partial g}{\partial x_{i}} \bigg] {~\rm d}{V}, \tag{3} \end{align*}

where $f^{\prime}_{i} \equiv \frac{\partial f}{\partial x_{i}}$.

We next integrate by parts, where, by Generalized Stokes’s Theorem,

$\begin{equation*} \int_{\partial \mathcal{X}} \alpha \mathbf{y} \cdot {\rm d}\hat{n} = \int_{\mathcal{X}} \nabla \cdot (\alpha \mathbf{y}) ~{\rm d}V = \underbrace{\int_{\mathcal{X}} (\nabla \alpha) \cdot \mathbf{y} ~{\rm d}V}_{\text{2nd term in (3)}} + \int_{\mathcal{X}} \alpha (\nabla \cdot \mathbf{y}) ~{\rm d}V. \end{equation*}$

for scalar $\alpha$, vector $\mathbf{y}$, and unit vector $\hat{n}$ normal to $\partial \mathcal{X}$.

In our case,

\begin{align*} \frac{{\rm d} S}{{\rm d} \epsilon} = \int_{\partial \mathcal{X}} \sum_{i} \underbrace{g(x)}_{0 \text{ on } \partial \mathcal{X}} \frac{\partial \mathcal{L}}{\partial f^{\prime}_{i}} {~\rm d}{\hat{n}_{i}} + \int_{\mathcal{X}} g(x) \bigg[ \frac{\partial \mathcal{L}}{\partial f} - \sum_{i} \frac{\partial }{\partial x_{i}} \bigg(\frac{\partial \mathcal{L}}{\partial f^{\prime}_{i}}\bigg) \bigg] {~\rm d}{V}. \end{align*}

The only way to guarantee that this derivative is zero for all permissible $g$ is for the Euler-Lagrange equation to hold: $\frac{\partial \mathcal{L}}{\partial f} - \sum_{i} \frac{\partial }{\partial x_{i}} \bigg(\frac{\partial \mathcal{L}}{\partial f^{\prime}_{i}}\bigg) =0 \quad ; \quad f^{\prime}_{i} = \frac{\partial f}{\partial x_{i}}.$

## Non-Local Lagrangian Densities

Consider now a situation in which the Lagrangian density $\mathcal{L}$ depends on the joint behavior of $f$ at $n$ disjoint points $x^{a} \in \mathcal{X}$ indexed by $a \in [n]$, such that the relationship between these points is captured by $[x^{a}] \in \mathcal{M} \subseteq \mathcal{X}^{n}$. That is, we seek to extremize $S(f) = \int_{\mathcal{M}} \mathcal{L}\big([x^{a}], [f(x^{a})], [\nabla f(x^{a})] \big) {~\rm d}{V^{n}}.$ $S(f)$ depends on non-local properties of the function $f$, and $\mathcal{M}$ determines any specific constraints or symmetries of the $n$ points.

Using the same prescription to vary $f$ as above, let ${\rm d} f = g {\rm d}\epsilon.$

This time, however, rather than fixing the value of $g$ on $\partial \mathcal{X}$, we will assume either a periodic structure for $\mathcal{M}$, or a Lagrangian density $\mathcal{L}$ that does not depend on $\nabla f(x^{a})$ for all $a$, in order to guarantee

$\begin{equation} \label{eqn-3}\tag{3} \forall g, \quad \int_{\mathcal{M}} \sum_{a \in [nG]} \nabla \cdot \bigg(g(x^{a}) \frac{\partial \mathcal{L}}{f_{i}^{\prime}(x^{a})}\bigg) {~\rm d}{V^{n}} = 0. \end{equation}$

Let us determine the perturbation ${\rm d}S$ to first order in ${\rm d}\epsilon$ by considering perturbations of $f$ and $f^{\prime}$ at each $x^{a}$ separately:

$\begin{equation*} \frac{{\rm d} S}{{\rm d} \epsilon} = \int_{\mathcal{M}} \sum_{a \in [n]}\bigg[ \frac{\partial \mathcal{L}}{\partial f(x^{a})} g(x^{a}) + \sum_{i} \frac{\partial \mathcal{L}}{\partial f^{\prime}_{i}(x^{a})} \bigg( \frac{\partial}{\partial x^{a}_{i}}g(x^{a})\bigg) \bigg] {\rm d}V^{n}. \end{equation*}$

We again integrate by parts, discarding the boundary term by previous assumption (Eq. (3)), and set ${\rm d}S/{\rm d}\epsilon = 0$ at the desired extremum. We obtain

$\begin{equation*} \int_{\mathcal{M}} \sum_{a \in [n]} g(x^{a}) \bigg[ \frac{\partial \mathcal{L}}{\partial f(x^{a})} - \sum_i \frac{\partial}{\partial x^{a}_{i}} \bigg( \frac{\partial \mathcal{L}}{\partial f^{\prime}_{i}(x^a)} \bigg) \bigg] {\rm d}V^{n} = 0. \end{equation*}$

Let us be mathematically explicit about how this equation must hold for all $g$. Specifically, consider perturbations of the form $g(x) = \delta(x - y)$ where $\delta$ is the Dirac delta, for any $y$. It follows that

$\begin{equation} \label{eqn-4}\tag{4} \forall y, \quad \sum_{a \in [n]} \int_{\mathcal{M} | x^{a} = y} \bigg[ \frac{\partial \mathcal{L}}{\partial f(x^{a})}\Big|_{x^{a}=y} - \sum_i \frac{\partial}{\partial y_{i}} \bigg( \frac{\partial \mathcal{L}}{\partial f^{\prime}_{i}(x^{a})} \Big|_{x^{a}=y} \bigg) \bigg] {\rm d}V^{n-1} = 0. \end{equation}$

### A Sanity Check

Consider the problem $\min \int_{-\infty}^{\infty} \underbrace{\frac{1}{2}\Big( f(x) + f^{\prime}(x-\pi/2) \Big)^{2}}_{\mathcal{L}(x, f, f^{\prime})} {\rm d}x.$ We know that translations of $f = \sin$ minimize this objective, though we have not excluded other possibilities.

To solve this problem with variational calculus, we redefine the Lagrangian density as $\mathcal{L} = \frac{1}{2}\Big( f(x) + f^{\prime}(z) \Big)^{2},$ and integrate over the manifold $\mathcal{M} = \big\{(x, z) \colon z = x - \pi / 2 \big\}.$

Applying Eq. (4), we have

$\begin{equation*} \forall y, \quad \bigg[ f(y) + f^{\prime}(z) \bigg]_{z=y-\pi/2} + \bigg[ -\Big( f^{\prime}(x) + f^{\prime\prime}(y) \Big) \bigg]_{y=x-\pi/2} = 0. \end{equation*}$

Therefore,

$\begin{equation*} f^{\prime\prime}(y) = f(y) + f^{\prime}(y-\pi/2) - f^{\prime}(y+\pi/2). \end{equation*}$

Indeed, translations of $\sin$ solve this equation, as hoped. Without ruling out other solutions, Eq. (4) at least passes this test.