# What is the action of sandwiching an operator with two CNOT gates?

When a gate is sandwiched (or conjugated) by two CNOT gates, what effect does it have on the gate being sandwiched? For example, in the figure below, it is clear what effect the controlled $$R_y(\theta)$$ has. The question is how the CNOT gates modify the behaviour of the controlled $$R_y(\theta)$$ gates. Controlled-$$R_y$$ with second qubit as control acts as identity on $$\mathrm{span}(|00\rangle, |10\rangle)$$ and as

$$R_y(\theta) = \begin{pmatrix} \cos\frac{\theta}{2} & -\sin\frac{\theta}{2} \\ \sin\frac{\theta}{2} & \cos\frac{\theta}{2} \end{pmatrix}$$

on $$\mathrm{span}(|01\rangle, |11\rangle)$$. Therefore,

$$CR_y(\theta) = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & \cos\frac{\theta}{2} & 0 & -\sin\frac{\theta}{2} \\ 0 & 0 & 1 & 0 \\ 0 & \sin\frac{\theta}{2} & 0 & \cos\frac{\theta}{2} \end{pmatrix}.$$

CNOT with the first qubit as control acts as the permutation matrix

$$\text{CNOT} = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \end{pmatrix}$$

which swaps $$|10\rangle$$ and $$|11\rangle$$. Consequently, the circuit in the question acts as $$CR_y(\theta)$$ with the last two rows swapped and the last two columns swapped

$$\begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & \cos\frac{\theta}{2} & -\sin\frac{\theta}{2} & 0 \\ 0 & \sin\frac{\theta}{2} & \cos\frac{\theta}{2} & 0 \\ 0 & 0 & 0 & 1 \\ \end{pmatrix}.$$

The reasoning above applies to any single qubit gate in place of $$R_y$$.

• I see. So the CNOT's are permuting which states the single qubit gates are acting on. Thank you for your answer. Feb 25 at 2:05