I am a little stuck on understanding the measurement probabilities of a 3 qubit system (QCQI q 4.41).
1)H gates are applied to both $q_1$ and $q_2$
2) $C^{(1,2)}_3(X)$, a Toffoli, controlled by $q_1$ and $q_2$ is then applied to $q_3$
3) A Unitary (S gate) is then applied to $q_3$
4) $C^{(1,2)}_3(X)$, a Toffoli, controlled by $q_1$ and $q_2$ is then applied to $q_3$
5) H gates are applied to both $q_1$ and $q_2$
The probability of measuring $|q_1\rangle = |q_2\rangle = 0$ should be $\frac{5}{8}$, however I can only seem to derive $\frac{4}{8}$, by expanding out the tensors and then cancelling.
After step 4 the state I think is:
$(|00\rangle + |01\rangle + |10\rangle)\otimes S|q_3\rangle + |11\rangle \otimes XSX|q_3\rangle$
Then after applying step 5, expanding out and cancelling I am left with:
$(|00\rangle + |00\rangle + |00\rangle - |11\rangle)\otimes S|q_3\rangle + (|00\rangle - |01\rangle - |10\rangle + |11\rangle)\otimes XSX|q_3\rangle $
however I can't seem to find the missing $|00\rangle$, and also in this result the measurement of $|00\rangle$ corresponds to two different states of $q_3$. I think the error in my understanding is somewhere here:
Applying Hs (step 5) and expanding $|11\rangle \otimes XSX|q_3\rangle$
$(H|1\rangle \otimes H|1\rangle) \otimes IXSX|q_3\rangle$ = $(|00\rangle - |01\rangle - |10\rangle + |11\rangle)\otimes XSX|q_3\rangle $
Could it also be my misunderstanding that the state of $|q_1q_2\rangle$ going into both Toffoli gates can be different for step 2 & 4? I was assuming that if that state was $|11\rangle$ in the first Toffoli then it must be $|11\rangle$ into the second as well.