49 Calculus of variations and optimal control