Variational calculations with unbounded operators