The principle of least action, also called Hamilton's principle, is the most general way of formulating the law of motion in mechanics.
According to this principle, every mechanical system is characterised by a function, the Lagrangian L, which has as variables the generalised coordinates q, the generalised velocities q̇ and time t. So L in general is L(q,q̇,t). Recall that q and q̇ are a shorthand for q₁,q₂,...,q̇₁,q̇₂,...
We consider the evolution of a mechanical system, from time t₁ to time t₂. We define the *action* S as the integral
S = ∫Ldt {t;t₁;t₂},
where {t;t₁;t₂} means that we integrate wrt time t from t₁ to t₂.
We want to find the trajectories q(t) that make the integral S an extremum (local maximum or minimum), although we will use a sloppy language and usually say "minimum".
If q(t) is the path for which S is minimum, then q(t)+δq(t), i.e. any variation on such path, will increase (go farther from the extremum) the value of S. Here, δq(t) is a *variation* of the function q(t), and it is always small along the interval we consider.
For the initial and end points there is no possible variation: we fix δq(t₁)=δq(t₂)=0 by definition of our protocol.
Then, the variation of S is
∫L(q+δq,q̇+δq̇,t)dt - ∫L(q,q̇,t)dt {t;t₁;t₂}.
The principle of least variation says that this quantity, also written as δS, must be δS=0.
Let's develop the function L(q,q̇,t) in power series up to first order, since the principle just says that these first-order terms must be 0. A variation δ of a function is developed the same way we develop a total derivative d. So it seems we should write this:
δL(q,q̇,t) = (∂L/∂q)·δq + (∂L/∂q̇)·δq̇ + (∂L/∂t)·δt .
However, there is a subtle thing here. A variation δ is a virtual displacement, meaning that it changes the position of the path without altering the time. So when you develop δ of a function, even if it is an explicit function of time, you must consider that the variation δ never brings a point at a given t to a point at a different t. Instead, it always moves the path from points at a given t from other neighbour points at the *same* t. In this way, it is not similar to the total derivative of a function explicitly dependent on time, since the total derivative will consider moving points to different instants. In summary, the correct development of δL is
δL(q,q̇,t) = (∂L/∂q)·δq + (∂L/∂q̇)·δq̇ .
Now, consider the following expression in order to develop the previous equation:
δq̇ = dδq/dt.
And we integrate the second term on the RHS (right hand side) by parts:
dU/dt = dδq/dt => U = δq V = (∂L/∂̇q) => dV/dt = (d/dt)(∂L/∂q̇).
Then, we apply V·dU/dt = d(V·U) - U·dV/dt, so
δL = (∂L/∂q)·δq + d/dt(δq∂L/∂q̇) - δq·(d/dt)(∂L/∂q̇).
But as S = ∫Ldt from 1 to b, the 2nd term on the rhs is just (δq∂L/∂q̇)| {1;2}, and since δq for 1 and 2 is 0, this term is just 0.
We have two remaining terms on the rhs that both have δq as a factor, so we write
δS = ∫[(∂L/∂q) - (d/dt)(∂L/∂q̇)]·δq·dt {t;t₁;t₂}.
But if this is =0, what is inside the integral must be 0, since the ∫ must be 0 for all values of δq. The only way to hold this is by considering
(d/dt)(∂L/∂q̇) - ∂L/∂q = 0 => (d/dt)(∂L/∂q̇) = ∂L/∂q .
This is the Lagrange or Euler-Lagrange (E-L) equation. But there is a subtle thing here now. We have used q and q̇ as a shorthand for many variables. Now you could ask: what happens if we have many variables? Do we need to do a sum over all variables and the sum will be equal to 0 or do we have one copy of this equation per variable? The answer is the latter. Why? Because each variable qᵢ will have a path qᵢ(t) and each path must be varied *independently*. This independence of the variation is what allows us to write the E-L equations, in plural:
(d/dt)(∂L/∂q̇ᵢ) = ∂L/∂qᵢ (i = 1,2,...,s).
These equations are the equations of motion of a mechanical system composed of s generalised coordinates.
These E-L equations consist in a set of s second-order differential equations (DE) for s unknowns qᵢ(t). Since each second-order DE needs two arbitrary constants, we will need 2s arbitrary constants to fully determine the motion. The typical set of conditions that define these constant is the set of "initial" conditions (could be the conditions at any time, in fact). For example, we can give all the initial coordinates and velocities.
What happens if we have two mechanical systems A and B? Each system has its Lagrangian L_A and L_B. What is the Lagrangian of the two systems combined? If there is no interaction (or it is ver small) between them, we have L = L_A + L_B. But it is not true in general.
So, if the two systems are so fart apart that the interactions can be neglected, then we can write this equality, and then no properties of A can be placed in L_B and no properties of B can appear in L_A.
What happens if we characterise a system by its Lagrangian and then we multiply this Lagrangian by a constant factor? The answer is that E-L equations don't care about constant multipliers, so the equations of motion will be the same. This means that the Lagrangian is arbitrary up to a constant multiplier.
However, if there are different (isolated, non-interacting) systems, we have L_A, L_B, and so on. Can we multiply each subsystem Lagrangian by a different constant? The answer is no! The additive property of Lagrangians for isolated systems tell us that we only have arbitrariness in the multiplication of *all* the Lagrangians by the *same* constant.
This is not the only arbitrariness for a Lagrangian, though. Let's change our Lagrangian L to L', as follows:
L'(q,q̇,t) = L(q,q̇,t) + (d/dt)f(q,q̇,t).
Will the equations of motion be affected if we use L' instead of L? The answer is yes, but we will learn something very important in the process. Since what we need is S'=∫L'dt, we get ∫Ldt + ∫(df/dt)dt {1;2}. The first term on the rhs is what we had, so let's worry about the second, and since it is the integral of a total derivative, we just get f(1) - f(2). Now, perform the variation δ on them, for example, over f(1):
δf(q,q̇,t){1} = (∂f/∂q)|₁·δq₁ + (∂f/∂q̇)|₁·δq̇₁ = (∂f/∂q̇)|₁·δq̇₁.
Here we learn an important lesson: if f(q,t) instead of f(q,q̇,t), then the equation above gives 0, since by protocol we fix δq₁=0.
So we have found another arbitrariness in L: we can add to L any total time derivative of any function that is only explicitly dependent on t and q. Then, although L' ≠ L, δS' = δS = 0, which is what matters for the equations of motion.