Here is my short intro to Lagrangian Mechanics
Note: Small sign error for the motion of the ball. The acceleration should be -g.
Link to code to calculate least action
https://trinket.io/glowscript/180051366b
Calculus of variations to find the shortest distance between two points
https://youtu.be/A_PzcTMRxhk
Brachistochrone problem
https://youtu.be/geBj865enOg