Let's say you have a circuit that performs a Z-rotation in the first register, and a Y-rotation in second register. How can we express this "moment" in terms of a 4x4 matrix, i.e. a two-qubit gate? My end goal is to express the circuit below in terms of only tfq.util.get_supported_gates
:
{cirq.X: 1,
cirq.XX: 2,
cirq.Y: 1,
cirq.YY: 2,
cirq.Z: 1,
cirq.ZZ: 2,
cirq.H: 1,
cirq.CZ: 2,
cirq.CNOT: 2,
cirq.SWAP: 2,
cirq.ISWAP: 2,
cirq.FSimGate(theta=0.123, phi=0.456): 2,
cirq.I: 1,
cirq.PhasedXPowGate(phase_exponent=0.123): 1,
cirq.PhasedISwapPowGate(phase_exponent=0.123): 2}
But I would like to start by understanding how I would represent just the first stacked Y- and Z-rotation in terms of a 4x4 matrix. For each moment, after I have the matrix representation, I plan to use cirq.two_qubit_matrix_to_operations
to decompose this quasi-two-qubit operation into Z/XY/CZ gates.
Are either of these the correct representation for $Rz(\gamma)$ and $Ry(\theta)$ rotations in registers one and two respectively?
1. $$ \begin{pmatrix} \cos{\theta} & -\sin{\theta} & 0 & 0 \\ \sin{\theta} & \cos{\theta} & 0 & 0 \\ 0 & 0 & e^{-i\gamma/2} & 0 \\ 0 & 0 & 0 & e^{i\gamma/2} \end{pmatrix} $$
2. $$ \begin{pmatrix} e^{-i\gamma/2}\cos{\theta} & 0 & -e^{-i\gamma/2}\sin{\theta} & 0 \\ 0 & e^{i\gamma/2}\cos{\theta} & 0 & -e^{i\gamma/2}\sin{\theta} \\ e^{-i\gamma/2}\sin{\theta} & 0 & e^{-i\gamma/2}\cos{\theta} & 0 \\ 0 & e^{i\gamma/2}\sin{\theta} & 0 & e^{i\gamma/2}\cos{\theta} \end{pmatrix} $$