# Appling a Hadamard gate to a qubit in density matrix form

If a Hadamard gate is applied to a qubit that is in the state $$|0\rangle$$, then it becomes the state $$|+\rangle = \frac{1}{\sqrt{2}}\left(|0\rangle+|1\rangle\right)$$ In density matrix form, this state is:

$$\rho=|+\rangle\langle+|=\frac{1}{2}\left(|0\rangle+|1\rangle\right)\left(\langle0|+\langle1|\right)$$

But, if we start with the state $$|0\rangle$$ in density matrix form, $$|0\rangle\langle0|$$, and then apply a Hadamard gate, we get:

$$\rho=|+\rangle\langle0|=\frac{1}{\sqrt{2}}\left(|0\rangle+|1\rangle\right)\langle0|$$

Why is there a discrepancy between these two results? Which is correct?

Applying a unitary $$U$$ to a state $$\psi$$ is expressed by $$U\psi.$$
Applying a unitary to a density matrix $$\rho$$ is expressed by
$$U\rho U^\dagger.$$
• to clarify why this is the case: If $\vert\psi\;^\prime\rangle = U\vert\psi\rangle$, then $\rho^\prime = \vert\psi\;^\prime\rangle\langle\psi\;^\prime\vert = U\vert\psi\rangle\langle\psi\vert U^\dagger$ Commented Apr 26 at 15:01