Text this: Classical mechanics with calculus of variations and optimal control