Quantum Variational Calculus