MATH0043 §2: Calculus of Variations

What is the Calculus of Variations?

Many problems involve finding a function that maximizes or minimizes an integral expression.
One example is finding the curve giving the shortest distance between two points — a straight line, of course, in Cartesian geometry (but can you prove it?) but less obvious if the two points lie on a curved surface (the problem of finding geodesics.)
The mathematical techniques developed to solve this type of problem are collectively known as the calculus of variations.

1 Functionals and Extrema

Typical Problem: Consider a definite integral that depends on an unknown function y(x), as well as its derivative y(x)=dydx,


A typical problem in the calculus of variations involve finding a particular function y(x) to maximize or minimize the integral I(y) subject to boundary conditions y(a)=A and y(b)=B.

Definition 1.

The integral I(y) is an example of a functional, which (more generally) is a mapping from a set of allowable functions to the reals.

We say that I(y) has an extremum when I(y) takes its maximum or minimum value.

2 The Statement of an Example Problem

Consider the problem of finding the curve y(x) of shortest length that connects the two points (0,0) and (1,1) in the plane. Letting ds be an element of arc length, the arc length of a curve y(x) from x=0 to x=1 is 01ds. We can use Pythagoras’ theorem to relate ds to dx and dy: drawing a triangle with sides of length dx and dy at right angles to one another, the hypotenuse is ds and so ds2=dx2+dy2 and s=dx2+dy2=1+(dydx)2dx. This means the arc length equals 011+y2dx.

The curve y(x) we are looking for minimizes the functional

I(y)=01𝑑s=01(1+(y)2)1/2dx  subject to boundary conditionsy(0)=0,y(1)=1

which means that I(y) has an extremum at y(x). It seems obvious that the solution is y(x)=x, the straight line joining (0,0) and (1,1), but how do we prove this?

3 The Euler-Lagrange Equation, or Euler’s Equation

Definition 2.

Let Ck[a,b] denote the set of continuous functions defined on the interval axb which have their first k-derivatives also continuous on axb.

The proof to follow requires the integrand F(x,y,y) to be twice differentiable with respect to each argument. What’s more, the methods that we use in this module to solve problems in the calculus of variations will only find those solutions which are in C2[a,b]. More advanced techniques (i.e. beyond MATH0043) are designed to overcome this last restriction. This isn’t just a technicality: discontinuous extremal functions are very important in optimal control problems, which arise in engineering applications.

Theorem 1.

If I(Y) is an extremum of the functional


defined on all functions yC2[a,b] such that y(a)=A,y(b)=B, then Y(x) satisfies the second order ordinary differential equation

ddx(Fy)-Fy=0. (1)
Definition 3.

Equation (1) is the Euler-Lagrange equation, or sometimes just Euler’s equation.

Warning 1.

You might be wondering what Fy is suppose to mean: how can we differentiate with respect to a derivative? margin: \dbend Think of it like this: F is given to you as a function of three variables, say F(u,v,w), and when we evaluate the functional I we plug in x,y(x),y(x) for u,v,w and then integrate. The derivative Fy is just the partial derivative of F with respect to its second variable v. In other words, to find Fy, just pretend y is a variable.

Equally, there’s an important difference between dFdx and Fx. The former is the derivative of F with respect to x, taking into account the fact that y=y(x) and y=y(x) are functions of x too. The latter is the partial derivative of F with respect to its first variable, so it’s found by differentiating F with respect to x and pretending that y and y are just variables and do not depend on x. Hopefully the next example makes this clear:

Example 1.

Let F(x,y,y)=2x+xyy+y2+y. Then

Fy =xy+2y
ddx(Fy) =y+xy+2y
Fy =xy+1
Fx =2+yy
dFdx =2+yy+xy2+xyy+2yy+y

and the Euler–Lagrange equation is

Warning 2.

Y satisfying the Euler–Lagrange equation is a necessary, but not sufficient, condition for I(Y) to be an extremum. margin: \dbendIn other words, a function Y(x) may satisfy the Euler–Lagrange equation even when I(Y) is not an extremum.


Consider functions Yϵ(x) of the form


where η(x)C2[a,b] satisfies η(a)=η(b)=0, so that Yϵ(a)=A and Yϵ(b)=B, i.e. Yϵ still satisfies the boundary conditions. Informally, Yϵ is a function which satisfies our boundary conditions and which is ‘near to’ Y when ϵ is small.11 1 The function ϵη(x) is known as the variation in Y. I(Yϵ) depends on the value of ϵ, and we write I[ϵ] for the value of I(Yϵ):


When ϵ=0, the function I[ϵ] has an extremum and so

dIdϵ=0  when  ϵ=0.

We can compute the derivative dIdϵ by differentiating under the integral sign:


We now use the multivariable chain rule to differentiate F with respect to ϵ. For a general three-variable function F(u(ϵ),v(ϵ),w(ϵ)) whose three arguments depend on ϵ, the chain rule tells us that


In our case, the first argument x is independent of ϵ, so dxdϵ=0, and since Yϵ=Y+ϵη we have dYϵdϵ=η and dYϵdϵ=η. Therefore


Recall that dIdϵ=0 when ϵ=0. Since Y0=Y and Y0=Y,

0=abFy(x,Y,Y)η(x)+Fy(x,Y,Y)η(x)dx. (2)

Integrating the second term in (2) by parts


The first term on the right hand side vanishes because η(a)=η(b)=0. Substituting the second term into (2),


The equation above holds for any η(x)C2[a,b] satisfying η(a)=η(b)=0, so the fundamental lemma of calculus of variations (explained on the next page) tells us that Y(x) satisfies

Definition 4.

A solution of the Euler-Lagrange equation is called an extremal of the functional.22 2 Don’t confuse this with ‘extremum’. The terminology is standard, e.g. Gelfand and Fomin p.15, but can be confusing.

Exercise 1.

Find an extremal y(x) of the functional

Exercise 2.

By considering y+g, where y is the solution from exercise 1 and g(x) is a variation in y(x) satisfying g(0)=g(1)=0, and then considering I(y+g), show explicitly that y(x) minimizes I(y) in Exercise 1 above. (Hint: use integration by parts, and the Euler–Lagrange equation satisfied by y(x) to simplify the expression for I(y+g)).

Exercise 3.

Prove that the straight line y=x is the curve giving the shortest distance between the points (0,0) and (1,1).

Exercise 4.

Find an extremal function of


MATH0043 Handout: Fundamental lemma of the calculus of variations

In the proof of the Euler-Lagrange equation, the final step invokes a lemma known as the fundamental lemma of the calculus of variations (FLCV).

Lemma 1.

(FLCV). Let y(x) be continuous on [a,b], and suppose that for all η(x)C2[a,b] such that η(a)=η(b)=0 we have


Then y(x)=0 for all axb.

Here is a sketch of the proof. Suppose, for a contradiction, that for some a<α<b we have y(α)>0 (the case when α=a or α=b can be done similarly, but let’s keep it simple). Because y is continuous, y(x)>0 for all x in some interval (α0,α1) containing α.

Consider the function η:[a,b] defined by


η is in C2[a,b] — it’s difficult to give a formal proof without using a formal definition of continuity and differentiability, but hopefully the following plot shows what is going on:

Figure 1: The function η defined above, if a=0,b=1,α0=0.2,α1=0.4.

By hypothesis, 01y(x)η(x)dx=0. But y(x)η(x) is continuous, zero outside (α0,α1), and strictly positive for all x(α0,α1). A strictly positive continuous function on an interval like this has a strictly positive integral, so this is a contradiction. Similarly we can show y(x) never takes values <0, so it is zero everywhere on [a,b].

4 The Brachistochrone

A classic example of the calculus of variations is to find the brachistochrone, defined as that smooth curve joining two points A and B (not underneath one another) along which a particle will slide from A to B under gravity in the fastest possible time.

Using the coordinate system illustrated, we can use conservation of energy to obtain the velocity v of the particle as it makes its descent


so that


Noting also that distance s along the curve s satisfies ds2=dx2+dy2, we can express the time T(y) taken for the particle to descend along the curve y=y(x) as a functional:

T(y)=AB𝑑t=ABdsds/dt=ABdsv=0h1+(y)22gxdx,subject toy(0)=0,y(h)=a.

The brachistochrone is an extremal of this functional, and so it satisfies the Euler-Lagrange equation


Integrating this, we get


where c is a constant, and rearranging


We can integrate this equation using the substitution x=αsin2θ to obtain

y=xα-xdx=sinθcosθ 2αsinθcosθdθ=α(1-cos2θ)𝑑θ=α2(2θ-sin2θ)+k.

Substituting back for x, and using y(0)=0 to set k=0, we obtain

Definition 5.

This curve is called a cycloid.

The constant α is determined implicitly by the remaining boundary condition y(h)=a. The equation of the cycloid is often given in the following parametric form (which can be obtained from the substitution in the integral)

x(θ) = α2(1-cos2θ)
y(θ) = α2(2θ-sin2θ)

and can be constructed by following the locus of the initial point of contact when a circle of radius α/2 is rolled (an angle 2θ) along a straight line.

5 Functionals leading to special cases

When the integrand F of the functional in our typical calculus of variations problem does not depend explicitly on x, for example if


extremals satisfy an equation called the Beltrami identity which can be easier to solve than the Euler–Lagrange equation.

Theorem 2.

If I(Y) is an extremum of the functional


defined on all functions yC2[a,b] such that y(a)=A,y(b)=B then Y(x) satisfies

F-yFy=C (3)

for some constant C.

Definition 6.

(3) is called the Beltrami identity or Beltrami equation.



ddx(F-yFy)=dFdx-yFy-yddx(Fy). (4)

Using the chain rule to find the x-derivative of F(y(x),y(x)) gives


so that (4) is equal to


Since Y is an extremal, it is a solution of the Euler–Lagrange equation and so this is zero for y=Y. If something has zero derivative it is a constant, so Y is a solution of


for some constant C. ∎

Exercise 5.

(Exercise 1 revisited): Use the Beltrami identity to find an extremal of





6 Isoperimetric Problems

So far we have dealt with boundary conditions of the form y(a)=A,y(b)=B or y(a)=A,y(b)=B. For some problems the natural boundary conditions are expressed using an integral. The standard example is Dido’s problem33 3 See Blåsjö - The Isoperimetric Problem for the history.: if you have a piece of rope with a fixed length, what shape should you make with it in order to enclose the largest possible area? Here we are trying to choose a function y to maximise an integral I(y) giving the area enclosed by y, but the fixed length constraint is also expressed in terms of an integral involving y. This kind of problem, where we seek an extremal of some function subject to ‘ordinary’ boundary conditions and also an integral constraint, is called an isoperimetric problem.

A typical isoperimetric problem is to find an extremum of

I(y)=abF(x,y,y)dx,subject toy(a)=A,y(b)=B,J(y)=abG(x,y,y)dx=L.

The condition J(y)=L is called the integral constraint.

Theorem 3.

In the notation above, if I(Y) is an extremum of I subject to J(y)=L, then Y is an extremal of


for some constant λ.

You will need to know about Lagrange multipliers to understand this proof: see the handout on moodle (the constant λ will turn out to be a Lagrange multiplier).


Suppose I(Y) is a maximum or minimum subject to J(y)=L, and consider the two-parameter family of functions given by


where ϵ and δ are constants and η(x) and ζ(x) are twice differentiable functions such that η(a)=ζ(a)=η(b)=ζ(b)=0, with ζ chosen so that Y+ϵη+δζ obeys the integral constraint.

Consider the functions of two variables


Because I has a maximum or minimum at Y(x) subject to J=L, at the point (ϵ,δ)=(0,0) our function I[ϵ,δ] takes an extreme value subject to J[ϵ,δ]=L.

It follows from the theory of Lagrange multipliers that a necessary condition for a function I[ϵ,δ] of two variables subject to a constraint J[ϵ,δ]=L to take an extreme value at (0,0) is that there is a constant λ (called the Lagrange multiplier) such that

Iϵ+λJϵ =0
Iδ+λJδ =0

at the point ϵ=δ=0. Calculating the ϵ derivative,

Iϵ[ϵ,δ]+λJϵ[ϵ,δ] = abϵ(F(x,Y+ϵη+δζ,Y+ϵη+δζ)+λG(x,Y+ϵη+δζ,Y+ϵη+δζ))dx
= abηy(F+λG)+ηy(F+λG)dx      (chain rule)
= abη(y(F+λG)-ddx(y(F+λG)))dx  (integration by parts)
= 0  when ϵ=δ=0, no matter what η is.

Since this holds for any η, by the FLCV (Lemma 1) we get


which says that Y is a solution of the Euler–Lagrange equation for K, as required. ∎

Note that to complete the solution of the problem, the initially unknown multiplier λ must be determined at the end using the constraint J(y)=L.

Exercise 6.

Find an extremal of the functional


subject to the constraint that

J(y)=01ydx=2.  [Answer:y=f(x)=-6(x-12)2+52.]
Exercise 7.

(Sheep pen design problem): A fence of length l must be attached to a straight wall at points A and B (a distance a apart, where a<l) to form an enclosure. Show that the shape of the fence that maximizes the area enclosed is the arc of a circle, and write down (but do not try to solve) the equations that determine the circle’s radius and the location of its centre in terms of a and l.

Suggested reading

There are many introductory textbooks on the calculus of variations, but most of them go into far more mathematical detail that is required for MATH0043. If you’d like to know more of the theory, Gelfand and Fomin’s Calculus of Variations is available in the library. A less technical source is chapter 9 of Boas Mathematical Methods in the Physical Sciences. There are many short introductions to calculus of variations on the web, e.g.

although all go into far more detail than we need in MATH0043. Lastly, as well as the moodle handout you may find

useful as a refresher on Lagrange multipliers.