So, a taste:
https://groups.csail.mit.edu/mac/users/gjs/6946/sicm-html/bo...
"1.5.2 Computing Lagrange's Equations
The procedure for computing Lagrange's equations mirrors the functional expression (1.18), where the procedure Gamma implements :58
(define ((Lagrange-equations Lagrangian) q)
(- (D (compose ((partial 2) Lagrangian) (Gamma q)))
(compose ((partial 1) Lagrangian) (Gamma q))))"
Maybe more readable version: