7
Numerical methods of calculus of variations
In the last chapter we focused on analytical solutions. Application problems
in engineering practice, however, may not be easily solved by such techniques,
if solvable at all. Hence, before we embark on applications, it seems prudent to
discuss solution techniques that are amenable for practical problems. These
methods produce approximate solutions and are, as such, called numerical
methods.
It was mentioned in the introduction that the solution of the Euler-Lagrange
diﬀerential equation resulting from a certain variational problem may not be
easy. This gave rise to the idea of directly solving the variational problem.
The classical method is the Euler method.
The most inﬂuential method is that of Ritz. The methods of Galerkin and
Kantorovich, both described in [13], could be considered extensions of Ritz’s.
They are the most well-known by engineers and used in the industry. Finally,
the boundary integral method is also useful for certain kind of engineering
problems.
7.1 Euler’s method
Euler proposed a numerical solution for the variational problem of
I(y)=
x
n
x
0
f(x, y, y
)dx = extremum
with the boundary conditions
y(x
0
)=y
0
; y(x
n
)=y
n
,
by subdividing the interval of the independent variable as
x
i
= x
0
+ i
x
n
x
0
n
; i =1, 2,...,n.
89
90 Applied calculus of variations for engineers
Introducing
h =
x
n
x
0
n
,
the functional may be approximated as
I(y
i
)=
x
1
x
0
f(x
i
,y
i
,y
i
)=h
n1
i=1
f(x
0
+ ih, y
i
,
y
i+1
y
i
h
)dx = extremum.
Here the approximated solution values y
i
are the unknowns and the extremum
may be found by diﬀerentiation:
∂I
∂y
i
=0.
The process is rather simple and follows from Euler’s other work in the nu-
merical solution of diﬀerential equations. For illustration, we consider the
following problem:
I(y)=
1
0
(2xy + y
2
+ y
2
)dx = extremum,
with the boundary conditions
y(0) = y(1) = 0.
Let us subdivide the interval into n = 5 equidistant segments with
h =0.2,
and
x
i
=0.2i.
The approximate functional with the appropriate substitutions becomes
I(y
i
)=0.2
4
i=1
(0.4iy
i
+ y
2
i
+(5(y
i+1
y
i
))
2
).
The computed partial derivatives are
∂I
∂y
1
=0.2(0.4+2y
1
2(y
2
y
1
)
0.04
)=0,
∂I
∂y
2
=0.2(0.8+2y
2
2(y
3
y
2
)
0.04
+
2(y
2
y
1
)
0.04
)=0,
∂I
∂y
3
=0.2(1.2+2y
3
2(y
4
y
3
)
0.04
+
2(y
3
y
2
)
0.04
)=0,
and
∂I
∂y
4
=0.2(1.6+2y
4
+
2y
4
0.04
+
2(y
4
y
3
)
0.04
)=0.
Numerical methods of calculus of variations 91
TA BL E 7 . 1
Accuracy of Euler’s
method
i x
i
y
i
y(x
i
)
1 0.2 -0.0286 -0.0287
2 0.4 -0.0503 -0.0505
3 0.6 -0.0580 -0.0583
4 0.8 -0.0442 -0.0444
This system of four equations yields the values of the approximate solution.
The analytic solution of this problem is
y(x)=x + e
e
x
e
x
e
2
1
.
The comparison of the Euler solution (y
i
) and the analytic solution (y(x
i
)) at
the four discrete points is shown in Table 7.1.
The boundary solutions of y(0) and y(1) = 0 are not shown since they are
in full agreement by deﬁnition.
7.2 Ritz method
Let us consider the variational problem of
I(y)=
x
1
x
0
f(x, y, y
)dx = extremum,
under the boundary conditions
y(x
0
)=y
0
; y(x
1
)=y
1
.
The Ritz method is based on an approximation of the unknown solution
function with a linear combination of certain basis functions. Finite element
or spline-based approximations are the most commonly used and will be the
subject of detailed discussion in Chapters 9 and 11. Let the unknown function
be approximated with
y(x)=α
0
b
0
(x)+α
1
b
1
(x)+...+ α
n
b
n
(x),
where the basis functions are also required to satisfy the boundary conditions
and the coeﬃcients are as yet unknown. Substituting the approximate solu-
tion into the variational problem results in
92 Applied calculus of variations for engineers
I(
y)=
x
1
x
0
f(x, y, y
)dx = extremum.
In order to reach an extremum of the functional, it is necessary that the
derivatives with respect to the unknown coeﬃcients vanish:
∂I(
y)
∂α
i
=0;i =0, 1,...,n.
It is not intuitively clear that the approximated function approaches the
extremum of the original variational problem, but it has been proven, for
example in [13]. Let us just demonstrate the process with a small analytic
example. Consider the variational problem of
I(y)=
1
0
y
2
(x)dx = extremum,
with the boundary conditions
y(0) = y(1) = 0,
and constraint of
1
0
y
2
(x)dx =1.
Since this is a constrained problem, we apply the Lagrange multiplier tech-
nique and rewrite the variational problem as
I(y)=
1
0
(y
2
(x) λy
2
)dx = extremum.
Let us use, for example, the basis functions of
b
0
(x)=x(x 1)
and
b
1
(x)=x
2
(x 1).
It is trivial to verify that these also obey the boundary conditions. The ap-
proximated solution function is
y = α
0
x(x 1) + α
1
x
2
(x 1).
The functional of the constrained, approximated variational problem is
I(
y)=
1
0
(y
2
λy
2
)dx.
Evaluating the integral yields
I(
y)=
1
3
(α
2
0
+ α
0
α
1
+
2
5
α
2
1
) λ(
1
30
α
2
0
+
1
30
α
0
α
1
+
1
105
α
2
1
).
Numerical methods of calculus of variations 93
The extremum requires the satisfaction of
∂I
∂α
0
= α
0
(
2
3
λ
15
)+α
1
(
1
3
λ
30
)=0
and
∂I
∂α
1
= α
0
(
1
3
λ
30
)+α
1
(
4
15
2λ
105
)=0.
A nontrivial solution of this system of equations is obtained by setting its
determinant to zero, resulting in the following quadratic equation
λ
2
52λ + 420
6300
=0.
Its solutions are
λ
1
= 10; λ
2
=42.
Using the ﬁrst value and substituting into the second condition yields
α
1
=0
with arbitrary α
0
. Hence
y(x)=α
0
x(x 1).
The condition
1
0
y
2
dx =
1
0
α
2
0
x
2
(x 1)
2
dx =1
results in
α
0
= ±
30.
The approximate solution of the variational problem is
y(x)=±
30x(x 1).
It is very important to point out that the solution obtained as a function
of the chosen basis functions is not the analytic solution of the variational
problem. For this particular example the corresponding Euler-Lagrange dif-
ferential equation is
y

+ λy =0
whose analytic solution, based on Section 5.3, is
y = ±
2sin(πx).
Figure 7.1 compares the analytic and the approximate solutions and plots
the error of the latter.

Get Applied Calculus of Variations for Engineers, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.