A simple pendulum of mass m and length l hangs from a trolley of mass M running on smooth horizontal rails. The pendulum swings in a plane parallel to the rails. Using the position x of the trolley and the angle \theta of the pendulum such that \theta =0 corresponds to the pendulum pointing vertically down as generalized co-ordinates, write down the Lagrangian function, and Lagrange's equations. Obtain an equation of motion for \theta alone.
[30]