An Introduction to the Calculus of Variations