# RZZ from CNOT and RZ

The following should represent an RZZ gate (source: https://pennylane.ai/qml/demos/tutorial_qaoa_maxcut.html)

How do the CNOT and an RZ compute mathematically to the RZZ?

$$R_Z(\theta) = \begin{pmatrix} e^{-i\frac{\theta}{2}} & 0 \\ 0 & e^{i\frac{\theta}{2}} \end{pmatrix}$$

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

The above circuit, if I understand, should result in the following:

$$R_{ZZ}(\theta) = \begin{pmatrix} e^{-i\frac{\theta}{2}} & 0 & 0 & 0 \\ 0 & e^{i\frac{\theta}{2}} & 0 & 0 \\ 0 & 0 & e^{i\frac{\theta}{2}} & 0 \\ 0 & 0 & 0& e^{-i\frac{\theta}{2}} \end{pmatrix}$$

• This technique can actually be extended to any number of qubit interactions. E.g. $Z_1 Z_2 Z_3$ would involve a CNOT from 1 to 3, and 2 to 3, a RZ gate on qubit 3, and then mirror the CNOTs on the other side of the RZ gate. Feb 23, 2023 at 22:10

The $$R_Z(\theta)$$ operator is in reality the $$I \otimes R_Z(\theta)$$ operator which makes it \begin{align} I \otimes R_Z(\theta) &= \begin{pmatrix} 1 & 0 \\ 0 & 1 \end{pmatrix} \otimes \begin{pmatrix} e^{-i\frac{\theta}{2}} & 0 \\ 0 & e^{i\frac{\theta}{2}} \end{pmatrix} \\ &= \begin{pmatrix} e^{-i\frac{\theta}{2}} & 0 & 0 & 0 \\ 0 & e^{i\frac{\theta}{2}} & 0 & 0 \\ 0 & 0 & e^{-i\frac{\theta}{2}} & 0 \\ 0 & 0 & 0 & e^{i\frac{\theta}{2}}\end{pmatrix} \end{align} This is because if you have to include the identity operator when looking at the overall 2-qubit system. Now you can perform the matrix multiplication
\begin{align} CNOT\left(I \otimes R_Z(\theta)\right)CNOT &= \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0\end{pmatrix} \begin{pmatrix} e^{-i\frac{\theta}{2}} & 0 & 0 & 0 \\ 0 & e^{i\frac{\theta}{2}} & 0 & 0 \\ 0 & 0 & e^{-i\frac{\theta}{2}} & 0 \\ 0 & 0 & 0 & e^{i\frac{\theta}{2}}\end{pmatrix} \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0\end{pmatrix} \end{align} which will give you the $$R_{ZZ}(\theta)$$ matrix you have written (up to a global phase).
$$(I - Z_1Z_2)/2 = \begin{pmatrix} 0&0&0&0\\ 0&1&0&0\\ 0&0&1&0\\ 0&0&0&0 \end{pmatrix}$$ So looking at $$R_{ZZ}(\theta) = e^{-i\theta(I-Z_1Z_2)/2}$$, we can again easily see that $$R_{ZZ}(\theta)=\begin{pmatrix} 1&0&0&0\\ 0&e^{-i\theta}&0&0\\ 0&0&e^{-i\theta}&0\\ 0&0&0&1 \end{pmatrix}.$$ Now, you correctly conclude the resulting matrix from the circuit above, getting $$R_{ZZ}(\theta)=\begin{pmatrix} e^{-i\frac{\theta}{2}}&0&0&0\\ 0&e^{i\frac{\theta}{2}}&0&0\\ 0&0&e^{i\frac{\theta}{2}}&0\\ 0&0&0&e^{-i\frac{\theta}{2}} \end{pmatrix},$$ which you'll notice we can rewrite as $$R_{ZZ}(\theta)=e^{-i\frac{\theta}{2}}\begin{pmatrix} 1&0&0&0\\ 0&e^{i\theta}&0&0\\ 0&0&e^{i\theta}&0\\ 0&0&0&1 \end{pmatrix},$$ Giving us the same matrix as above up to some global phase differences, which we can generally ignore.