By differentiating the scalar Lagrangian in the energy dimension with respect to the generalized coordinates and generalized velocities, excluding the constraints, the Euler-Lagrange equation is derived using the variational method.
Euler–Lagrange equation
In the calculus of variations and classical mechanics, the Euler–Lagrange equations[1] are a system of second-order ordinary differential equations whose solutions are stationary points of the given action functional. The equations were discovered in the 1750s by Swiss mathematician Leonhard Euler and Italian mathematician Joseph-Louis Lagrange.
https://en.wikipedia.org/wiki/Euler–Lagrange_equation
Seonglae Cho