The computation and theory of optimal control