The calculus of variations lays the mathematical groundwork
for Lagrangian mechanics.
Consider a functionalJ, mapping a function f(x) to a scalar value
by integrating over the so-called LagrangianL,
which represents an expression involving x, f and the derivative f′:
J[f]=∫x0x1L(f,f′,x)dx
If J in some way measures the physical “cost” (e.g. energy) of
the path f(x) taken by a physical system,
the principle of least action states that f will be a minimum of J[f],
so for example the expended energy will be minimized.
In practice, various cost metrics may be used,
so maxima of J[f] are also interesting to us.
If f(x,ε=0) is the optimal route, then a slightly
different (and therefore worse) path between the same two points can be expressed
using the parameter ε:
f(x,ε)=f(x,0)+εη(x)orδf=εη(x)
Where η(x) is an arbitrary differentiable deviation.
Since f(x,ε) must start and end in the same points as f(x,0),
we have the boundary conditions:
η(x0)=η(x1)=0
Given L, the goal is to find an equation for the optimal path f(x,0).
Just like when finding the minimum of a real function,
the minimum f of a functional J[f] is a stationary point
with respect to the deviation weight ε,
a condition often written as δJ=0.
In the following, the integration limits have been omitted:
The goal is to turn each η(n)(x) into η(x), so we need to
partially integrate the nth term of the sum n times. In this case,
we will need some additional boundary conditions for η(x):
η′(x0)=η′(x1)=0⋯η(N−1)(x0)=η(N−1)(x1)=0
This eliminates the boundary terms from partial integration, leaving:
0=∫η(∂f∂L+n∑(−1)ndxndn(∂f(n)∂L))dx
Once again, because η(x) is arbitrary, the Euler-Lagrange equation becomes:
0=∂f∂L+n∑(−1)ndxndn(∂f(n)∂L)
Multiple coordinates
Suppose now that f is a function of multiple variables.
For brevity, we only consider two variables x and y,
but the results generalize effortlessly to larger amounts.
The Lagrangian now depends on all the partial derivatives of f(x,y):
J[f]=∬(x0,y0)(x1,y1)L(f,fx,fy,x,y)dxdy
The arbitrary deviation η is then also a function of multiple variables:
f(x,y;ε)=f(x,y;0)+εη(x,y)
The derivation procedure starts in the exact same way as before:
But now, to eliminate these boundary terms, we need extra conditions for η:
∀y:η(x0,y)=η(x1,y)=0∀x:η(x,y0)=η(x,y1)=0
In other words, the deviation η must be zero on the whole “box”.
Again relying on the fact that η is arbitrary, the Euler-Lagrange
equation is:
0=∂f∂L−dxd(∂fx∂L)−dyd(∂fy∂L)
This generalizes nicely to functions of even more variables x1,x2,...,xN:
0=∂f∂L−n∑dxnd(∂fxn∂L)
Constraints
So far, for multiple functions f1,...,fN,
we have been assuming that all fn are independent, and by extension all ηn.
Suppose that we now have M<N constraints ϕm
that all fn need to obey, introducing implicit dependencies between them.
Let us consider constraints ϕm of the two forms below.
It is important that they are holonomic,
meaning they do not depend on any derivatives of any fn(x):
Where Cm is a constant.
Note that the first form can also be used for ϕm=Cm=0,
by simply redefining the constraint as ϕm0=ϕm−Cm=0.
To solve this constrained optimization problem for fn(x),
we introduce Lagrange multipliersλm.
In the former case λm(x) is a function of x, while in the
latter case λm is constant:
The reason for this distinction in λm
is that we need to find the stationary points with respect to ε
of both constraint types. Written in the variational form, this is:
δ∫λmϕmdx=0
From this, we define a new Lagrangian Λ for the functional J,
with the contraints built in:
Using the same logic as before, we end up with a set of Euler-Lagrange equations with Λ:
0=∂fn∂Λ−dxd(∂fn′∂Λ)
By inserting the definition of Λ, we then get the following.
Recall that ϕm is holonomic, and thus independent of all derivatives fn′:
0=∂fn∂L−dxd(∂fn′∂L)+m∑λm∂fn∂ϕm
These are Lagrange’s equations of the first kind,
with their second-kind counterparts being the earlier Euler-Lagrange equations.
Note that there are N separate equations, one for each fn.
Due to the constraints ϕm, the functions fn are not independent.
This is solved by choosing λm such that M of the N equations hold,
i.e. solving a system of M equations for λm:
dxd(∂fn′∂L)−∂fn∂L=m∑λm∂fn∂ϕm
And then the remaining N−M equations can be solved in the normal unconstrained way.