Introduction to the Variational Formulation in Mechanics