I am unsure how exactly it can be inferred that the following sequence of logic gates and rotation operators acting on a three-qubit state $\lvert abc\rangle$

$$ R_{y,c}\left(\frac{\pi}{4}\right)CNOT(b,c)R_{y,c}\left(\frac{\pi}{4}\right)CNOT(a,c)R_{y,c}\left(-\frac{\pi}{4}\right)CNOT(b,c) R_{y,c}\left(-\frac{\pi}{4}\right) $$

(Where, for example, $R_{y,c}(\frac{\pi}{4})$ represents a $\frac{\pi}{4}$ rotation of qubit c about the y-axis and CNOT(b,c) represents the CNOT gate acting on the qubits b and c (b is the control and c is the target).)

Can represent that of a Toffoli gate but with relative phases.

My specific problem with understanding this sequence are the rotation operators. If I neglect the rotation operators and just apply the three CNOT logic gates for some state $\lvert abc\rangle$ (e.g. $\lvert 110\rangle$), it is apparent that the sequence of the three CNOT gates acts as a single Toffoli gate. But I'm confused by trying to understand what effect the rotation operators have on each c qubit. Do they cancel each other out? Do they impose a net rotation on some state $\lvert abc\rangle$?

I've tried to make sense of it all by envisioning rotations on a Bloch sphere but it hasn't helped. If anyone could provide an explanation as to what effect a rotation operator has on a qubit, that would be helpful. Thank you.


1 Answer 1


The key observation is that commuting $X$ through a $Y$ rotation changes the sign of the rotation angle

$$ XR_y(\theta) = R_y(-\theta)X. $$

In order to understand how the circuit gives rise to a Toffoli-like gate, we consider three cases.

First, suppose that $a$ is in the state $|0\rangle$. Then $CNOT(a, c)$ acts as identity and the sequence simplifies as

$$ R_{y,c}\left(\frac{\pi}{4}\right)CNOT(b,c)R_{y,c}\left(\frac{\pi}{4}\right)R_{y,c}\left(-\frac{\pi}{4}\right)CNOT(b,c) R_{y,c}\left(-\frac{\pi}{4}\right) = \\ R_{y,c}\left(\frac{\pi}{4}\right)CNOT(b,c)CNOT(b,c) R_{y,c}\left(-\frac{\pi}{4}\right) = \\ R_{y,c}\left(\frac{\pi}{4}\right)R_{y,c}\left(-\frac{\pi}{4}\right) = \\ I. $$

Next, suppose that qubits $ab$ are in the state $|10\rangle$. Then $CNOT(a, c)$ acts as Pauli $X$ on $c$ and each $CNOT(b, c)$ acts as identity and the sequence simplifies as

$$ R_{y,c}\left(\frac{\pi}{4}\right)R_{y,c}\left(\frac{\pi}{4}\right)X_cR_{y,c}\left(-\frac{\pi}{4}\right) R_{y,c}\left(-\frac{\pi}{4}\right) = \\ R_{y,c}\left(\frac{\pi}{4}\right)R_{y,c}\left(\frac{\pi}{4}\right)R_{y,c}\left(\frac{\pi}{4}\right) R_{y,c}\left(\frac{\pi}{4}\right)X_c = \\ R_{y,c}(\pi) X_c = -iY_cX_c = Z_c. $$

Finally, suppose that qubits $ab$ are in the state $|11\rangle$. Then all three CNOTs act as Pauli $X$ on $c$ and the sequence simplifies as

$$ R_{y,c}\left(\frac{\pi}{4}\right)X_cR_{y,c}\left(\frac{\pi}{4}\right)X_cR_{y,c}\left(-\frac{\pi}{4}\right)X_cR_{y,c}\left(-\frac{\pi}{4}\right) = \\ R_{y,c}\left(\frac{\pi}{4}\right)R_{y,c}\left(-\frac{\pi}{4}\right)X_cX_cR_{y,c}\left(-\frac{\pi}{4}\right)R_{y,c}\left(\frac{\pi}{4}\right)X_c = \\ R_{y,c}\left(\frac{\pi}{4}\right)R_{y,c}\left(-\frac{\pi}{4}\right)R_{y,c}\left(-\frac{\pi}{4}\right)R_{y,c}\left(\frac{\pi}{4}\right)X_c = X_c $$

We have shown that the action of the circuit on the computational basis is

$$ \begin{array}{ccc} |000\rangle & \to & |000\rangle \\ & \dots & \\ |011\rangle & \to & |011\rangle \\ |100\rangle & \to & |100\rangle \\ |101\rangle & \to & -|101\rangle \\ |110\rangle & \to & |111\rangle \\ |111\rangle & \to & |110\rangle \end{array} $$

which neglecting the phase change on $|101\rangle$ is that of the Toffoli gate. Action of an operator on a basis completely determines the operator.

Note that it is not true that without the $Y$ rotations the circuit is equivalent to a Toffoli with phases. In that case, the two $CNOT(b, c)$ gates cancel and all we are left with is $CNOT(a, c)$.

  • 1
    $\begingroup$ Thank you, Adam. Your answer was very helpful. $\endgroup$
    – Coconut
    Commented Jan 21, 2021 at 3:18
  • $\begingroup$ You're welcome! I'm happy it helped :-) $\endgroup$ Commented Jan 21, 2021 at 3:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.