# 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^{\prime}(x)=\frac{{\rm d}y}{{\rm d}x}$,

 $I(y)=\int_{a}^{b}~{}F(x,y,y^{\prime})~{}{\rm d}x.$

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 ${\rm d}s$ be an element of arc length, the arc length of a curve $y(x)$ from $x=0$ to $x=1$ is $\int_{0}^{1}\;{\rm d}s$. We can use Pythagoras’ theorem to relate ${\rm d}s$ to ${\rm d}x$ and ${\rm d}y$: drawing a triangle with sides of length ${\rm d}x$ and ${\rm d}y$ at right angles to one another, the hypotenuse is $\approx{\rm d}s$ and so ${\rm d}s^{2}={\rm d}x^{2}+{\rm d}y^{2}$ and $\mathrm{s}=\sqrt{\mathrm{d}x^{2}+\mathrm{d}y^{2}}=\sqrt{1+\left(\frac{\mathrm{% d}y}{\mathrm{d}x}\right)^{2}}\mathrm{d}x$. This means the arc length equals $\int_{0}^{1}\sqrt{1+y^{\prime 2}}{\rm d}x$.

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

 $I(y)=\int_{0}^{1}~{}ds=\int_{0}^{1}~{}(1+(y^{\prime})^{2})^{1/2}\;{\rm d}x~{}~% {}~{}~{}\mbox{subject to boundary conditions}~{}~{}y(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 ${\rm C}^{k}[a,b]$ denote the set of continuous functions defined on the interval $a\leq x\leq b$ which have their first $k$-derivatives also continuous on $a\leq x\leq b$.

The proof to follow requires the integrand $F(x,y,y^{\prime})$ 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 $C^{2}[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

 $I(y)=\int_{a}^{b}~{}F(x,y,y^{\prime})~{}{\rm d}x$

defined on all functions $y\in C^{2}[a,b]$ such that $y(a)=A,y(b)=B$, then $Y(x)$ satisfies the second order ordinary differential equation

 $\frac{{\rm d}}{{\rm d}x}\left(\frac{\partial F}{\partial y^{\prime}}\right)-% \frac{\partial F}{\partial y}=0.$ (1)
###### Definition 3.

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

###### Warning 1.

You might be wondering what $\frac{\partial F}{\partial y^{\prime}}$ 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^{\prime}(x)$ for $u,v,w$ and then integrate. The derivative $\frac{\partial F}{\partial y^{\prime}}$ is just the partial derivative of $F$ with respect to its second variable $v$. In other words, to find $\frac{\partial F}{\partial y^{\prime}}$, just pretend $y^{\prime}$ is a variable.

Equally, there’s an important difference between $\frac{{\rm d}F}{{\rm d}x}$ and $\frac{\partial F}{\partial x}$. The former is the derivative of $F$ with respect to $x$, taking into account the fact that $y=y(x)$ and $y^{\prime}=y^{\prime}(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^{\prime}$ are just variables and do not depend on $x$. Hopefully the next example makes this clear:

###### Example 1.

Let $F(x,y,y^{\prime})=2x+xyy^{\prime}+y^{\prime 2}+y$. Then

 $\displaystyle\frac{\partial F}{\partial y^{\prime}}$ $\displaystyle=xy+2y^{\prime}$ $\displaystyle\frac{{\rm d}}{{\rm d}x}\left(\frac{\partial F}{\partial y^{% \prime}}\right)$ $\displaystyle=y+xy^{\prime}+2{y^{\prime}}^{\prime}$ $\displaystyle\frac{\partial F}{\partial y}$ $\displaystyle=xy^{\prime}+1$ $\displaystyle\frac{\partial F}{\partial x}$ $\displaystyle=2+yy^{\prime}$ $\displaystyle\frac{{\rm d}F}{{\rm d}x}$ $\displaystyle=2+yy^{\prime}+xy\prime^{2}+xyy\prime\prime+2y\prime\prime y% \prime+{y\prime}$

and the Euler–Lagrange equation is

 $y+xy^{\prime}+2{y^{\prime}}^{\prime}=xy^{\prime}+1$
###### 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.

###### Proof.

Consider functions $Y_{\epsilon}(x)$ of the form

 $Y_{\epsilon}(x)=Y(x)+\epsilon\eta(x)$

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

 $I[\epsilon]=\int^{b}_{a}~{}F(x,Y_{\epsilon},Y_{\epsilon}^{\prime})~{}{\rm d}x.$

When $\epsilon=0$, the function $I[\epsilon]$ has an extremum and so

 $\frac{{\rm d}I}{{\rm d}\epsilon}=0~{}~{}~{}~{}\mbox{when}~{}~{}~{}~{}\epsilon=0.$

We can compute the derivative $\frac{{\rm d}I}{{\rm d}\epsilon}$ by differentiating under the integral sign:

 $\frac{{\rm d}I}{{\rm d}\epsilon}=\frac{{\rm d}}{{\rm d}\epsilon}\int^{b}_{a}F(% x,Y_{\epsilon},Y_{\epsilon}^{\prime})~{}{\rm d}x=\int^{b}_{a}\frac{{\rm d}F}{{% \rm d}\epsilon}(x,Y_{\epsilon},Y_{\epsilon}^{\prime})~{}{\rm d}x$

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

 $\frac{{\rm d}F}{{\rm d}\epsilon}=\frac{\partial F}{\partial u}\frac{{\rm d}u}{% {\rm d}\epsilon}+\frac{\partial F}{\partial v}\frac{{\rm d}v}{{\rm d}\epsilon}% +\frac{\partial F}{\partial w}\frac{{\rm d}w}{{\rm d}\epsilon}.$

In our case, the first argument $x$ is independent of $\epsilon$, so $\frac{{\rm d}x}{{\rm d}\epsilon}=0$, and since $Y_{\epsilon}=Y+\epsilon\eta$ we have $\frac{{\rm d}Y_{\epsilon}}{{\rm d}\epsilon}=\eta$ and $\frac{{\rm d}Y_{\epsilon}^{\prime}}{{\rm d}\epsilon}=\eta^{\prime}$. Therefore

 $\frac{{\rm d}F}{{\rm d}\epsilon}(x,Y_{\epsilon},Y_{\epsilon}^{\prime})=\frac{% \partial F}{\partial y}\,\eta(x)+\frac{\partial F}{\partial y^{\prime}}\,\eta^% {\prime}(x).$

Recall that $\frac{{\rm d}I}{{\rm d}\epsilon}=0$ when $\epsilon=0$. Since $Y_{0}=Y$ and $Y_{0}^{\prime}=Y^{\prime}$,

 $0=\int_{a}^{b}\frac{\partial F}{\partial y}(x,Y,Y^{\prime})\eta(x)+\frac{% \partial F}{\partial y^{\prime}}(x,Y,Y^{\prime})\eta^{\prime}(x)~{}{\rm d}x.$ (2)

Integrating the second term in (2) by parts

 $\int_{a}^{b}\frac{\partial F}{\partial y^{\prime}}\eta^{\prime}(x)~{}{\rm d}x=% \left[\frac{\partial F}{\partial y^{\prime}}\eta(x)\right]^{b}_{a}-\int_{a}^{b% }\frac{{\rm d}}{{\rm d}x}\left(\frac{\partial F}{\partial y^{\prime}}\right)% \eta(x)~{}{\rm d}x.$

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

 $\int^{b}_{a}\,\left(\frac{\partial F}{\partial y}-\frac{{\rm d}}{{\rm d}x}% \frac{\partial F}{\partial y^{\prime}}\right)\eta(x)~{}{\rm d}x=0.$

The equation above holds for any $\eta(x)\in C^{2}[a,b]$ satisfying $\eta(a)=\eta(b)=0$, so the fundamental lemma of calculus of variations (explained on the next page) tells us that $Y(x)$ satisfies

 $\frac{{\rm d}}{{\rm d}x}\left(\frac{\partial F}{\partial y^{\prime}}\right)-% \frac{\partial F}{\partial y}=0.\qed$
###### 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

 $I(y)=\int_{0}^{1}(y^{\prime}-y)^{2}~{}{\rm d}x,~{}~{}~{}~{}~{}~{}y(0)=0,~{}y(1% )=2,~{}~{}~{}~{}\left[\mbox{Answer:}~{}~{}y(x)=2\frac{\sinh{x}}{\sinh{1}}% \right].$
###### 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

 $I[y]=\int_{1}^{2}x^{2}(y^{\prime})^{2}+y~{}{\rm d}x,~{}~{}~{}~{}~{}~{}y(1)=1,~% {}y(2)=1,~{}~{}~{}~{}\left[\mbox{Answer:}~{}~{}y(x)=\frac{1}{2}\ln{x}+\frac{% \ln{2}}{x}+1-\ln{2}\right].$

## 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 $\eta(x)\in C^{2}[a,b]$ such that $\eta(a)=\eta(b)=0$ we have

 $\int_{a}^{b}~{}y(x)\eta(x)~{}{\rm d}x=0.$

Then $y(x)=0$ for all $a\leq x\leq b$.

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

Consider the function $\eta:[a,b]\to\mathbb{R}$ defined by

 $\eta(x)=\begin{cases}(x-\alpha_{0})^{4}(x-\alpha_{1})^{4}&\alpha_{0}

$\eta$ is in $C^{2}[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:

By hypothesis, $\int_{0}^{1}y(x)\eta(x)\;{\rm d}x=0$. But $y(x)\eta(x)$ is continuous, zero outside $(\alpha_{0},\alpha_{1})$, and strictly positive for all $x\in(\alpha_{0},\alpha_{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

 $\frac{1}{2}mv^{2}=mgx$

so that

 $v=\sqrt{2gx}.$

Noting also that distance $s$ along the curve $s$ satisfies $ds^{2}=dx^{2}+dy^{2}$, we can express the time $T(y)$ taken for the particle to descend along the curve $y=y(x)$ as a functional:

 $T(y)=\int^{B}_{A}\,dt=\int^{B}_{A}\,\frac{ds}{ds/dt}=\int^{B}_{A}\,\frac{ds}{v% }=\int^{h}_{0}\,\frac{\sqrt{1+(y^{\prime})^{2}}}{\sqrt{2gx}}\,{\rm d}x,~{}~{}~% {}\mbox{subject to}~{}~{}~{}y(0)=0,~{}y(h)=a.$

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

 $\frac{d}{dx}\left(\frac{y^{\prime}}{\sqrt{2gx(1+(y^{\prime})^{2})}}\right)=0,~% {}~{}~{}y(0)=0,~{}y(h)=a.$

Integrating this, we get

 $\frac{y^{\prime}}{\sqrt{2gx(1+(y^{\prime})^{2})}}=c$

where $c$ is a constant, and rearranging

 $y^{\prime}=\frac{dy}{dx}=\frac{\sqrt{x}}{\sqrt{\alpha-x}},~{}~{}~{}~{}\mbox{% with}~{}~{}\alpha=\frac{1}{2gc^{2}}.$

We can integrate this equation using the substitution $x=\alpha\sin^{2}{\theta}$ to obtain

 $y=\int\,\frac{\sqrt{x}}{\sqrt{\alpha-x}}\,{\rm d}x=\int\,\frac{\sin{\theta}}{% \cos{\theta}}\;2\alpha\sin{\theta}\cos{\theta}\,d\theta=\int\,\alpha(1-\cos{2% \theta})\,d\theta=\frac{\alpha}{2}(2\theta-\sin{2\theta})+k.$

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

 $y(x)=\alpha\sin^{-1}{\left(\sqrt{\frac{x}{\alpha}}\right)}-\sqrt{x}\sqrt{% \alpha-x}.$
###### Definition 5.

This curve is called a cycloid.

The constant $\alpha$ 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)

 $\displaystyle x(\theta)$ $\displaystyle=$ $\displaystyle\frac{\alpha}{2}(1-\cos{2\theta})$ $\displaystyle y(\theta)$ $\displaystyle=$ $\displaystyle\frac{\alpha}{2}(2\theta-\sin{2\theta})$

and can be constructed by following the locus of the initial point of contact when a circle of radius $\alpha/2$ is rolled (an angle $2\theta$) 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

 $I(y)=\int_{0}^{1}(y^{\prime}-y)^{2}{\rm d}x,$

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

 $I=\int_{a}^{b}~{}F(y,y^{\prime})~{}{\rm d}x$

defined on all functions $y\in C^{2}[a,b]$ such that $y(a)=A,y(b)=B$ then $Y(x)$ satisfies

 $F-y^{\prime}\frac{\partial F}{\partial y^{\prime}}=C$ (3)

for some constant $C$.

###### Definition 6.

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

###### Proof.

Consider

 $\frac{{\rm d}}{{\rm d}x}\left(F-y^{\prime}\frac{\partial F}{\partial y^{\prime% }}\right)=\frac{{\rm d}F}{{\rm d}x}-{y^{\prime}}^{\prime}\frac{\partial F}{% \partial y^{\prime}}-y^{\prime}\frac{{\rm d}}{{\rm d}x}\left(\frac{\partial F}% {\partial y^{\prime}}\right).$ (4)

Using the chain rule to find the $x$-derivative of $F(y(x),y^{\prime}(x))$ gives

 $\frac{{\rm d}F}{{\rm d}x}=y^{\prime}\frac{\partial F}{\partial y}+{y^{\prime}}% ^{\prime}\frac{\partial F}{\partial y^{\prime}}$

so that (4) is equal to

 $y^{\prime}\frac{\partial F}{\partial y}+y\prime\prime\frac{\partial F}{% \partial y^{\prime}}-y^{\prime\prime}\frac{\partial F}{\partial y^{\prime}}-y^% {\prime}\frac{{\rm d}}{{\rm d}x}\frac{\partial F}{\partial y^{\prime}}=y^{% \prime}\left(\frac{\partial F}{\partial y}-\frac{{\rm d}}{{\rm d}x}\frac{% \partial F}{\partial y^{\prime}}\right)$

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

 $F-y^{\prime}\frac{\partial F}{\partial y^{\prime}}=C$

for some constant $C$. ∎

###### Exercise 5.

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

 $I(y)=\int_{0}^{1}(y^{\prime}-y)^{2}~{}{\rm d}x,~{}~{}~{}~{}~{}~{}y(0)=0,~{}y(1% )=2,$

 $y=f(x)=2\frac{\sinh{x}}{\sinh{1}}$

(again).

## 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^{\prime}(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)=\int_{a}^{b}~{}F(x,y,y^{\prime})~{}{\rm d}x,~{}~{}~{}\mbox{subject to}~{}% y(a)=A,~{}y(b)=B,J(y)=\int_{a}^{b}~{}G(x,y,y^{\prime})~{}{\rm d}x=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

 $K(y)=\int_{a}^{b}~{}F(x,y,y^{\prime})+\lambda G(x,y,y^{\prime})\;{\rm d}x$

for some constant $\lambda$.

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

###### Proof.

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

 $Y(x)+\epsilon\eta(x)+\delta\zeta(x)$

where $\epsilon$ and $\delta$ are constants and $\eta(x)$ and $\zeta(x)$ are twice differentiable functions such that $\eta(a)=\zeta(a)=\eta(b)=\zeta(b)=0$, with $\zeta$ chosen so that $Y+\epsilon\eta+\delta\zeta$ obeys the integral constraint.

Consider the functions of two variables

 $I[\epsilon,\delta]=\int_{a}^{b}F(x,Y+\epsilon\eta+\delta\zeta,Y^{\prime}+% \epsilon\eta^{\prime}+\delta\zeta^{\prime})\,{\rm d}x,~{}~{}J[\epsilon,\delta]% =\int_{a}^{b}G(x,Y+\epsilon\eta+\delta\zeta,Y^{\prime}+\epsilon\eta^{\prime}+% \delta\zeta^{\prime})\,{\rm d}x.$

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

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

 $\displaystyle\frac{\partial I}{\partial\epsilon}+\lambda\frac{\partial J}{% \partial\epsilon}$ $\displaystyle=0$ $\displaystyle\frac{\partial I}{\partial\delta}+\lambda\frac{\partial J}{% \partial\delta}$ $\displaystyle=0$

at the point $\epsilon=\delta=0$. Calculating the $\epsilon$ derivative,

 $\displaystyle\frac{\partial I}{\partial\epsilon}[\epsilon,\delta]+\lambda\frac% {\partial J}{\partial\epsilon}[\epsilon,\delta]$ $\displaystyle=$ $\displaystyle\int_{a}^{b}\frac{\partial}{\partial\epsilon}\left(F(x,Y+\epsilon% \eta+\delta\zeta,Y^{\prime}+\epsilon\eta^{\prime}+\delta\zeta^{\prime})+% \lambda G(x,Y+\epsilon\eta+\delta\zeta,Y^{\prime}+\epsilon\eta^{\prime}+\delta% \zeta^{\prime})\right)\,{\rm d}x$ $\displaystyle=$ $\displaystyle\int_{a}^{b}\eta\frac{\partial}{\partial y}\left(F+\lambda G% \right)+\eta^{\prime}\frac{\partial}{\partial y^{\prime}}\left(F+\lambda G% \right)\,{\rm d}x~{}~{}~{}~{}~{}~{}~{}~{}~{}~{}~{}~{}~{}~{}~{}\mbox{(chain rule)}$ $\displaystyle=$ $\displaystyle\int_{a}^{b}\eta\left(\frac{\partial}{\partial y}\left(F+\lambda G% \right)-\frac{{\rm d}}{{\rm d}x}\left(\frac{\partial}{\partial y^{\prime}}% \left(F+\lambda G\right)\right)\right)\,{\rm d}x~{}~{}~{}~{}\mbox{(integration% by parts)}$ $\displaystyle=$ $\displaystyle 0~{}~{}~{}~{}~{}{\mbox{when \epsilon=\delta=0, no matter what % \eta is.}}$

Since this holds for any $\eta$, by the FLCV (Lemma 1) we get

 $(F_{y}+\lambda G_{y})(x,Y,Y^{\prime})+\frac{{\rm d}}{{\rm d}x}(F_{y^{\prime}}+% \lambda G_{y^{\prime}})(x,Y,Y^{\prime})=0$

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 $\lambda$ must be determined at the end using the constraint $J(y)=L$.

###### Exercise 6.

Find an extremal of the functional

 $I(y)=\int_{0}^{1}(y^{\prime})^{2}~{}{\rm d}x,~{}~{}~{}~{}~{}y(0)=y(1)=1,$

subject to the constraint that

 $~{}~{}~{}~{}~{}J(y)=\int_{0}^{1}y~{}{\rm d}x=2.~{}~{}~{}~{}\left[\mbox{Answer:% }~{}~{}y=f(x)=-6\left(x-\frac{1}{2}\right)^{2}+\frac{5}{2}.\right]$
###### 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) 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$.