# General Mechanics/Motion Under Constraint

So far we've tacitly assumed we can just calculate force as a function of position, set up the ODE
    $m{\ddot {\mathbf {r} }}=\mathbf {F} (\mathbf {r} )$
and start solving.
It is not always so simple.
Often, we have to deal with motion under constraint; a bead sliding on a wire, a ball rolling without slipping, a weight dangling from a string.
There has to be some force keeping the bead on the wire, but we don't know what it is in advance, only what it does. This isn't enough information for us to write down the ODE.
We need a way of solving the problem without knowing the forces in advance.
How easy this is depends on the type of constraint.

## Generalised coordinates

Suppose we have a system of n particles satisfying k constraints of the form
    $f_{k}(\mathbf {r} _{1},\cdots ,\mathbf {r} _{n},t)=0$
then we can use the constraints to eliminate k of the 3n coordinates of the particles, giving us a new set of 3n-k independent generalised coordinates; q$_1$, q$_2$, … q$_{3n-k}$.
Unlike the components of the position vectors, these new coordinates will not all be lengths, and will not typically form vectors. They may often be angles.
We now need to work out what Newton's laws will look like in the generalised coordinates.

### Derivation

The first step is to eliminate the forces of constraint.
We will need to consider a virtual displacement. This is an infinitesimal displacement made, while holding the forces and constraints constant. It is not the same as the infinitesimal displacement made during an infinitesimal time, since the forces and constraints may change during that time.
    We write the total force on particle i as
       $\mathbf {F} _{i}=\mathbf {F} _{i}^{a}+\mathbf {F} _{i}^{c}$
    the sum of the externally applied forces and the forces of constraint.
    Newton's second law states
       $\mathbf {F} _{i}^{a}+\mathbf {F} _{i}^{c}=\mathbf {F} _{i}={\dot {\mathbf {p} }}_{i}$
    We take the dot product of this with the virtual displacement of particle i and sum over all particles.
       $\sum _{i}\left(\mathbf {F} _{i}^{a}+\mathbf {F} _{i}^{c}-{\dot {\mathbf {p} }}_{i}\right)\cdot \delta \mathbf {r} _{i}=0$
    We now assume that the forces of constraint are perpendicular to the virtual displacement. This assumption is generally true in the absence of friction; e.g, the force of constraint that keeps a ball on a surface is normal to the surface.
    This assumption is called D'Alembert's principle. Using it we can eliminate the forces of constraint from the problem, giving
       $\sum _{i}\left(\mathbf {F} _{i}^{a}-{\dot {\mathbf {p} }}_{i}\right)\cdot \delta \mathbf {r} _{i}=0$
    or
       $\sum _{i}\mathbf {F} _{i}^{a}\cdot \delta \mathbf {r} _{i}=\sum _{i}{\dot {\mathbf {p} }}_{i}\cdot \delta \mathbf {r} _{i}\quad (1)$
    The left hand side of this equation is called the virtual work.
Now we must change to the generalised co-ordinate system.
    We write
       $\mathbf {r} _{i}=\mathbf {r} _{i}(q_{1},q_{2},\cdots ,q_{3n-k},t)$
    Using the chain rule gives
       $\mathbf {v} _{i}=\sum _{j}{\frac {\partial \mathbf {r} _{i}}{\partial q_{j}}}{\dot {q}}_{j}+{\frac {\partial \mathbf {r} _{i}}{\partial t}}$
    and
       $\delta \mathbf {r} _{i}=\sum _{j}{\frac {\partial \mathbf {r} _{i}}{\partial q_{j}}}\delta q_{j}$
    Note that this implies
       ${\frac {\partial \mathbf {r} _{i}}{\partial q_{j}}}={\frac {\partial \mathbf {v} _{i}}{\partial {\dot {q}}_{j}}}\quad (2)$
    The virtual work is, dropping the superscript,
       ${\begin{matrix}\sum _{i}\mathbf {F} _{i}\cdot \delta \mathbf {r} _{i}&=&\sum _{i,j}\mathbf {F} _{i}\cdot {\frac {\partial \mathbf {r} _{i}}{\partial q_{j}}}\delta q_{j}\\&=&\sum _{j}Q_{j}\delta q_{j}\end{matrix}}$
    where the Q$_j$ are the components of the generalised force.
We now manipulate the right hand side of (1) into a form comparable with this last equation
    The right hand side term is
       ${\begin{matrix}\sum _{i}{\dot {\mathbf {p} }}_{i}\cdot \delta \mathbf {r} _{i}&=&\sum _{i}m_{i}{\ddot {\mathbf {r} }}_{i}\cdot \delta \mathbf {r} _{i}\\&=&\sum _{i,j}m_{i}{\ddot {\mathbf {r} }}_{i}\cdot {\frac {\partial \mathbf {r} _{i}}{\partial q_{j}}}\delta q_{j}\end{matrix}}$
    The terms in the coefficient of q$_j$ can be rearranged
       ${\begin{matrix}\sum _{i}m_{i}{\ddot {\mathbf {r} }}_{i}\cdot {\frac {\partial \mathbf {r} _{i}}{\partial q_{j}}}&=&\sum _{i}\left[{\frac {d}{dt}}\left(m_{i}{\dot {\mathbf {r} }}_{i}\cdot {\frac {\partial \mathbf {r} _{i}}{\partial q_{j}}}\right)-m_{i}{\dot {\mathbf {r} }}_{i}\cdot {\frac {d}{dt}}\left({\frac {\partial \mathbf {r} _{i}}{\partial q_{j}}}\right)\right]\\&=&\sum _{i}\left[{\frac {d}{dt}}\left(m_{i}\mathbf {v} _{i}\cdot {\frac {\partial \mathbf {v} _{i}}{\partial {\dot {q}}_{j}}}\right)-m_{i}\mathbf {v} _{i}\cdot {\frac {\partial \mathbf {v} _{i}}{\partial q_{j}}}\right]\end{matrix}}$
    on substituting in equation (2) from above
On taking a close look at this last equation, we see a resemblance to the total kinetic energy,
    $T={\frac {1}{2}}\sum _{i}m_{i}v_{i}^{2}$
    We now further rearrange to get an expression explicitly involving T.
       ${\begin{matrix}\sum _{i}m_{i}{\ddot {\mathbf {r} }}_{i}\cdot {\frac {\partial \mathbf {r} _{i}}{\partial q_{j}}}&=&\sum _{i}\left[{\frac {d}{dt}}\left(m_{i}\mathbf {v} _{i}\cdot {\frac {\partial \mathbf {v} _{i}}{\partial {\dot {q}}_{j}}}\right)-m_{i}\mathbf {v} _{i}\cdot {\frac {\partial \mathbf {v} _{i}}{\partial q_{j}}}\right]\\&=&{\frac {d}{dt}}\left({\frac {\partial }{\partial {\dot {q}}_{j}}}{\frac {1}{2}}\sum _{i}m_{i}v_{i}^{2}\right)-{\frac {\partial }{\partial q_{j}}}{\frac {1}{2}}\sum _{i}m_{i}v_{i}^{2}\\&=&{\frac {d}{dt}}\left({\frac {\partial }{\partial {\dot {q}}_{j}}}T\right)-{\frac {\partial }{\partial q_{j}}}T\end{matrix}}$
Putting this last expression into (1) along with the generalised force give
    $\sum _{j}\left[{\frac {d}{dt}}\left({\frac {\partial T}{\partial {\dot {q}}_{j}}}\right)-{\frac {\partial T}{\partial q_{j}}}-Q_{j}\right]\delta q_{j}=0$
Since the δq$_j$, unlike the δr$_i$, are independent, this last equation can only be true if all the coefficients vanish.
That is we must have
    ${\frac {d}{dt}}{\frac {\partial T}{\partial {\dot {q}}_{j}}}-{\frac {\partial T}{\partial q_{j}}}=Q_{j}\quad (3)$
These are the equations of motion for the system, in a general set of coordinates for which all constraints are automatically satisfied.
For example, suppose we have a cylinder, mass m, radius a, rolling without slipping on a flat plane.
The kinetic energy of the cylinder is
    $T={\frac {1}{2}}m{\dot {x}}^{2}+{\frac {1}{8}}ma^{2}{\dot {\theta }}^{2}$
using the results from Rigid Bodies, where x is the axis in the plane perpendicular to the axis of the cylinder, and θ is the angle of rotation.
Rolling without slipping implies
    ${\dot {x}}=a{\dot {\theta }}$
so we get
    $T={\frac {5}{8}}m{\dot {x}}^{2}\quad {\frac {5}{4}}m{\ddot {x}}=Q_{x}$
The cylinder has the same kinetic energy as if its mass were 20% greater. If there is no torque on the cylinder then Q$_x$=F$_x$, and the cylinder behaves in every respect as though it were a 20% larger point mass.
To use (3) more generally, we need an expression for the Q$_j$
Suppose, as is often the case, that
    $\mathbf {F} _{i}=-{\frac {\partial }{\partial \mathbf {r} _{i}}}V$
then, by definition
    ${\begin{matrix}\sum _{j}Q_{j}\delta q_{j}&=&\sum _{i}\mathbf {F} _{i}\cdot \delta \mathbf {r} _{i}\\&=&\sum _{i,j}\mathbf {F} _{i}\cdot {\frac {\partial \mathbf {r} _{i}}{\partial q_{j}}}\delta q_{j}\\&=&-\sum _{i,j}{\frac {\partial V}{\partial \mathbf {r} _{i}}}{\frac {\partial \mathbf {r} _{i}}{\partial q_{j}}}\delta q_{j}\\&=&-\sum _{j}{\frac {\partial V}{\partial q_{j}}}\delta q_{j}\end{matrix}}$
so, equating coefficients, the generalised force is
    $Q_{j}=-{\frac {\partial V}{\partial q_{j}}}$
Putting this generalised force into (3) gives
    ${\frac {d}{dt}}{\frac {\partial (T-V)}{\partial {\dot {q}}_{j}}}-{\frac {\partial (T-V)}{\partial q_{j}}}=0$
since V has been assumed independent of the velocities.
In fact, this last equation will still be true for some velocity dependent forces, most notably magnetism, for a suitable definition of V, but we won't prove this here.
We call the T-V the Lagrangian, L, and write
    ${\frac {d}{dt}}{\frac {\partial L}{\partial {\dot {q}}_{j}}}-{\frac {\partial L}{\partial q_{j}}}=0$
We call these equations Lagrange's equations. They are useful whenever Cartesian co-ordinates are inconvenient, including motion under constraint.

### Example

Suppose we have two identical point masses, m, connected by a string, length a. The string is threaded through an hole in a flat table so that the upper mass is moving in a horizontal plane without friction, and the lower mass is always vertically below the hole. The distance of the upper mass from the hole is r.
The position of the mass on the table is best described using polar coordinates, (r,θ). Its kinetic energy is then
    ${\frac {1}{2}}m\left({\dot {r}}^{2}+r^{2}{\dot {\theta }}^{2}\right)$
The velocity of the lower mass is d(a-r)/dt=-dr/dt, so the total kinetic energy is
    $T={\frac {1}{2}}m\left(2{\dot {r}}^{2}+r^{2}{\dot {\theta }}^{2}\right)$
The potential energy is
    $V=mg(a-r)$
where g is the gravitational acceleration.
This means
    $L={\frac {1}{2}}m\left(2{\dot {r}}^{2}+r^{2}{\dot {\theta }}^{2}\right)+mg(r-a)$
and the equations of motion are
    ${\begin{matrix}{\frac {d}{dt}}{\frac {\partial L}{\partial {\dot {\theta }}}}-{\frac {\partial L}{\partial \theta }}&=&m{\frac {d}{dt}}\left(r^{2}{\dot {\theta }}\right)&=&0\\{\frac {d}{dt}}{\frac {\partial L}{\partial {\dot {r}}}}-{\frac {\partial L}{\partial r}}&=&2m{\ddot {r}}-mr{\dot {\theta }}^{2}+mg&=&0\end{matrix}}$
The first of these equations says that the angular momentum is constant, as expected since there is no torque on the particles. If we call this constant angular momentum l then we can write
    ${\dot {\theta }}={\frac {l}{mr^{2}}}$
and the second equation of motion becomes
    ${\ddot {r}}={\frac {l^{2}}{2m^{2}r^{3}}}-{\frac {g}{2}}$
Clearly, if initially
    $l^{2}>gm^{2}r^{3},\,$
then the lower ball will be pulled out of the hole, at which point these equations of motions cease to apply. They only hold when 0≤r≤a, a constraint which is not easily tamable.
Notice, we have not needed to calculate the tension in the string, which is the force of constraint in this problem.