Home / Articles / University Mathematics
University Mathematics · 5 min read

Calculus of Variations and the Euler–Lagrange Equation

Learn the calculus of variations from scratch: derive the Euler–Lagrange equation and solve worked problems on shortest paths, functionals and mechanics.

Ordinary calculus finds the number that minimises a function. The calculus of variations goes one level higher: it finds the whole function, or curve, that minimises a quantity such as length, time or energy. From the shape of a hanging cable to the laws of motion in physics, the Euler–Lagrange equation is the key tool, and this guide derives it and applies it step by step.

Functionals: Functions of Functions

A functional takes a function and returns a number. The standard form is

$$ J[y] = \int_a^b F\big(x, y(x), y'(x)\big)\,dx, $$

where \(y\) is required to satisfy fixed boundary conditions \(y(a) = A\) and \(y(b) = B\). Some examples:

  • Arc length of a curve: \(F = \sqrt{1 + y'^2}\).
  • Travel time of a sliding bead: \(F = \sqrt{1 + y'^2}/\sqrt{2gy}\), the brachistochrone problem.
  • Action in mechanics: \(F = T - V\), kinetic minus potential energy.

The goal is to find \(y\) that makes \(J[y]\) stationary (usually a minimum).

A Little History

In June 1696, Johann Bernoulli challenged the mathematicians of Europe to find the curve of fastest descent between two points, the brachistochrone. Solutions came from Johann himself, his brother Jakob, Leibniz, l'Hôpital and, anonymously, Isaac Newton; the answer is an arc of a cycloid. Leonhard Euler developed a general method in the 1740s, and in 1755 the 19-year-old Joseph-Louis Lagrange sent Euler a cleaner analytic approach using "variations". Euler adopted it and named the subject the calculus of variations.

Deriving the Euler–Lagrange Equation

Suppose \(y\) is the minimiser. Perturb it: \(y_\varepsilon = y + \varepsilon\eta\), where \(\eta\) is any smooth function with \(\eta(a) = \eta(b) = 0\), so the boundary conditions still hold. Then \(\Phi(\varepsilon) = J[y + \varepsilon\eta]\) has a minimum at \(\varepsilon = 0\), so \(\Phi'(0) = 0\).

Step 1: Differentiate under the integral.

$$ \Phi'(0) = \int_a^b \left( \frac{\partial F}{\partial y}\eta + \frac{\partial F}{\partial y'}\eta' \right) dx = 0. $$

Step 2: Integrate the second term by parts.

$$ \int_a^b \frac{\partial F}{\partial y'}\eta'\,dx = \left[\frac{\partial F}{\partial y'}\eta\right]_a^b - \int_a^b \frac{d}{dx}\left(\frac{\partial F}{\partial y'}\right)\eta\,dx. $$

The boundary term vanishes because \(\eta(a) = \eta(b) = 0\).

Step 3: Combine.

$$ \int_a^b \left( \frac{\partial F}{\partial y} - \frac{d}{dx}\frac{\partial F}{\partial y'} \right)\eta\,dx = 0 \quad \text{for every admissible } \eta. $$

Step 4: Apply the fundamental lemma of the calculus of variations: if \(\int g\eta = 0\) for all such \(\eta\) and \(g\) is continuous, then \(g \equiv 0\). This gives the Euler–Lagrange equation

$$ \frac{\partial F}{\partial y} - \frac{d}{dx}\left(\frac{\partial F}{\partial y'}\right) = 0. $$

Two Useful Shortcuts

  • If \(F\) does not depend on \(y\), then \(\partial F/\partial y' = \text{constant}\).
  • If \(F\) does not depend on \(x\) explicitly, the Beltrami identity holds:

$$ F - y'\frac{\partial F}{\partial y'} = C. $$

Worked Example 1: The Shortest Path in a Plane

Find the curve of minimum length joining \((0, 0)\) and \((1, 2)\).

Step 1: Set up. \(J[y] = \int_0^1 \sqrt{1 + y'^2}\,dx\), so \(F = \sqrt{1 + y'^2}\).

Step 2: Note \(F\) has no \(y\), so \(\partial F/\partial y = 0\) and

$$ \frac{\partial F}{\partial y'} = \frac{y'}{\sqrt{1 + y'^2}} = c. $$

Step 3: Solve for \(y'\). Squaring, \(y'^2 = c^2(1 + y'^2)\), so \(y'^2 = c^2/(1 - c^2)\), a constant. Hence \(y' = m\) and \(y = mx + k\).

Step 4: Apply boundary conditions. \(y(0) = 0\) gives \(k = 0\); \(y(1) = 2\) gives \(m = 2\). So \(y = 2x\).

Sanity check: the minimal length is \(\int_0^1\sqrt{1 + 4}\,dx = \sqrt5 \approx 2.236\), exactly the straight-line distance \(\sqrt{1^2 + 2^2}\). Our intuition is confirmed by the calculus.

Worked Example 2: Minimising an Energy-Type Functional

Find the extremal of

$$ J[y] = \int_0^1 \left( y'^2 + 12xy \right) dx, \qquad y(0) = 0,\ y(1) = 1. $$

Step 1: Partial derivatives. \(F = y'^2 + 12xy\), so \(\dfrac{\partial F}{\partial y} = 12x\) and \(\dfrac{\partial F}{\partial y'} = 2y'\).

Step 2: Euler–Lagrange equation.

$$ 12x - \frac{d}{dx}(2y') = 0 \quad\Longrightarrow\quad y'' = 6x. $$

Step 3: Integrate twice. \(y' = 3x^2 + C_1\), then \(y = x^3 + C_1 x + C_2\).

Step 4: Boundary conditions. \(y(0) = 0\) gives \(C_2 = 0\). \(y(1) = 1\) gives \(1 + C_1 = 1\), so \(C_1 = 0\). Therefore

$$ y(x) = x^3. $$

Step 5: Sanity check by comparison. For \(y = x^3\): \(y'^2 = 9x^4\) and \(12xy = 12x^4\), so \(J = \int_0^1 21x^4\,dx = \tfrac{21}{5} = 4.2\). For the competitor \(y = x\) (same endpoints): \(J = \int_0^1 (1 + 12x^2)\,dx = 1 + 4 = 5\). Since \(4.2 < 5\), our extremal does better. Because \(F\) is convex in \(y'\) and linear in \(y\), the extremal is in fact the global minimum.

Worked Example 3: A Second-Order Linear Case

Find the extremal of \(J[y] = \int_0^1 (y'^2 + y^2)\,dx\) with \(y(0) = 0\), \(y(1) = 1\).

Step 1. \(\partial F/\partial y = 2y\) and \(\partial F/\partial y' = 2y'\), so the equation is \(2y - 2y'' = 0\), that is \(y'' = y\).

Step 2. The general solution is \(y = C_1\sinh x + C_2\cosh x\).

Step 3. \(y(0) = 0\) forces \(C_2 = 0\); \(y(1) = 1\) gives \(C_1 = 1/\sinh 1\). So

$$ y(x) = \frac{\sinh x}{\sinh 1}, \qquad \sinh 1 \approx 1.1752. $$

At \(x = 0.5\), \(y \approx 0.5211/1.1752 \approx 0.443\), slightly below the straight line's value of 0.5, because the \(y^2\) term rewards keeping \(y\) small.

Constraints and Lagrange Multipliers

Many problems have a constraint \(K[y] = \int_a^b G\,dx = L\), such as fixed length. You then apply the Euler–Lagrange equation to \(F - \lambda G\), where \(\lambda\) is a Lagrange multiplier. This approach solves the isoperimetric problem (the circle encloses the most area for a given perimeter) and the catenary, the shape \(y = a\cosh(x/a)\) of a hanging chain, which is seen in power lines.

Connection to Physics

With \(F = L = T - V\) and time as the variable, the Euler–Lagrange equation becomes Lagrange's equation of motion. For a mass on a spring, \(L = \tfrac12 m\dot{x}^2 - \tfrac12 kx^2\), so \(\partial L/\partial x = -kx\) and \(\partial L/\partial \dot x = m\dot x\), giving \(m\ddot{x} = -kx\): Newton's second law, recovered from a minimisation principle. This principle of least action extends to electromagnetism, relativity and quantum field theory.

Did You Know?

  • The brachistochrone (a cycloid) is also the tautochrone: a bead released anywhere on it reaches the bottom in the same time, a fact Christiaan Huygens used in pendulum clock design around 1673.
  • Soap films naturally form minimal surfaces, which are solutions of a two-dimensional Euler–Lagrange equation.
  • Modern optimal control, used to plan rocket trajectories, is a direct descendant of the calculus of variations.

Key Takeaways

  • A functional assigns a number to a function; we seek the function that makes it stationary.
  • The Euler–Lagrange equation \(\partial F/\partial y - \frac{d}{dx}(\partial F/\partial y') = 0\) comes from perturbing the solution and integrating by parts.
  • Use the shortcuts: no \(y\) means \(\partial F/\partial y'\) is constant; no \(x\) means the Beltrami identity.
  • Always apply the boundary conditions and sanity-check by comparing with a simple competitor curve.

Need help setting up a variational problem or solving the resulting differential equation? Amathify's experts and PhD scholars provide step-by-step solutions and assignment help via WhatsApp or the Ask a Question form.

Stuck on a problem or assignment?

Our experts and PhD scholars solve maths, physics and chemistry — step by step.

WhatsApp usAsk a question

Related articles