A commutativity theorem for unbounded operators in Hilbert space