Exercise 4.41#

From the definition of Hadamard gate, we have

(1)#\[ H|0\rangle = |+\rangle = \frac{|0\rangle + |1\rangle}{\sqrt{2}}, H|1\rangle = |-\rangle =\frac{|0\rangle - |1\rangle}{\sqrt{2}} \]

Given the input state \(|00\psi\rangle\)​, after two Hadamard gates in qubit \(1\)​ and qubit \(2\)​, we obtain

(2)#\[ H_1H_2I_3 |00\psi\rangle = |++\psi\rangle = \frac{1}{2}(|00\psi\rangle + |01\psi\rangle +|10\psi\rangle +|11\psi\rangle ) \]

where we use eq. (1) for calculation and the number \(1,2,3\) denotes the number of qubit. For the first Toffoli gate, notice that it would only apply \(X\) operation to the state with both first and second qubit as \(|1\rangle\), then after the first Toffoli gate, we obtain

(3)#\[ {\rm Toffoli} |++\psi\rangle = \frac{1}{2}(|00\psi\rangle + |01\psi\rangle +|10\psi\rangle +I_1I_2X_3|11\psi\rangle ) \]

The phase gate between two Toffoli gates only performs on the third qubit, then we have

(4)#\[ I_1I_2S_3({\rm Toffoli} |++\psi\rangle ) =\frac{1}{2}(S_3|00\psi\rangle + S_3|01\psi\rangle +S_3|10\psi\rangle +S_3X_3|11\psi\rangle ) \]

The second Toffoli gate would also apply \(X\) operation to the state with both first and second qubit as \(|1\rangle\). Note that operations at the third qubit does not change the first and second qubit, so eq. (4) becomes

(5)#\[ {\rm Toffoli}(I_1I_2S_3){\rm Toffoli} |++\psi\rangle =\frac{1}{2}(S_3|00\psi\rangle + S_3|01\psi\rangle +S_3|10\psi\rangle +X_3S_3X_3|11\psi\rangle ) \]

The final two Hadamard gates change \(|0\rangle\) to \(|+\rangle\) and \(|1\rangle\) to \(|-\rangle\), so the final state is given by

(6)#\[ \begin{align} \text{final state:}\;\frac{1}{2}(S_3|++\psi\rangle + S_3|+-\psi\rangle +S_3|-+\psi\rangle +X_3S_3X_3|--\psi\rangle ) \end{align} \]

Since we perform a \(Z-\)basis measurement on first and second qubit, we need to use eq. (1) to re-write eq. (6). From eq. (1) we have

(7)#\[\begin{split} \begin{align} |++\rangle &=\frac{1}{2}(|0\rangle+|1\rangle)\otimes (|0\rangle+|1\rangle) \\ &=\frac{1}{2}(|00\rangle+|01\rangle+|10\rangle+|11\rangle)\\ |+-\rangle &=\frac{1}{2}(|0\rangle+|1\rangle)\otimes (|0\rangle-|1\rangle) \\ &= \frac{1}{2}(|00\rangle-|01\rangle+|10\rangle-|11\rangle)\\ |-+\rangle &=\frac{1}{2}(|0\rangle-|1\rangle)\otimes (|0\rangle+|1\rangle) \\ &= \frac{1}{2}(|00\rangle+|01\rangle-|10\rangle-|11\rangle)\\ |--\rangle &=\frac{1}{2}(|0\rangle-|1\rangle)\otimes (|0\rangle-|1\rangle) \\ &= \frac{1}{2}(|00\rangle-|01\rangle-|10\rangle+|11\rangle)\\ \end{align} \end{split}\]

Thus, we could re-write the final state as

(8)#\[\begin{split} \begin{align} \text{final state:}\;&\frac{1}{2}(S_3|++\psi\rangle + S_3|+-\psi\rangle +S_3|-+\psi\rangle +X_3S_3X_3|--\psi\rangle ) \\ =&\frac{1}{4}[(|00\rangle+|01\rangle+|10\rangle+|11\rangle)\otimes S_3|\psi\rangle \\ &+ (|00\rangle-|01\rangle+|10\rangle-|11\rangle)\otimes S_3|\psi\rangle\\ &+(|00\rangle+|01\rangle-|10\rangle-|11\rangle)\otimes S_3|\psi\rangle \\ &+(|00\rangl-|01\rangle-|10\rangle+|11\rangle)\otimes X_3S_3X_3|\psi\rangle ] \\ =& \frac{1}{4}[(3|00\rangle+|01\rangle+|10\rangle-|11\rangle)\otimes S_3|\psi\rangle +(|00\rangle-|01\rangle-|10\rangle+|11\rangle)\otimes X_3S_3X_3|\psi\rangle ] \\ =& |00\rangle\otimes \left(\frac{3}{4}S_3|\psi\rangle + \frac{1}{4}X_3S_3X_3|\psi\rangle\right) + \frac{1}{4}(|01\rangle+|10\rangle - |11\rangle) \otimes\left(S_3|\psi\rangle - X_3S_3X_3|\psi\rangle\right) \end{align} \end{split}\]

Measuring \(00\)#

From the final state we know that, if the measurement of first two qubits are both \(0\), the corresponding projector is \(P = |00\rangle\langle 00|\otimes I\), and probability of getting both \(0\) is

(9)#\[\begin{split} \begin{align} p_{00} =& \langle \text{final state}|P |\text{final state}\rangle \\ =& \frac{1}{16}\langle \psi|(3S_3 + X_3S_3X_3)^{\dagger}(3S_3 + X_3S_3X_3)|\psi\rangle \\ =& \frac{1}{16}\langle \psi|(3S^{\dagger}_3 + X^{\dagger}_3S^{\dagger}_3X^{\dagger}_3)(3S_3 + X_3S_3X_3)|\psi\rangle \\ =& \frac{1}{16}\langle \psi|(9S^{\dagger}_3S_3 + 3S^{\dagger}_3 X_3S_3X_3+ 3X^{\dagger}_3S^{\dagger}_3X^{\dagger}_3S_3 + X^{\dagger}_3S^{\dagger}_3X^{\dagger}_3 X_3S_3X_3)|\psi\rangle \\ =& \frac{1}{16}\langle \psi|(9I + 3S^{\dagger}_3 X_3S_3X_3+ 3X^{\dagger}_3S^{\dagger}_3X^{\dagger}_3S_3 + I)|\psi\rangle \end{align} \end{split}\]

where we use the fact that \(S\) and \(X\) are unitary matrices and \(X\) is Hermitian matrix. Note that

(10)#\[\begin{split} S^{\dagger}_3X_3S_3X_3 = \begin{pmatrix} 1 & 0 \\ 0 & -i \end{pmatrix}\begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix}\begin{pmatrix} 1 & 0 \\ 0 & i \end{pmatrix}\begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix} = \begin{pmatrix} i & 0 \\ 0 & -i \end{pmatrix}\\ X^{\dagger}_3S^{\dagger}_3X^{\dagger}_3S_3 = (S^{\dagger}_3X_3S_3X_3)^{\dagger} = \begin{pmatrix} -i & 0 \\ 0 & i \end{pmatrix} \end{split}\]

Then we could obtain the probability of getting \(00\) as

(11)#\[\begin{split} \begin{align} p_{00} =& \frac{1}{16}\langle \psi|(9I + 3S^{\dagger}_3 X_3S_3X_3+ 3X^{\dagger}_3S^{\dagger}_3X^{\dagger}_3S_3 + I)|\psi\rangle = \frac{10}{16}= \frac{5}{8} \\ \end{align} \end{split}\]

After measuring \(00\), we will obtain the state at the third qubit as

(12)#\[ \frac{1}{\sqrt{p_{00}}}\left(\frac{3}{4}S_3|\psi\rangle + \frac{1}{4}X_3S_3X_3|\psi\rangle\right) \]

To see whether it is equivalent with adding a \(R_z(\theta)\) on \(|\psi\rangle\), we need to compute

(13)#\[\begin{split} \begin{align} 3S_3 + X_3S_3X_3 &= 3\begin{pmatrix} 1 & 0 \\ 0 & i \end{pmatrix} + \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix}\begin{pmatrix} 1 & 0 \\ 0 & i \end{pmatrix}\begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix} \\ &=\begin{pmatrix} 3+i & 0 \\ 0 & 3i+1 \end{pmatrix} = \begin{pmatrix} (1+i)(2-i) & 0 \\ 0 & (1+i)(2+i) \end{pmatrix} \\ &= (1+i) (2I - iZ) \end{align} \end{split}\]

Therefore, the post-measurement state becomes

(14)#\[\begin{split} \begin{align} \frac{1}{\sqrt{p_{00}}}\left(\frac{3}{4}S_3|\psi\rangle + \frac{1}{4}X_3S_3X_3|\psi\rangle\right) &= \frac{1}{\sqrt{10}}(1+i) (2I - iZ) \\ &= e^{i\pi/4}\left(\frac{2}{\sqrt{5}}I - i\frac{1}{\sqrt{5}}Z\right) \end{align} \end{split}\]

From the definition of \(R_{z}(\theta)\) gate, we know that

(15)#\[ \cos\frac{\theta}{2} = \frac{2}{\sqrt{5}} \iff \cos\theta = 2\cos^2\frac{\theta}{2}-1 = \frac{3}{5} \]

Not measuring \(00\)#

From the final state we know that, if the measurement of first two qubits are not both \(0\), the post-measurement state becomes

(16)#\[ \begin{align} \frac{1}{\sqrt{1-p_{00}}}\frac{1}{4}(S_3|\psi\rangle - X_3S_3X_3|\psi) &= \frac{1}{\sqrt{6}}(S_3|\psi\rangle - X_3S_3X_3|\psi) \end{align} \]

Since

(17)#\[\begin{split} \begin{align} S_3 - X_3S_3X_3 &= \begin{pmatrix} 1 & 0 \\ 0 & i \end{pmatrix} - \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix}\begin{pmatrix} 1 & 0 \\ 0 & i \end{pmatrix}\begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix} \\ &=\begin{pmatrix} 1-i & 0 \\ 0 & i-1 \end{pmatrix} = (1-i) Z \end{align} \end{split}\]

the post measurement state is given by \((1-i)Z|\psi\rangle /\sqrt{6}\).

If we want to repeat the whole process to obtain a precise \(R_{z}(\theta)\) operation, we need to execute the circuit for many times, and add \(Z\) gate to the third qubit if the measurement outcome is not \(00\).