Quantum Gates Cheat Sheet
Single-Qubit Gates
| Gate | Symbol | Matrix | Effect | Qiskit | Cirq |
|---|---|---|---|---|---|
| Hadamard | H | 1/√2 [[1,1],[1,-1]] | |0⟩→|+⟩, |1⟩→|-⟩ | qc.h(q) | cirq.H(q) |
| Pauli-X | X | [[0,1],[1,0]] | Bit flip: |0⟩↔|1⟩ | qc.x(q) | cirq.X(q) |
| Pauli-Y | Y | [[0,-i],[i,0]] | Bit+phase flip | qc.y(q) | cirq.Y(q) |
| Pauli-Z | Z | [[1,0],[0,-1]] | Phase flip on |1⟩ | qc.z(q) | cirq.Z(q) |
| S gate | S | [[1,0],[0,i]] | Phase shift π/2 | qc.s(q) | cirq.S(q) |
| T gate | T | [[1,0],[0,e^iπ/4]] | Phase shift π/4 | qc.t(q) | cirq.T(q) |
| Rx(θ) | Rx | [[cos θ/2, -i sin θ/2],[-i sin θ/2, cos θ/2]] | Rotate around X by θ | qc.rx(θ,q) | cirq.rx(θ)(q) |
| Ry(θ) | Ry | [[cos θ/2, -sin θ/2],[sin θ/2, cos θ/2]] | Rotate around Y by θ | qc.ry(θ,q) | cirq.ry(θ)(q) |
| Rz(θ) | Rz | [[e^-iθ/2,0],[0,e^iθ/2]] | Rotate around Z by θ | qc.rz(θ,q) | cirq.rz(θ)(q) |
Two-Qubit Gates
| Gate | Effect | Qiskit | Cirq |
|---|---|---|---|
| CNOT (CX) | Flips target if control=|1⟩ | qc.cx(c,t) | cirq.CNOT(c,t) |
| CZ | Phase flips target if both |1⟩ | qc.cz(q1,q2) | cirq.CZ(q1,q2) |
| SWAP | Exchanges states of two qubits | qc.swap(q1,q2) | cirq.SWAP(q1,q2) |
| iSWAP | SWAP with phase i | qc.iswap(q1,q2) | cirq.ISWAP(q1,q2) |
Three-Qubit Gates
| Gate | Effect | Qiskit | Cirq |
|---|---|---|---|
| Toffoli (CCX) | Flips target if both controls |1⟩ | qc.ccx(c1,c2,t) | cirq.CCX(c1,c2,t) |
| Fredkin (CSWAP) | Swaps two qubits if control |1⟩ | qc.cswap(c,q1,q2) | cirq.FREDKIN(c,q1,q2) |
Key Identities
| Identity | Meaning |
|---|---|
| H·X·H = Z | Conjugate X with H to get Z |
| H·Z·H = X | Conjugate Z with H to get X |
| S = T² | S gate is T applied twice |
| T⁸ = I | T has order 8 |
| X·X = I | X is its own inverse |
| H·H = I | H is its own inverse |
| CNOT·CNOT = I | CNOT is its own inverse |