variational calculations