What is Calculus of Variations?
In general, developments in mathematics are motivated by the need for them in applications. Calculus of variations is no exception. In fact, it was first developed in 1969 when Johann Bernoulli asked the greatest mathematical minds of his time to solve the famous ‘brachistochrone problem’. This problem involves a bead sliding down a frictional wire attached to two points, and asks what shape the wire should take so that the bead takes the least time to travel from one point to another ! This is a minimization problem, but it is important to note that the ‘basic problem’ of calculus of variations involves making a certain quantity stationary, rather than just minimizing it (recall that a function of one variable can have three types of stationary points, only one of which is a minimum). You will have certainly solved problems in which we wish to make quantities stationary before. For example, if one wishes to find the for which the function is stationary, you simply differentiate and then set its derivative to zero, i.e. solve . However, what if I asked you to find a which makes the integral stationary? This is not a problem which can be solved in the same manner as the one before. Do not despair though, this is where calculus of variations comes in!
In fact, making an integral stationary is a surprisingly prevalent problem within physics and mechanics. Many physical laws can be stated in terms of stationary integrals. Two examples include Fermat’s principle, which states that light will take a path between two points which makes the time it takes to travel the path stationary , and Hamilton’s Principle which is a reformulation of Newton’s Laws and says that any particle or system of particles always moves in such a way that is stationary, where , kinetic energy and potential energy .
Calculus of variations can also be used to find geodesics. A geodesic is the shortest path between two points on a surface. For example, the shortest distance between two points in a plane is given by a straight line. This extremely intuitive fact can actually be proven rigorously using calculus of variations (and we shall do so in this article)! Similarly, and less trivially, the geodesic of any surface can be found using calculus of variations.
Deriving the Euler Equation
Here we will derive the Euler Equation, namely, the condition that must satisfy to make stationary the integral .
First, let us consider the definition of a functional. The integral is known as a functional. The formal definition of a functional is a real-valued function on a vector space V. This may seem abstract at first glance, but it is easy to understand when you break it down. First of all, ‘real-valued’ simply means that the functional always returns a real number for any input. This is clearly the case for our integral . Secondly, a functional is defined on a vector-space rather than the real number line like functions you may be used to. If our vector space is a space of functions (recall that this is possible due to the abstract definition of a vector space – it can be a space of combinations of any mathematical object, not just vectors) then the functional takes inputs that are functions! This is the usual case, and certainly the case that we will be dealing with here. As a summary, the functionals that we will deal with take functions as an input, and output real numbers.
In our derivation we will be assuming that our functional is defined on a space of functions with fixed endpoints i.e. a space for which and . This is not such a restrictive assumption as it is often the case in problems. For example, finding the shortest distance between two points in a surface has predefined endpoints.
Now, recall that is any function defined on the interval (which satisfies the assumption above). Therefore, we can rewrite it as the sum of two functions, where is the extremal we seek (i.e. the function which makes the integral stationary), is any function for which (a necessary condition due to our predefined endpoints) and is a scalar variable.
When is defined in this manner our integral becomes a function of the variable . We wish to find a function for which when (because we wish the integral to be stationary when the extremal, i.e. .
I.e. we want when .
Furthermore, and , and when , and
If we integrate the second term by parts we obtain,
Now, because , and we can therefore eliminate the second term leaving only .
We are almost done now. Recall that g(x) is an entirely arbitrary function. Because of this, for the integral to always be zero (for any ) our function must equal zero! This is obvious intuitively (for any other function it would be possible to choose a for which the integral is not zero e.g. choose a which is positive when is positive and negative when is negative). Furthermore, this is a statement verified by the fundamental lemma of calculus of variations, which states that if is continuous and for all infinitely differentiable then on the open interval . 
Therefore, and we have obtained the Euler Equation!
A Quick Application
To briefly give an example of the Euler equation in use we will derive the geodesic of the Cartesian plane.
Here we wish to minimize the integral . Therefore, , and . Plugging theses results into the Euler equation we get or constant.
Clearly, this is only true when constant, and therefore the path is a straight line!
 https://undergroundmathematics.org/calculus-of-powers/calculus-of-variations, accessed January 13, 2018
 Fermat’s Principle, Encyclopædia Britannica, URL https://www.britannica.com/science/Fermats-principle, accessed January 13, 2018
 Mathematical Methods in the Physical Sciences Third Edition, Mary L. Boas, Chapter 9
 An adapted and extended version of the proof given in 
 Rowland, Todd. “Functional.” From MathWorld— A Wolfram Web Resource, created by Eric W. Weisstein. http://mathworld.wolfram.com/Functional.html
 http://courses.physics.ucsd.edu/2010/Fall/physics110a/LECTURES/CH05.pdf, accessed on January 13, 2018
 Weisstein, Eric W. “Fundamental Lemma of Calculus of Variations.” From MathWorld— A Wolfram Web Resources. http://mathworld.wolfram.com/FundamentalLemmaofCalculusofVariations.html