# How does $\mathcal E(\rho)=\mathrm{Tr}_{env}[U(\rho\otimes\rho_{env})U^\dagger]$ turn into $P_0\rho P_0+P_1\rho P_1$?

In the Quantum Operations section in Nielsen and Chuang, (page 358 in the 2002 edition), they have the following equation: $$\mathcal E(\rho) = \mathrm{Tr}_{env} [U(\rho \otimes \rho_{env})U^\dagger]$$

They show an example with $$\rho_{env} = |0\rangle \langle0|$$ and $$U = \mathrm{CNOT}$$, and claim that the final solution is: $$P_0\rho P_0 + P_1\rho P_1,$$ where $$P_0=|0\rangle \langle0|$$ and $$P_1=|1\rangle \langle 1|$$.

These are my steps so far to get this, but I don't know how to trace out the environment after this:

Let $$\rho$$ be $$|\psi \rangle \langle \psi |$$, so that $$\rho \otimes \rho_{env} = |\psi, 0\rangle \langle \psi, 0|$$.

Applying the unitary $$U$$, we have

$$|00 \rangle \langle 00| \psi, 0 \rangle \langle \psi, 0 | 00 \rangle \langle 00 | + |00 \rangle \langle 00| \psi 0 \rangle \langle \psi 0 | 10 \rangle \langle 11 | \\ + |11 \rangle \langle 10| \psi 0 \rangle \langle \psi 0 | 00 \rangle \langle 00 | + |11 \rangle \langle 10| \psi 0 \rangle \langle \psi 0 | 10 \rangle \langle 11 |.$$

I don't know how to trace out the environment in the above state.

Also, I realize that I have considered only a pure state, if anyone can show it for a general state that would be great.

Let's start with a general state $$\rho\otimes\rho_0=\sum_{x,y\in\{0,1\}}\langle x|\rho|y\rangle|x\rangle\langle y|\otimes |0\rangle\langle 0|.$$ If we apply the controlled-not, we have $$\rightarrow\rho_{\text{final}}=\sum_{x,y\in\{0,1\}}\langle x|\rho|y\rangle|x\rangle\langle y|\otimes |x\rangle\langle y|.$$

Now we want to take the partial trace over the second subsystem. This means calculating $$\sum_k(\mathbb{I}\otimes\langle k|)\rho_{\text{final}}(\mathbb{I}\otimes|k\rangle)=\sum_k\sum_{x,y\in\{0,1\}}\langle x|\rho|y\rangle|x\rangle\langle y|\times \langle k|x\rangle\langle y|k\rangle.$$ If we perform the sums over $$x$$ and $$y$$, we find that $$x=y=k$$, so $$=\sum_k\langle k|\rho|k\rangle|k\rangle\langle k|,$$ which is entirely equivalent to removing all the off-diagonal elements of $$\rho$$.


We have

$$[U(\rho\otimes\sigma)U^\dagger]_{ij,k\ell} = \sum_{mnpq} U_{ij,mn} U^*_{k\ell,pq} \rho_{mp} \sigma_{nq}.\tag1$$

Suppose $$\sigma=|0\rangle\!\langle0|$$. Then $$[U(\rho\otimes|0\rangle\!\langle0|)U^\dagger]_{ij,k\ell} = \sum_{mp} U_{ij,m0} U^*_{k\ell,p0} \rho_{mp}.\tag2$$

Remember now the definition of partial trace. Let $$X:\CC^n\otimes\CC^m\to\CC^{n'}\otimes\CC^{m}$$ be some linear operator. Its matrix elements can be written as $$X_{ij,k\ell}$$, where $$i\in [n'], j\in[m], k\in[n], \ell\in[m]$$, with $$n,n',m\in\mathbb N$$ positive integers, and $$[n]\equiv\{1,...,n\}$$ etc. Its partial trace with respect to the second space is the linear operator $$\mathrm{Tr}_2(X):\CC^n\to\CC^{n'}$$ with matrix elements $$[\mathrm{Tr}_2(X)]_{ik} = \sum_j X_{ij,kj}.$$

Therefore, the partial trace of (2) wrt the second space reads $$\Big[\mathrm{Tr}_2[U(\rho\otimes|0\rangle\!\langle0|)U^\dagger]\Big]_{ik} = \sum_{jmp} U_{ij,m0} U^*_{kj,p0} \rho_{mp}.$$ Define the operators $$A_j:\CC^n\to\CC^{n'}$$ via their matrix elements $$(A_j)_{im} = U_{ij,m0}$$. With these, we can rewrite the above equation as $$\mathrm{Tr}_2[U(\rho\otimes|0\rangle\!\langle0|)U^\dagger] = \sum_j A_j \rho A_j^\dagger.$$

It's worth noting that $$A_j$$ can be understood as sub-blocks of the matrix $$\mathcal U$$ corresponding to the columns specified by $$j$$. See also my answer here about this.