The mechanics of a trebuchet using Lagrangian mechanics