Quantum Gates Cheat Sheet

Single-Qubit Gates

GateSymbolMatrixEffectQiskitCirq
HadamardH1/√2 [[1,1],[1,-1]]|0⟩→|+⟩, |1⟩→|-⟩qc.h(q)cirq.H(q)
Pauli-XX[[0,1],[1,0]]Bit flip: |0⟩↔|1⟩qc.x(q)cirq.X(q)
Pauli-YY[[0,-i],[i,0]]Bit+phase flipqc.y(q)cirq.Y(q)
Pauli-ZZ[[1,0],[0,-1]]Phase flip on |1⟩qc.z(q)cirq.Z(q)
S gateS[[1,0],[0,i]]Phase shift π/2qc.s(q)cirq.S(q)
T gateT[[1,0],[0,e^iπ/4]]Phase shift π/4qc.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

GateEffectQiskitCirq
CNOT (CX)Flips target if control=|1⟩qc.cx(c,t)cirq.CNOT(c,t)
CZPhase flips target if both |1⟩qc.cz(q1,q2)cirq.CZ(q1,q2)
SWAPExchanges states of two qubitsqc.swap(q1,q2)cirq.SWAP(q1,q2)
iSWAPSWAP with phase iqc.iswap(q1,q2)cirq.ISWAP(q1,q2)

Three-Qubit Gates

GateEffectQiskitCirq
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

IdentityMeaning
H·X·H = ZConjugate X with H to get Z
H·Z·H = XConjugate Z with H to get X
S = T²S gate is T applied twice
T⁸ = IT has order 8
X·X = IX is its own inverse
H·H = IH is its own inverse
CNOT·CNOT = ICNOT is its own inverse