# How to find projection operators for spectral decomposition

I am a little bit confused about the spectral decomposition for the observable $$Z_{1}Z_{2}$$ in Section $$10.1$$ of Nielsen and Chunag's "Quantum Computation and Quantum Information".

The idea is that for the bit flip channel, there are four error syndromes corresponding to the four projection operators: $$P_{0} \equiv |000\rangle \langle 000| + |111\rangle \langle 111|$$ $$P_{1} \equiv |100\rangle \langle 100| + |011\rangle \langle 011|$$ $$P_{2} \equiv |010\rangle \langle 010| + |101\rangle \langle 101|$$ $$P_{3} \equiv |001\rangle \langle 001| + |110\rangle \langle 110|$$

However, instead of measuring the four projectors $$P_{0}, P_{1}, P_{2}, P_{3}$$, we measure the observables $$Z_{1}Z_{2}$$ and $$Z_{2}Z_{3}$$. Each of these observables has eigenvalues $$\pm 1$$.

"The first measurement $$Z_{1}Z_{2}$$ can be thought of as comparing the first and second qubits to see if they are the same. To see why this is so, note that $$Z_{1}Z_{2}$$ has spectral decomposition $$Z_{1}Z_{2} = (|00\rangle \langle 00| + |11\rangle \langle 11|) \otimes I - (|01 \rangle \langle 01| + |10 \rangle \langle 10|) \otimes I$$

I really don't understand how we obtain the above spectral decomposition for $$Z_{1}Z_{2}$$.

My understanding is that the spectral decomposition should be: $$E = \sum_{n} \lambda_{n}P_{n}$$ where $$E$$ is the Hermitian operator, $$\lambda_{n}$$ are the eigenvalues of $$E$$ and $$P_{n}$$ are the corresponding eigenspace of $$E$$.

So $$Z_{1}Z_{2}= \lambda_{+1}P_{+1} + \lambda_{-1}P_{-1}$$

I don't how to obtain the $$P_{\pm 1}$$ projectors and so I don't understand how the above spectral decomposition was obtained. Could someone explain how to get the projectors for the eigenspaces with eigenvalues $$\pm 1$$?

For a general finite-dimensional Hermitian operator $$E$$, once you find the eigenvalues $$\lambda_i$$ and eigenvectors $$|\lambda_i\rangle$$, you can write out the spectral decomposition $$E = \sum_i \lambda_i |\lambda_i\rangle \langle \lambda_i| := \sum_i \lambda_i P_i \tag{1}$$ where $$P_i:= |\lambda_i\rangle \langle \lambda_i|$$. You can verify that $$P_i$$ is a projector using the fact that the eigenvectors will form an orthonormal basis for the space that $$E$$ acts on (ignoring anything unimportant that happens with the eigenvectors whose eigenvalue is zero). If we suppose that all eigenvalues are $$\pm 1$$, you can break Eq (1) into two parts: $$E = \sum_{i: \lambda_i = +1} P_i - \sum_{i: \lambda_i = -1} P_i. \tag{2}$$
In your case, finding $$P_i$$ is straightforward because $$Z_1 Z_2 := Z\otimes Z \otimes I$$ is diagonal in the computational basis, i.e. \begin{align} Z\otimes Z \otimes I = \text{diag}(1, 1, -1, -1, -1 , -1, 1, 1), \tag{3} \end{align} with the first element acting on the basis state $$|000\rangle$$, the second element on $$|001\rangle$$, and so on. From this you see that the eigenvectors of this operator with $$+1$$ eigenvalue are $$\{|000\rangle, |001\rangle, |110\rangle, |111\rangle\}$$ (basis states where the first two bits agree) and the eigenvectors with $$-1$$ eigenvalue are $$\{|010\rangle, |011\rangle, |100\rangle, |101\rangle\}$$ (basis states where the first two bits disagree). Plugging the corresponding projectors into Eq. (2) (and writing $$P_{ijk} = |ijk\rangle \langle ijk|$$ for brevity) gives \begin{align} E &= \left( P_{000} + P_{001} + P_{110} + P_{111}\right) - \left( P_{010} + P_{011} + P_{100} + P_{101}\right) \tag{4a}\\ &= (|00\rangle \langle 00| \otimes I + |11\rangle \langle 11| \otimes I) - (|01\rangle \langle 01| \otimes I + |10\rangle \langle 10| \otimes I), \tag{4b} \end{align} which is the desired expression.