Calculus of Variations Demystified - by Naoki - Medium
Calculus of Variations Demystified - by Naoki - Medium
Calculus of Variations Demystified - by Naoki - Medium
You have 2 free member-only stories left this month. Sign up for Medium and get an extra one
Naoki Follow
Save
Image by author
But what are functionals? What does a functional really look like?
Image by author
Image by author
But for now, let’s forget the fact that we know the answer.
Instead, let’s frame the problem into an optimization problem and mathematically
show that the straight line is the answer.
Doing so let us understand what functionals and variations are as well as how to derive
the Euler-Lagrange equation to solve the optimization problem.
Before finding the shortest path, we need to be able to calculate the length of a path
from A to B.
Open in app Get started
As the famous Chinese proverb say, “a journey of a thousand miles begins with a single
step”.
So, let’s calculate the length of a small passage and integrate it from A to B.
As shown in the above diagram, a small passage can be approximated by a straight line.
So, the total length of a path can be calculated by the following integration:
Since A and B are fixed points, let’s define them as A = (x1, y1) and B = (x2, y2) .
p , ( , y ) ( , y )
In the last step, y1 and y2 are dropped as they are determined by x1 and x2 .
We are going to find the y = f(x) that minimizes the path length S.
What is a functional?
We actually know that the y = f(x) is the straight line between A and B but let’s still
forget that for the time being.
Image by author
And so on.
But having a function name for each line is too tedious, so we call them collectively y =
y(x) .
We think of y = y(x) as any line between A and B which could be the blue line, the red
line or else.
We can calculate the length of any line (given a particular y(x) ) using the formula S .
Open in app Get started
In other words, S takes an instance of y(x) and returns the length of the line.
A functional is written with square brackets like S[y] which means the functional S
If we talk about functions of functions like this general, there could be too many kinds
of functionals, many of which may not be that useful.
Since the functional optimization originates from the Physics which deals with
positions and velocities, the following general form is very common and has many
applications (not only in Physics but also in machine learning).
In the shortest path problem, L does not include x and y but only y' .
That is ok.
The point is that if we can solve the optimization problem for the general form of
functionals, we can solve many problems including the shortest path problem.
Functional variations
Before attempting solving the general form of functionals, let’s think about how to
solve the shortest path problem.
Do we generate many random functions and evaluate the path length to find out the
shortest path?
Open in app Get started
Image by author
We can map each path to a path length value using the functional S.
The question is how to know if we actually find the shortest path or not.
We can take an alternative approach since we already know that the shortest path
exists.
We start with the shortest path and slightly modify it to see what kind of condition is
required for the shortest path.
H it i t d f
Here, we write f(x) instead of y(x) .
Open in app Get started
y(x) is a candidate function that may or may not solve our problem like the blue line
and the red line.
When we give y(x) or f(x) to S , we write like S[y] and S[f] respectively.
S[f] gives the path length following f(x) from A to B which is the shortest path
length.
asserted:
In the below diagram, the blue straight line is the shortest path y = f(x) .
Image by author
S[f + ϵη] gives the length of the path given by the function f + ϵη .
Since S[f] is the shortest path length, the relationship S[f] <= S[f + ϵη] is true for
any variation.
When ϵ goes to zero, the purple line becomes the same as the blue line as the
variation vanishes.
Also, note that η(x) must be zero at the point A and B since any variation must include
the point A and B. (Remember we are looking for the shortest line from A to B).
The reason is that the variation makes the functional optimization into a function
optimization which we know how to solve.
If we look at S[f + ϵη] very closely, we can see that it depends only on ϵ.
f(x) is the function that gives the minimum path line which is fixed.
S(ϵ) is the function of ϵ that returns the path length for the function y that is the
solution function f plus a variation ϵη .
We just need to solve the minimization problem for the function S(ϵ) .
Conveniently, we also know that S becomes the minimum when ϵ goes to zero.
In case it’s not clear, an apostrophe is used when we calculate the derivative of a
function by the only independent variable. Since ϵ is the only independent variable of
S in this context, the apostrophe here means the derivative of S by ϵ.
Let’s go back to the general form to reiterate all the points we’ve discussed so far and
Open in app Get started
derive the Euler-Lagrange equation to solve the optimization problem.
The Euler-Lagrange equation
The general form of functionals we are dealing with is as follows:
So far, we reinforced the same idea from the shortest path problem for the general
form of functionals.
Now, we are going to solve it for the general form of functionals to derive the Euler-
Lagrange equation.
B b i i i h b i
By substituting J[y] into the above equation:
Open in app Get started
Therefore,
Open in app Get started
As η(x) is an arbitrary function, the term in the brackets must be zero to satisfy the
equation ∅'(0)=0 .
This is called the Euler-Lagrange equation which is the condition that must be
satisfied for the optimal function f of the general form of functionals.
Now, we say y = f(x) is the function that minimizes the path length from A to B.
Let’s solve the Euler-Lagrange equation for the shortest path problem.
Open in app Get started
C is a constant value.
It can be shown by taking the square of both sides and re-arrange the equation:
Voilà!
If we put the boundary conditions f(x1) = y1 and f(x2) = y2 , we get the values for a
and b.
Open in app Get started
The essential idea of the calculus of variations is to make a functional into a function of
ϵ by adding the variation ϵη to the optimal function f so that the problem of
functional optimization becomes a function optimization problem.
We derived the Euler-Lagrange equation for the general form of functionals which
must be satisfied for solution functions.
However, in many problems, we know the solution would give the functional minimum
or maximum.
In the shortest path problem, the maximum has no limit, so we know the solution to
the Euler-Lagrange equation gives the minimum function.
In case we want to check if the solution function is for the maximum or minimum, we
need to calculate the second derivative of ∅(ϵ) by ϵ for ϵ=0 where y = f + ϵη .
This is already a positive value, so we know the Euler-Lagrange equation for the
shortest path problem gives the minimum function.
In theory, we should check the value of the second derivative when ϵ=0 because we
are talking about the local minimum/maximum around the range expressed by ϵ.
When ϵ=0 , y = f :
All in all, the solution function (the straight line) given by the Euler-Lagrange equation
for the shortest path problem gives the minimum of the functional S.
Lastly, I assumed all the derivatives are possible in this article. For example, y(x) and
η(x) must be differentiable by x.
I hope you have a clearer idea about the calculus of variations now.
Related Articles
References
Calculus of variations (Wikipedia)
Calculus of variations
The calculus of variations is a field of mathematical analysis that uses variations, which are small
changes in…
en.wikipedia.org
https://youtu.be/6HeQc7CSkZs
260 2
Open in app Get started
Your email
Subscribe
By signing up, you will create a Medium account if you don’t already have one. Review our Privacy Policy for more information about
our privacy practices.