Introduction to the calculus of variations