Calculus of Variations & Optimal Control