The calculus of variations