# Two-Qubit Gates **Two-qubit gates** act on pairs of qubits, represented by $4 \times 4$ matrices. They create and manipulate entanglement. Most quantum computations rely heavily on two-qubit gates. ## CNOT (CX) **[[quantum-gate-cnot|CNOT]]** (Controlled-NOT or CX) is the most common entangling gate. It flips the target qubit if the control qubit is $|1\rangle$. Self-inverse ($\text{CNOT}^2 = I$) and asymmetric (control and target are distinct), it is essential for universal quantum computation. $$\text{CNOT} = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \end{pmatrix}$$ Basis action: $|00\rangle \to |00\rangle$, $|01\rangle \to |01\rangle$, $|10\rangle \to |11\rangle$, $|11\rangle \to |10\rangle$. ## Controlled-Z (CZ) **[[quantum-gate-cz|CZ]]** (Controlled-Z) applies a phase to the $|11\rangle$ state without changing basis states. Self-inverse ($\text{CZ}^2 = I$) and symmetric (control and target are interchangeable), it relates to CNOT by Hadamards on the target: $\text{CZ} = H_t \text{CNOT} H_t$. $$\text{CZ} = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & -1 \end{pmatrix}$$ ## SWAP **[[quantum-gate-swap|SWAP]]** exchanges two qubits without entangling them. Self-inverse ($\text{SWAP}^2 = I$) and symmetric, it can be decomposed into three CNOTs: $\text{SWAP} = \text{CX}_{01} \text{CX}_{10} \text{CX}_{01}$. $$\text{SWAP} = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \end{pmatrix}$$ ## iSWAP **[[quantum-gate-iswap|iSWAP]]** swaps two qubits and applies a phase. With $\text{iSWAP}^4 = I$, it is a native gate on some platforms (transmon qubits via flux tuning) and has an entangling character distinct from CNOT or CZ. $$\text{iSWAP} = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 0 & i & 0 \\ 0 & i & 0 & 0 \\ 0 & 0 & 0 & 1 \end{pmatrix}$$ ## Controlled-Phase (CPHASE) **[[quantum-gate-cphase|Controlled-Phase]]** applies a programmable phase to the $|11\rangle$ state in the form $\text{CPHASE}(\theta)$. Parametric and symmetric (control and target interchangeable), it reduces to $\text{CZ}$ when $\theta = \pi$. $$\text{CPHASE}(\theta) = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & e^{i\theta} \end{pmatrix}$$ ## XX (Parametric) **[[quantum-gate-xx|XX]]** is a parametric two-qubit gate implementing correlated X rotations. Symmetric and entangling, it is native on many platforms; $\text{XX}(\pi/2)$ creates Bell-state-like entanglement. $$\text{XX}(\theta) = e^{-i\theta X_1 X_2 / 2} = \begin{pmatrix} \cos(\theta/2) & 0 & 0 & -i\sin(\theta/2) \\ 0 & \cos(\theta/2) & -i\sin(\theta/2) & 0 \\ 0 & -i\sin(\theta/2) & \cos(\theta/2) & 0 \\ -i\sin(\theta/2) & 0 & 0 & \cos(\theta/2) \end{pmatrix}$$ ## YY (Parametric) **[[quantum-gate-yy|YY]]** is a parametric two-qubit gate implementing correlated Y rotations. Symmetric and entangling, it is less commonly native than XX or ZZ but available on some platforms. $$\text{YY}(\theta) = e^{-i\theta Y_1 Y_2 / 2} = \begin{pmatrix} \cos(\theta/2) & 0 & 0 & i\sin(\theta/2) \\ 0 & \cos(\theta/2) & -i\sin(\theta/2) & 0 \\ 0 & -i\sin(\theta/2) & \cos(\theta/2) & 0 \\ i\sin(\theta/2) & 0 & 0 & \cos(\theta/2) \end{pmatrix}$$ ## ZZ (Parametric) **[[quantum-gate-zz|ZZ]]** is a parametric two-qubit gate implementing correlated Z rotations (phase interactions). Diagonal and native on most platforms, it is the most commonly used parametric gate for variational algorithms (QAOA, VQE). $$\text{ZZ}(\theta) = e^{-i\theta Z_1 Z_2 / 2} = \begin{pmatrix} e^{-i\theta/2} & 0 & 0 & 0 \\ 0 & e^{i\theta/2} & 0 & 0 \\ 0 & 0 & e^{i\theta/2} & 0 \\ 0 & 0 & 0 & e^{-i\theta/2} \end{pmatrix}$$