Quantum Gate Reference¶
Standard Single-Qubit Gates¶
Table 1. Standard single-qubit gates with matrix representations
| Gate | Symbol | Matrix | PennyLane |
|---|---|---|---|
| Identity | \(I\) | \(\begin{pmatrix}1&0\\0&1\end{pmatrix}\) | Identity |
| Pauli-X | \(X\) | \(\begin{pmatrix}0&1\\1&0\end{pmatrix}\) | PauliX |
| Pauli-Y | \(Y\) | \(\begin{pmatrix}0&-i\\i&0\end{pmatrix}\) | PauliY |
| Pauli-Z | \(Z\) | \(\begin{pmatrix}1&0\\0&-1\end{pmatrix}\) | PauliZ |
| Hadamard | \(H\) | \(\frac{1}{\sqrt{2}}\begin{pmatrix}1&1\\1&-1\end{pmatrix}\) | Hadamard |
| Phase (\(S\)) | \(S\) | \(\begin{pmatrix}1&0\\0&i\end{pmatrix}\) | S |
| \(T\) gate | \(T\) | \(\begin{pmatrix}1&0\\0&e^{i\pi/4}\end{pmatrix}\) | T |
| \(R_x(\theta)\) | \(R_x\) | \(\begin{pmatrix}\cos\frac{\theta}{2}&-i\sin\frac{\theta}{2}\\-i\sin\frac{\theta}{2}&\cos\frac{\theta}{2}\end{pmatrix}\) | RX |
| \(R_y(\theta)\) | \(R_y\) | \(\begin{pmatrix}\cos\frac{\theta}{2}&-\sin\frac{\theta}{2}\\\sin\frac{\theta}{2}&\cos\frac{\theta}{2}\end{pmatrix}\) | RY |
| \(R_z(\theta)\) | \(R_z\) | \(\begin{pmatrix}e^{-i\theta/2}&0\\0&e^{i\theta/2}\end{pmatrix}\) | RZ |
Standard Two-Qubit Gates¶
Table 2. Standard two-qubit gates
| Gate | Definition | Matrix | PennyLane |
|---|---|---|---|
| CNOT (\(CX\)) | \(|0\rangle\langle 0|\otimes I + |1\rangle\langle 1|\otimes X\) | \(\begin{pmatrix}1&0&0&0\\0&1&0&0\\0&0&0&1\\0&0&1&0\end{pmatrix}\) | CNOT |
| CZ | \(|0\rangle\langle 0|\otimes I + |1\rangle\langle 1|\otimes Z\) | \(\text{diag}(1,1,1,-1)\) | CZ |
| SWAP | Exchanges qubits | \(\begin{pmatrix}1&0&0&0\\0&0&1&0\\0&1&0&0\\0&0&0&1\end{pmatrix}\) | SWAP |
| iSWAP | \(\text{SWAP}\cdot e^{i\pi(X\otimes X+Y\otimes Y)/4}\) | \(\begin{pmatrix}1&0&0&0\\0&0&i&0\\0&i&0&0\\0&0&0&1\end{pmatrix}\) | ISWAP |
| \(CR_y(\theta)\) | \(|0\rangle\langle 0|\otimes I + |1\rangle\langle 1|\otimes R_y(\theta)\) | Block diagonal | CRY |
PennyLane Rotation Conventions¶
PennyLane uses the convention:
\[R_\alpha(\theta) = e^{-i\theta\sigma_\alpha/2}
= \cos\frac{\theta}{2}I - i\sin\frac{\theta}{2}\sigma_\alpha\tag{1}\]
Note: some sources define \(R_\alpha(\theta) = e^{+i\theta\sigma_\alpha/2}\) (opposite sign). PennyLane and Qiskit both use \(e^{-i\theta/2}\).
Gate Decompositions¶
Euler decomposition (ZYZ): Any single-qubit unitary can be written:
\[U = e^{i\alpha}R_z(\beta)R_y(\gamma)R_z(\delta)\]
CNOT from CZ: \(\text{CNOT} = (I\otimes H)\cdot CZ\cdot(I\otimes H)\)
Toffoli from CNOT: Requires 6 CNOT gates and 9 single-qubit gates.
SWAP from CNOT: \(\text{SWAP} = \text{CNOT}_{01}\cdot\text{CNOT}_{10}\cdot\text{CNOT}_{01}\)
Circuit Identities for Optimization¶
\[\begin{align*}
H X H &= Z \\
H Z H &= X \\
H Y H &= -Y \\
R_z(\theta) R_z(\phi) &= R_z(\theta+\phi) \\
R_y(\theta) R_y(\phi) &= R_y(\theta+\phi) \\
X R_x(\theta) X &= R_x(-\theta) \\
Z R_y(\theta) Z &= R_y(-\theta)
\end{align*}\]
These identities enable compiler optimization: consecutive rotations merge, Pauli conjugations flip signs.