Consider a system with coordinates qi. Say we want to constrain its
motion such that some scalar function f(qi)=0. For example, we
could constrain two coordinates to be equal by setting f(qi)=q1−q2.
For uncontrained motion, we have used the Euler-Lagrange equation to
find the path through space that minimizes the action, i.e. the
integral of the Lagrangian. We considered all possible paths with some
given start and end points.
Now we want to constrain our search to only paths that satisfy this
constraint equation. We will use Lagrange multipliers to do this. We set the gradient of the Lagrangian
parallel to the weighted sum of the gradients of the constraint
equations.
∇L(t)=−k∑λk(t)⋅∇f(k).
We then define a function Lλ(qi,q˙i,t,λk) such
that optimizing it is equivalent to the above.
Here we applied the Euler-Lagrange equation to the left term in the
integral as we would normally. We see that the right-hand side of the
resulting equation has extra terms that describe the constraint forces.