On Variational Theory and Optimal Control Theory