Optimality conditions for problems involving ordinary ODEs Optimality conditions mathematics