I am quite confused about how to measure observables (like Pauli spins).
For example, in the exercise 2.66 of Nielsen and Chuang's textbook:
Show that the average value of the observable $X_1Z_2$ for a two qubit system measured in the state $(\vert00\rangle+\vert11\rangle)/\sqrt2$ is zero.
My first take is to decompose the system into eigenvalues of the operators:
$$(\vert00\rangle+\vert11\rangle)/\sqrt2 = \left(\frac{\vert+\rangle+\vert-\rangle}{\sqrt2}\vert0\rangle + \frac{\vert+\rangle-\vert-\rangle}{\sqrt2}\vert1\rangle\right)/\sqrt2$$
So, each one of the four possibilities appears with the same probability 1/4, and the average is $$\frac{1*1\ +\ (-1)*1\ +\ 1*(-1)\ +\ (-1)*(-1)}{4}=\frac{1-1-1+1}{4}=0$$
Now, I observe that just computing $\langle\phi\vert X_1Z_2\vert\phi\rangle$ also works although $X_1Z_2$ is not projective:
$$\begin{align} 2 * \langle\phi\vert X_1Z_2\vert\phi\rangle &= \langle00\vert X_1Z_2 \vert00\rangle + \langle00\vert X_1Z_2 \vert11\rangle + \langle11\vert X_1Z_2 \vert00\rangle + \langle11\vert X_1Z_2 \vert11\rangle \\ &= \langle00|10\rangle - \langle00|01\rangle + \langle11|10\rangle - \langle11|01\rangle\\ &= 0+0+0+0=0 \end{align}$$
I'm not really sure about this method.
I also found this solution:
and I cannot understand what they compute.