Calculus of Variations#
The Discrete Picture#
Most presentations of the calculus of variations use the functional formulation, which often requires careful manipulations of the integration by parts formula to derive the corresponding Euler-Lagrange equations. Here we present an alternative perspective afforded by considering the discrete version of the problem.
Consider a function \(f(x)\) represented by the vector \(\vect{f}\): \(f_{n} = f(x_n)\) at a set of equally spaced points \(x_n\) with spacing \(\d{x} = a = x_{n+1} - x_{n}\). The goal is to minimize (or more generally, extremize) some functional
In the discrete case, \(E(\vect{f})\) just becomes a scalar valued function of the vector \(\vect{f}\), and the equations of motion simply amount to
The advantage of this formulation is that, if you are careful, you have a numerically exact minimization problem and corresponding gradient that can be used to solve the system with a stable algorithm like L-BFGS-M which is suitable for large-scale problems.
Of course, to do this, you must carefully specify terms like the derivative \(\dot{\vect{f}} = \mat{D}\vect{f}\) which might enter \(E(\vect{f})\). If using a finite-difference approximation, one might have
The resulting equations of motion will have terms with \(\mat{D}^{T} = -\mat{D}\), accounting for the minus sign obtained after integrating by parts. This exact relationship \(\mat{D}^{T} = -\mat{D}\) follows from the explicit choice of boundary conditions – Dirichlet here for \(\mat{D}_{d}\) and periodic for \(\mat{D}_{p}\), and imply vanishing boundary terms in the equations of motion. Other choices of boundary conditions might require corrections to this relation, corresponding to non-vanishing boundary terms in the usual functional derivative.
Example
Consider a general functional of the form
A discretized version might look like
We can now explicitly compute the variation, noting that \(\partial f_m/\partial f_n = \delta_{mn}\):
This is exact: all subtleties about boundary conditions etc. will explicitly contained in the relationship between \(\mat{D}^T \approx -\mat{D}\). If the boundary conditions are such that \(\mat{D}^T = -\mat{D}\) exactly, we obtain the usual Euler-Lagrange equations
Catenary#
What is the shape of a thin rope of linear mass density \(\lambda\) and fixed length \(L_0\) hanging between two hooks? This is a classic problem for calculus of variations. Expressed as an optimization problem, our goal is to minimize the potential energy of the rope while holding the length constant:
The first task is to parameterize the rope. A straightforward approach is to express it as a function \(y(x)\) subject to the boundary conditions \(y(x_0) = y_0\) and \(y(x_1) = y_1\). The length and potential energy are then given by the functionals \(L[y]\) and \(E[y]\) respectively:
The differentials can be expressed as:
giving the definite integrals
Direct Approach#
The constraint can be enforced by using the method of sec:LagrangeMultipliers, thus we look for extremal points of the functional
To simplify this, we write the integrand in terms of the function \(\mathcal{L}(y, y', x)\), which is the analogue of the Lagrangian in classical mechanics.
The solution to the extremization problem follows the usual approach of calculus of variations, which yields the Euler-Lagrange equation:
Using our functional form, this gives the following solution for the catenary:
Expanding, then simplifying, we have
Expressing, \(y'' = \d{y'}/d{y} y'\), this separates:
However, even after solving this, we still have another integration to perform. Maybe there is a better way…
Alternative Strategies#
Let’s see if some other formulations might have helped us. Consider two expressions of the solution: \(y(x)\) as we have done above with the independent variable \(x\) (the analog of \(t\) in Lagrangian mechancs), and the inverse \(x(y)\) which switches the roll so that \(y\) is the independent variable. We can express the extremization problem in terms of the following two Lagrangians:
Conservation Laws#
Notice that \(\mathcal{L}_x(y, y', x)\) is independent of \(x\). This is the equivalent of a classical Lagrangian being time-independent, and Noether’s theorem tells us that the corresponding Hamiltonian is conserved:
Similarly, \(\mathcal{L}_y(x, x', y)\) is independent of \(x\). This makes the conserved quantity a little more obvious since, from the Euler-Lagrange equations:
It turns out that these two conserved quantities are equivalent, and this trick of exchanging the dependent and independent variables works in classical mechanics to derive the conserved Hamiltonian. In any case, it should be pretty apparent that this latter form is simpler to evaluate:
Simplifying, and replacing \(x'(y) = 1/y'(x)\), we obtain
where \(c\) is a constant.
Note
This is considerably simpler than the direct approach. When presented with a somewhat complicated problem, it can be worth your time to first consider the general form of the problem and try a few general approaches to see if you can find one that might be computationally simpler before delving into the algebraic details.
This is also separable:
The integral here has the form
which can be found in common tables.
Full Solution
Once can also check a partially remembered answer. I recall that the solution for a catenary is somehow related to the hyperbolic functions. Practical experience with hanging ropes suggest it is probably something of the form:
If \(ab = 1\), then \(1+(y')^2 = 1+\sinh^2(bx+c) = \cosh^2(bx+c)\) which is almost right, but won’t get the constant \(\mu\). We can get this by adding a constant, and a bit more through suggest the following form which has a minimum at \((x_{\min}, y_{\min})\):
This is exactly the solution if
This has three parameters \(a\), \(x_{\min}\), and \(y_{\min}\), allowing us to satisfy the three constraints \(y(x_0) = y_0\), \(y(x_1) = y_1\), and \(L[y] = L_0\). The length equation becomes:
The algebra can be simplified considerably by choosing the origin at the minimum \(x_{\min} = 0\), \(y_{\min} = 0\). This implies \(x_0 = -x_1\) and \(y_0 = y_1\):
As a final check, one should make sure that no errors were made multiplying or dividing by zero, and that this is indeed a minimum, not a maximum or saddle point. The latter check is fairly easy on physical grounds if we make sure \(a, x_1 >0\). The maximum energy has a form with \(a, x_1<0\) – an inverted catenary.
As a final check, let’s compute the conserved Hamiltonian from the first approach:
which gives the same equation as the second approach:
Geodesics#
A final application goes back to geometry – the computation of geodesics on a manifold \(M\). Consider a path \(X(t)\) in our coordinate chart corresponding to the path \(x(t)\). We can obtain the length of the path by integrating the speed:
Holding the endpoints and \(t\) fixed, we can view the path-length as a functional of the path:
The geodesic equation is thus the corresponding Euler-Lagrange equation
Using the symmetry of \(g_{\alpha\beta} = g_{\beta\alpha}\) and the fact that each term of the lhs is symmetric under \(\alpha \leftrightarrow \beta\), we can rewrite this in terms of the Christoffel symbols: