Skip to content
Tutorials Center
My learning

Topics

Lesson 12 of 44 · Calculus of Variations

Functionals and the Euler-Lagrange Equation

Derive the Euler-Lagrange equation from the idea of a stationary functional, learn the special cases and Beltrami identity, and check solutions with symbolic and numerical Python.

This lesson derives the most important equation of the course. We take a functional S[y] = ∫ L(y, y′, x) dx, perturb the path slightly, demand that the first-order change vanish, and obtain a differential equation that the extremal path must obey. Later, with x replaced by time and y by a generalized coordinate, the same equation becomes the equation of motion of a mechanical system.

The extremal path, a nearby varied path, and a five-line derivation ending in the Euler-Lagrange equation.
Nudge the path by εη(x) with fixed ends and demand no first-order change: out comes the Euler-Lagrange equation.

What you will learn

  • How to derive the Euler-Lagrange equation with a variation εη(x).
  • The meaning of the "fundamental lemma" that justifies the last step.
  • Special cases: L independent of y or of x (the Beltrami identity).
  • How to verify an extremal symbolically and numerically.

Key terms

The Euler-Lagrange equation is ∂L/∂y − d/dx(∂L/∂y′) = 0. A first integral is a quantity, derived from it, that is constant along the extremal. The fundamental lemma: if ∫ f(x) η(x) dx = 0 for every smooth η vanishing at the ends, then f ≡ 0.

The derivation

Let y(x) be an extremal with y(a) and y(b) fixed. Consider the neighbor ỹ(x) = y(x) + ε η(x) with η(a) = η(b) = 0. Then

Text
S(ε) = ∫ₐᵇ L(y + εη, y′ + εη′, x) dx
dS/dε at ε = 0 = ∫ₐᵇ ( ∂L/∂y · η + ∂L/∂y′ · η′ ) dx

The second term contains η′. Integrate it by parts:

Text
∫ₐᵇ ∂L/∂y′ · η′ dx = [ ∂L/∂y′ · η ]ₐᵇ − ∫ₐᵇ d/dx(∂L/∂y′) · η dx

The boundary term vanishes because η(a) = η(b) = 0. Therefore

Text
dS/dε at ε = 0 = ∫ₐᵇ ( ∂L/∂y − d/dx ∂L/∂y′ ) η dx = 0

This must hold for every admissible η. By the fundamental lemma the bracket must vanish at every x:

Text
∂L/∂y − d/dx (∂L/∂y′) = 0

That is the Euler-Lagrange equation. Note the order: take partial derivatives first, treating y and y′ as independent, then differentiate ∂L/∂y′ totally with respect to x. For several unknown functions yᵢ(x) there is one equation per function.

Two useful special cases

L does not depend on y. Then ∂L/∂y = 0, so d/dx(∂L/∂y′) = 0 and

Text
∂L/∂y′ = constant

A first integral appears for free; in mechanics it will be momentum conservation.

L does not depend explicitly on x. Multiply the equation by y′ and combine terms. This gives the Beltrami identity:

Text
L − y′ ∂L/∂y′ = constant

In mechanics, with x → t, this will be conservation of energy.

Worked example: shortest path. For L = √(1 + y′²), L has no y, so ∂L/∂y′ = y′/√(1 + y′²) is constant. That implies y′ is constant: the extremal is a straight line. The EL equation gives y″ = 0, as expected.

Worked example: a spring-like functional. For L = y′² + y² we get ∂L/∂y = 2y and d/dx(2y′) = 2y″, so 2y − 2y″ = 0, that is y″ = y. With y(0) = 0, y(1) = 1 the solution is y = sinh x / sinh 1.

A worked example with numbers

Find the curve through (0, 0) and (1, 1) that minimizes J[y] = ∫₀¹ (y′)² dx. Here L = y′², so ∂L/∂y = 0 and ∂L/∂y′ = 2y′. The Euler-Lagrange equation says d/dx(2y′) = 0, hence y″ = 0, and the straight line y = x with J = 1.

Now test it by brute force. Perturb the line by η(x) = ε sin(πx), which vanishes at both ends. Then y′ = 1 + επ cos(πx) and

Text
J(ε) = ∫₀¹ (1 + επ cos πx)² dx = 1 + 0 + ε²π² · ½ = 1 + ε²π²/2

because the cross term integrates to 0 over the interval. At ε = 0.1 this is 1 + 0.0493 = 1.0493, larger than 1, and the change is of second order in ε. The first-order term is exactly what must vanish at an extremal; the surviving second-order term is positive, so this extremal is actually a minimum.

The logic step by step

  1. Write the varied curve y + εη and expand J to first order in ε.
  2. Integrate the η′ term by parts. The boundary term vanishes because η = 0 at both ends.
  3. What remains is ∫ [∂L/∂y − d/dx(∂L/∂y′)] η dx = 0 for every admissible η.
  4. The fundamental lemma then forces the bracket to be zero everywhere.

Step 4 is not obvious. If the bracket were positive at some point, you could choose a narrow bump η there and make the integral positive, a contradiction. This argument is usually credited to Lagrange, who sent it to Euler in 1755 and introduced the δ notation; Euler's own 1744 derivation used geometric differences and is much messier. Euler later adopted the name "calculus of variations" for the subject.

Choosing the right first integral

If L has no explicit x, the Beltrami identity L − y′ ∂L/∂y′ = const holds. For L = y′² it gives y′² − 2y′² = −y′² = const, so y′ is constant: the same straight line, found in one line. If L has no explicit y, then ∂L/∂y′ = const. Always check which symmetry applies before differentiating.

Common misconceptions

"Stationary means minimum." The EL equation only finds stationary paths. Some are maxima or saddle points, and you need a second-variation test (or physical reasoning) to know which.

"d/dx and ∂/∂x can be swapped." In d/dx(∂L/∂y′) you must include the dependence of y and y′ on x; the partial derivative ∂/∂x would only see explicit x.

"The endpoint condition does not matter." It is essential: it kills the boundary term. Free endpoints give extra natural boundary conditions.

Try it

Let SymPy derive the Euler-Lagrange equations for the two Lagrangians above and solve the second.

Python Euler-Lagrange equations by computer algebra

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Now check numerically that the analytic extremal really minimizes the functional. We discretize y on a grid, hold the endpoints fixed, and let an optimizer minimize S = ∫(y′² + y²) dx. It should land on sinh x / sinh 1.

Python Minimizing a discretized functional

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Check your understanding

Quick check · 6 questions

of 6 answered You scored / 6 · perfect!

  1. 1. What is the Euler-Lagrange equation for L(y, y′, x)?

    The integration by parts produces the minus sign.
  2. 2. Why does the boundary term [∂L/∂y′ · η] vanish?

    The varied paths share the endpoints, so η(a) = η(b) = 0.
  3. 3. If L does not contain y, which quantity is constant along the extremal?

    The EL equation reduces to d/dx(∂L/∂y′) = 0.
  4. 4. For L = √(1 + y′²), the extremal is:

    ∂L/∂y′ constant forces y′ constant.
  5. 5. For L = y′² + y², what differential equation do we get?

    ∂L/∂y = 2y and d/dx(2y′) = 2y″, so 2y − 2y″ = 0.
  6. 6. What does the Beltrami identity say, when L has no explicit x?

    It is a first integral of the Euler-Lagrange equation in that case.

Summary

  • Vary the path y → y + εη with fixed ends, demand dS/dε = 0, integrate by parts and apply the fundamental lemma.
  • The result is ∂L/∂y − d/dx(∂L/∂y′) = 0, one equation for each unknown function.
  • No y in L gives a conserved ∂L/∂y′; no explicit x gives the Beltrami identity L − y′ ∂L/∂y′ = const.
  • Symbolic and numerical checks agree with hand derivations.

Next: Brachistochrone and Shortest Paths