oftentimes it is beneficial to use newton's second law instead of lagrange's equations because newton's equations give the reaction forces at the joint between the pendulum and the cart. these equations give rise to two equations for each body; one in the x-direction and the other in the y-direction. the equations of motion of the cart are shown below where the lhs is the sum of the forces on the body and the rhs is the acceleration.