Variational Principles in Dynamics and Quantum Theory