Variational Methods in Economics