A compound Atwood machine replaces one hanging mass by another pulley carrying two masses. Let the upper mechanical string carry mass opposite the moving pulley, and let the lower mechanical string carry masses at upward heights . The length constraints on the mechanical strings give the height of as up to a constant. Thus its Lagrangian isThis follows by adding the three kinetic energies and subtracting their gravitational potential energies. Constant coordinate shifts annihilating the linear potential energy give conserved generalized momentum components by Noether's theorem.
Articles by others on the same topic
Lagrangian Mechanics Example: The Compound Atwood Machine by Michel van Biezen (2017)
Source. Part of lagrangian mechanics lectures by Michel van Biezen (2017).