Physics Library
 An open source physics library
Encyclopedia | Forums | Docs | Random |  
Login
create new user
Username:
Password:
forget your password?
Main Menu
Sections

Meta

Talkback

Downloads

Information
[parent] Calculus of Variations: Euler--Lagrange Introductory Exercises and Worked Solutions (Example)

Calculus of Variations: Euler–Lagrange Introductory Exercises and Worked Solutions

This companion entry turns the Euler–Lagrange equation from CV04 into a repeatable problem-solving procedure. The goal is not to memorize

Fy − -d-Fy′ = 0,
     dx
(1)

but to become comfortable reading a functional, computing the two partial derivatives, taking the required total derivative with respect to the independent variable, imposing endpoint data, and interpreting what the result actually proves.

The exercises begin with direct substitutions and linear boundary-value problems. They then introduce a nonlinear integrand, reverse-engineering a Lagrangian from a differential equation, and a final example showing that a stationary function can be a saddle rather than a minimum.

PIC

Figure. A reliable Euler–Lagrange workflow. The derivative in the fourth box is a total derivative along the candidate curve; this is the step most likely to be compressed too aggressively in a first calculation.

1 Exercises

Exercise 1: identify the Euler–Lagrange ingredients

For each integrand below, compute Fy, Fy, and dFy∕dx, then write the Euler–Lagrange differential equation. Do not solve the resulting equation unless it is immediate.

  1. F (y,y′) = 1(y′)2 + V (y).
           2
    (2)

  2. F(x, y,y′) = x(y′)2 + 1-y2.
             2       2
    (3)

  3.     ′   ∘ ------′-2
F (y) =   1 + (y ) .
    (4)

  4. With the independent variable interpreted as time t,
              1       1
F (q,q˙) = -m ˙q2 − --kq2.
          2       2
    (5)

For part (b), explicitly identify the product-rule term that would be missed if one incorrectly wrote

d-(xy′) = xy′′.
dx
(6)

Exercise 2: Dirichlet energy and the straight-line extremal

Consider

         ∫ 1
J [y] = 1-    y′(x)2 dx
       2  0
(7)

on the fixed-endpoint class

𝒜 =  {y ∈ C2 ([0,1]) : y(0) = 0, y(1) = 1} .
(8)

  1. Derive the Euler–Lagrange equation.
  2. Solve the resulting boundary-value problem.
  3. Evaluate J on the stationary curve.
  4. Go beyond Euler–Lagrange and prove directly that this stationary curve is the global minimizer by writing an arbitrary admissible function as y = x + u, where u(0) = u(1) = 0.

Explain carefully which part of the argument establishes stationarity and which part establishes the stronger statement of global minimum.

Exercise 3: a static quadratic energy with a restoring term

Let

       ∫ L [T        K    ]
J [y] =      --(y′)2 +---y2 dx,     T  > 0,  K  > 0,
        0    2        2
(9)

with

y(0) = 0,     y(L) = Y.
(10)

  1. Derive the Euler–Lagrange equation.
  2. Define λ = ∘K--∕T- and solve the boundary-value problem.
  3. Show that the solution can be written
              sinh (λx)
y(x ) = Y --------.
          sinh (λL )
    (11)

  4. Examine the limit K 0 and show that the solution approaches a straight line.

Exercise 4: uniformly forced string or membrane strip

Consider

       ∫  L[ T           ]
J [y] =      --(y ′)2 − f0y dx,     T  > 0,
         0   2
(12)

with fixed endpoints

y (0) = y(L) = 0.
(13)

  1. Derive the Euler–Lagrange equation.
  2. Solve for y(x).
  3. Locate the maximum displacement and find its value.
  4. Explain why the sign of the curvature is consistent with the sign convention used in the potential term f0y.

PIC

Figure. For a constant load f0 > 0, the Euler–Lagrange equation gives a parabolic stationary shape. The fixed endpoints determine the two integration constants after the differential equation has been obtained.

Exercise 5: harmonic oscillator from stationary action

Let

      ∫    [              ]
         Tf 1    2   1   2
S[q] =      --m ˙q −  -kq   dt,
        0   2        2
(14)

with

q(0 ) = 0,    q(Tf) = Q.
(15)

  1. Derive the Euler–Lagrange equation.
  2. Define ω = ∘  -----
   k∕m and solve the equation.
  3. Assuming sin(ωTf)0, show that the unique stationary path satisfying the endpoints is
             sin(ωt)
q(t) = Q ---------.
        sin(ωTf )
    (16)

  4. What special feature occurs when sin(ωTf) = 0? Explain why this is a boundary-value issue rather than a failure of the Euler–Lagrange equation.

Exercise 6: explicit x-dependence and the total derivative

Consider

       ∫ 2 [x        1  ]
J [y] =      --(y ′)2 + -y2  dx.
        1   2        2
(17)

  1. Compute Fy and Fy.
  2. Expand dFy∕dx one algebraic step at a time.
  3. Show that the Euler–Lagrange equation is
       ′′    ′
xy  + y  − y = 0.
    (18)

  4. Explain why replacing dFy∕dx by the partial derivative ∂Fy∕∂x would also give the wrong result in a general problem where Fy depends on y or y.

Exercise 7: a nonlinear derivative energy

Let

         ∫
       1-  1  ′  4
J [y ] = 4    y(x ) dx,     y(0) = 0,  y(1) = 1.
          0
(19)

  1. Derive the Euler–Lagrange equation in the form
    d  (    )
--- (y′)3  = 0.
dx
    (20)

  2. Integrate this equation before expanding it and determine the stationary curve.
  3. If one expands the equation as
        ′2 ′′
3 (y ) y  = 0,
    (21)

    why is dividing immediately by (y)2 a logically unnecessary and potentially misleading step?

  4. Evaluate J on the stationary curve.

Exercise 8: reverse-engineer a Lagrangian

Suppose one wants the Euler–Lagrange equation to reproduce the forced linear oscillator equation

y ′′ + ω2y = f(x).
(22)

  1. Show that
            ′    1  ′2   1  2 2
F (x, y,y ) = -(y ) − --ω y  + f(x)y
             2       2
    (23)

    produces the desired equation.

  2. Explain why adding a constant to F does not change the Euler–Lagrange equation.
  3. Verify directly that adding the total derivative dG(x,y)∕dx to F changes the action only by endpoint terms when the endpoints are fixed.

Exercise 9: stationary does not mean minimum

Consider

         ∫
       1   1[  ′ 2     2 2]
J [y] = --    (y ) −  4π y  dx,     y(0) = y (1 ) = 0.
       2  0
(24)

  1. Show that y = 0 satisfies the Euler–Lagrange equation and is therefore stationary.
  2. Evaluate J on the one-parameter family
    y = 𝜖sin(πx ).
    (25)

  3. Evaluate J on the one-parameter family
    y =  𝜖sin (3πx).
    (26)

  4. Use the two signs obtained above to classify y = 0 locally along these two directions. Why does the Euler–Lagrange equation alone not contain this classification information?

PIC

Figure. The same stationary function y = 0 can be approached along directions that decrease J and directions that increase J. The Euler–Lagrange equation detects stationarity, not this second-order classification.

2 Solutions

Solution 1: identify the Euler–Lagrange ingredients

The Euler–Lagrange equation is

F  − -d-F ′ = 0.
 y   dx  y
(27)

(a) For

     1   ′2
F  = 2-(y ) +  V(y ),
(28)

we have

        ′               ′
Fy =  V (y),     Fy′ = y .
(29)

Hence

 d
---Fy′ = y′′,
dx
(30)

and the Euler–Lagrange equation is

|---------------|
|V ′(y ) − y′′ = 0 .
----------------
(31)

(b) For

     x        1
F =  -(y′)2 + -y2,
     2        2
(32)

we obtain

Fy = y,     Fy′ = xy′.
(33)

Now the product rule is essential:

-d-   ′     ′     ′′
dx (xy ) = y + xy  .
(34)

Therefore

      ′     ′′
y − (y +  xy ) = 0,
(35)

or

|----------------|
xy-′′ +-y-′ −-y-=-0-.
(36)

The term yis exactly the term lost by the incorrect replacement d(xy)∕dx = xy′′.

(c) For

    ∘  ---------
F =    1 + (y ′)2,
(37)

we have

                        ′
              ′   ∘---y------
Fy = 0,     Fy =    1 + (y′)2.
(38)

Thus

   (      ′    )
d--  ∘---y------  = 0.
dx     1 + (y′)2
(39)

Differentiating gives

     y′′
-------′2-3∕2 = 0,
(1 + (y) )
(40)

so any regular stationary graph satisfies

|------|
y′′ =-0-.
(41)

(d) Treating t as the independent variable,

F =  1m ˙q2 − 1kq2
     2       2
(42)

gives

Fq = − kq,     F˙q = m ˙q.
(43)

Hence

        d
− kq − -- (m q˙) = 0.
       dt
(44)

For constant m,

|------------|
m ¨q + kq = 0 .
--------------
(45)

Solution 2: Dirichlet energy and the straight-line extremal

The integrand is

     1  ′ 2
F =  -(y ) .
     2
(46)

Therefore

                    ′
Fy  = 0,    Fy ′ = y .
(47)

Euler–Lagrange gives

   ′′
− y  = 0,
(48)

so

y′′ = 0.
(49)

Integrating twice,

y = C x + C  .
     1      2
(50)

The endpoint y(0) = 0 gives C2 = 0, and y(1) = 1 gives C1 = 1. Thus

|----------|
|y∗(x) = x .
-----------
(51)

Its functional value is

         ∫          |--|
        1   1       |1 |
J[y∗] = --   1 dx = |--.
        2  0        -2-
(52)

The Euler–Lagrange calculation has established stationarity. To prove the global minimum, let any admissible competitor be written

y = x + u,     u(0) = u(1) = 0.
(53)

Then

J[y] = 1-
2 01(1 + u)2 dx (54)
= 1-
2 + 01udx + 1-
2 01(u)2 dx. (55)

The middle term vanishes because

∫
  1  ′
    u dx = u (1 ) − u (0) = 0.
 0
(56)

Hence

             ∫  1
J [y] = 1-+  1-   (u ′)2dx ≥  1.
       2    2  0           2
(57)

Therefore

|------------------------------|
|y =  x is the global minimizer. |
--∗-----------------------------
(58)

The distinction is important: Euler–Lagrange found the candidate; positivity of the remainder proved the minimum.

Solution 3: a static quadratic energy with a restoring term

Here

F =  T-(y′)2 + K--y2.
     2         2
(59)

Thus

                      ′
Fy = Ky,      Fy′ = Ty .
(60)

With constant T,

 d
---Fy′ = Ty ′′.
dx
(61)

Therefore

Ky  − T y′′ = 0,
(62)

or

                      ∘ ---
y′′ − λ2y = 0,     λ =    K-.
                         T
(63)

The general solution is

y = C  sinh (λx ) + C  cosh(λx).
     1             2
(64)

The condition y(0) = 0 gives C2 = 0. Then

Y  = C1 sinh (λL ),
(65)

so

         Y
C1 =  ---------.
      sinh (λL)
(66)

Hence

|------------------|
|         sinh-(λx)-|
y(x ) = Y sinh (λL ) .
--------------------
(67)

As K 0, λ 0. Using sinh z z,

sinh (λx)      x
---------−→   -.
sinh (λL )      L
(68)

Thus

|-------------|
|           x-|
-y(x)-−→--Y-L-,
(69)

which is the straight-line extremal recovered when the restoring term is removed.

Solution 4: uniformly forced string or membrane strip

The integrand is

F =  T-(y ′)2 − f0y.
     2
(70)

Therefore

Fy =  − f0,    Fy′ = T y′.
(71)

Euler–Lagrange gives

− f0 − Ty′′ = 0,
(72)

so

|-----------|
|T y′′ = − f0.
------------
(73)

Integrating twice,

      f0- 2
y = − 2T x  + C1x + C2.
(74)

From y(0) = 0, C2 = 0. From y(L) = 0,

      -f0  2
0 = − 2T L  + C1L,
(75)

so

     f0L
C1 = ----.
      2T
(76)

Thus

|-------------------|
|       -f0         |
|y(x) = 2T x(L −  x).
---------------------
(77)

Differentiate:

        f0
y′(x) =  ---(L −  2x).
        2T
(78)

The maximum occurs at

x =  L,
     2
(79)

and

|------------|
|       f0L2 |
ymax =  -----.
---------8T---
(80)

Because f0 > 0 appears in the functional as f0y, increasing y lowers that potential contribution. The stationary curve therefore bows in the positive y direction, while its second derivative is negative:

 ′′     f0-
y =  − T  < 0.
(81)

Solution 5: harmonic oscillator from stationary action

With

          1   2   1   2
F (q,q˙) = -m ˙q  − --kq ,
          2       2
(82)

we have

Fq = − kq,     F˙q = m ˙q.
(83)

The Euler–Lagrange equation is

− kq − m ¨q = 0,
(84)

or

                      ∘  ---
|-----------|            k
¨q-+-ω2q-=--0 ,    ω =    --.
                         m
(85)

The general solution is

q(t) = A sin(ωt) + B cos(ωt).
(86)

The condition q(0) = 0 gives B = 0. The final condition gives

Q =  A sin(ωTf ).
(87)

If sin(ωTf)0, then

    ----Q----
A = sin(ωTf ),
(88)

and therefore

|-----------------|
|q(t) = Q -sin(ωt)-|.
|        sin(ωTf )|
-------------------
(89)

If sin(ωTf) = 0, the endpoint condition becomes

Q = A sin(ωTf ) = 0.
(90)

Thus, for Q≠0, no solution of the Euler–Lagrange ODE can satisfy those two endpoints. For Q = 0, infinitely many amplitudes A satisfy the endpoint conditions. This is a special property of the boundary-value problem at those time intervals, not a breakdown of Euler–Lagrange theory.

Solution 6: explicit x-dependence and the total derivative

For

     x  ′ 2   1 2
F =  -(y ) +  -y ,
     2        2
(91)

we have

                    ′
Fy = y,     Fy′ = xy .
(92)

Now expand the total derivative carefully:

d--
dxFy = -d-
dx(xy) (93)
= dx
---
dxy+ xdy′
---
dx (94)
= y+ xy′′. (95)

Therefore

      ′     ′′
y − (y +  xy ) = 0,
(96)

which is

|--′′----′--------|
xy--+-y--−-y-=-0-.
(97)

The distinction between partial and total derivatives matters because, in general,

                  ′
Fy′ = Fy′(x,y(x),y (x)).
(98)

Consequently,

d
--Fy′ = Fxy′ + Fyy′y ′ + Fy′y′y′′.
dx
(99)

The partial derivative ∂Fy∕∂x holds y and yfixed; the total derivative follows their variation along the candidate curve.

Solution 7: a nonlinear derivative energy

Here

     1  ′ 4
F =  -(y ) .
     4
(100)

Thus

Fy =  0,    Fy′ = (y′)3.
(101)

Euler–Lagrange gives

|-------------|
|-d-   ′3     |
|dx ((y ) ) = 0|.
---------------
(102)

Integrate before expanding:

  ′3
(y)  = C.
(103)

Since the real cube root is single valued,

y ′ = C1 ∕3 = A,
(104)

so

y =  Ax + B.
(105)

The endpoints give B = 0 and A = 1, hence

|------|
y∗-=-x-.
(106)

If instead we first expand,

3 (y ′)2y′′ = 0,
(107)

then dividing by (y)2 assumes y0. That assumption has not yet been established and is unnecessary. The integrated equation (y)3 = C is cleaner and loses no possible branch.

Finally,

         ∫  1       |--|
J[y ] = 1-   1 dx = |1-.
   ∗    4  0        -4-|
(108)

Solution 8: reverse-engineer a Lagrangian

Take

     1-  ′2   1- 2 2
F  = 2 (y)  − 2ω  y +  f(x)y.
(109)

Then

        2                     ′
Fy = − ω y + f (x),    Fy′ = y .
(110)

Euler–Lagrange gives

   2            ′′
− ω y + f(x) − y  = 0,
(111)

or

|-′′----2---------|
y--+-ω--y =-f(x)-.
(112)

Adding a constant C to F changes neither Fy nor Fy, so the Euler–Lagrange equation is unchanged.

More generally, let

^        -d-
F =  F + dx G (x,y).
(113)

The corresponding functional changes by

J[y] J[y] = abd--
dxG(x,y(x)) dx (114)
= G(b,y(b)) G(a,y(a)). (115)

For fixed endpoint values this difference is the same for every admissible curve, so the interior stationarity equation is unchanged.

Solution 9: stationary does not mean minimum

The integrand is

     1- ′ 2     2 2
F =  2(y ) − 2π  y .
(116)

Therefore

          2             ′
Fy = − 4π y,     Fy′ = y .
(117)

The Euler–Lagrange equation is

    2     ′′
− 4π y − y  = 0,
(118)

or

 ′′     2
y + 4 π y = 0.
(119)

Clearly y = 0 satisfies this equation and the endpoint conditions, so it is stationary.

Now take

y = 𝜖sin(πx ).
(120)

Then

y′ = 𝜖πcos(πx ).
(121)

Using

∫                ∫
  1   2             1   2          1-
    sin (πx )dx =     cos (πx) dx = 2 ,
 0                 0
(122)

we obtain

J[𝜖 sin(πx)] = 1
2-[                ]
  2 2 1     2 21
 𝜖 π  2 − 4π 𝜖 2- (123)
=    2
3π--
 4𝜖2 . (124)

Thus this direction decreases J below J[0] = 0.

For

y =  𝜖sin (3πx),
(125)

we have

y′ = 3π𝜖cos(3πx ),
(126)

so

J[𝜖 sin(3πx)] = 1
--
2[      1        1 ]
 9π2 𝜖2 -−  4π2𝜖2--
       2        2 (127)
= 5π2
-4--𝜖2 . (128)

This direction increases J above zero. Hence arbitrarily close to y = 0 there are admissible functions with both larger and smaller functional values. The stationary function is therefore saddle-like rather than a local minimum or maximum.

The Euler–Lagrange equation is a first-order stationarity condition in function space. Classification requires additional information, such as the second variation developed later in the series.

3 Summary

The exercises establish a reusable Euler–Lagrange workflow:

       ∫ b
J [y] =     F(x,y, y′) dx   =⇒    Fy,   Fy′,  -d-Fy′,  Fy −  d-Fy ′ = 0.
        a                                   dx             dx
(129)

The most important conceptual points are equally reusable:

  • the derivative dFy∕dx is a total derivative along the candidate curve;
  • endpoint conditions are imposed after the Euler–Lagrange differential equation has been obtained in the fixed-endpoint problem;
  • nonlinear Euler–Lagrange equations are often safer to integrate in an unexpanded form before dividing by quantities that might vanish; and
  • satisfying Euler–Lagrange proves stationarity, not minimum classification.

CV04E2 can now specialize these tools to shortest-path problems, while CV04E3 can emphasize nonlinear integrands and more demanding algebra.

Further reading

For complementary treatments of the Euler–Lagrange equation and classical variational problems, see I. M. Gelfand and S. V. Fomin, Calculus of Variations; Robert Weinstock, Calculus of Variations with Applications to Physics and Engineering; Hans Sagan, Introduction to the Calculus of Variations; and Cornelius Lanczos, The Variational Principles of mechanics. These references are useful for comparing notation and for seeing how the same Euler–Lagrange structure appears in analysis, mechanics, geometry, and mathematical physics.


"Calculus of Variations: Euler--Lagrange Introductory Exercises and Worked Solutions" is owned by bloftin.
(view preamble)
View style:
Other names:  CV04E1
Keywords:  calculus of variations, Euler-Lagrange equation, first variation, extremal, stationary function, boundary-value problem, mechanical action, Dirichlet energy, forced string, nonlinear functional

This object's parent.

Cross-references: mathematical physics, mechanics, graph, regular, detects, algebraic, function, differential equation, Lagrangian, CV04

This is version 1 of Calculus of Variations: Euler--Lagrange Introductory Exercises and Worked Solutions, born on 2026-09-12.
Object id is 1199, canonical name is CalculusOfVariationsEulerLagrangeIntroductoryExercisesAndWorkedSolutions.
Accessed 2 times total.

Classification:
Physics Classification02.30.Xx (Calculus of variations)
 02.30.Sa (Functional analysis)
 45.20.Jj (Lagrangian and Hamiltonian mechanics)
Pending Errata and Addenda
None.
Discussion
Style: Expand: Order:

No messages.

Interact
rate | post | correct | update request | add example | add (any)