Skip to content
Kartikey Purohit
← Course overview

Reference

Quantum Math Cheatsheet

Companion to final-review-cheatsheet.md (which covers Qiskit API syntax). This sheet is the physics/math layer: every matrix, the Bloch sphere, the identities, the algorithms. If it's on this sheet, be able to write it from memory.


1. States

∣0⟩=(10)∣1⟩=(01)∣±⟩=12(1±1)∣±i⟩=12(1±i)|0\rangle = \begin{pmatrix}1\\0\end{pmatrix}\quad |1\rangle = \begin{pmatrix}0\\1\end{pmatrix}\quad |\pm\rangle = \tfrac{1}{\sqrt2}\begin{pmatrix}1\\\pm1\end{pmatrix}\quad |{\pm i}\rangle = \tfrac{1}{\sqrt2}\begin{pmatrix}1\\\pm i\end{pmatrix}
  • General qubit: ∣ψ⟩=α∣0⟩+β∣1⟩|\psi\rangle = \alpha|0\rangle + \beta|1\rangle,   ∣α∣2+∣β∣2=1\;|\alpha|^2 + |\beta|^2 = 1.
  • Born rule: P(x)=∣αx∣2=∣⟨x∣ψ⟩∣2P(x) = |\alpha_x|^2 = |\langle x|\psi\rangle|^2; state collapses to the outcome.
  • Bra = conjugate-transpose: ⟨ψ∣=(∣ψ⟩)†\langle\psi| = (|\psi\rangle)^\dagger. Inner product ⟨ϕ∣ψ⟩\langle\phi|\psi\rangle; orthogonal ⇔ 0.
  • Global phase eiγ∣ψ⟩e^{i\gamma}|\psi\rangle: unobservable. Relative phase: observable (after basis change).
  • Tensor product stacks systems: (a0a1)⊗(b0b1)=(a0b0a0b1a1b0a1b1)\begin{pmatrix}a_0\\a_1\end{pmatrix}\otimes\begin{pmatrix}b_0\\b_1\end{pmatrix} = \begin{pmatrix}a_0b_0\\a_0b_1\\a_1b_0\\a_1b_1\end{pmatrix}; nn qubits = 2n2^n amplitudes.
  • Qiskit is little-endian: qubit 0 = least significant bit = rightmost in bitstrings = top wire in drawings. "ZIX" = Z on q2, I on q1, X on q0.

Bell states (all four)

∣Φ±⟩=12(∣00⟩±∣11⟩)∣Ψ±⟩=12(∣01⟩±∣10⟩)|\Phi^\pm\rangle = \tfrac{1}{\sqrt2}(|00\rangle \pm |11\rangle)\qquad |\Psi^\pm\rangle = \tfrac{1}{\sqrt2}(|01\rangle \pm |10\rangle)

h(0); cx(0,1) on ∣00⟩|00\rangle → ∣Φ+⟩|\Phi^+\rangle. GHZ: 12(∣0n⟩+∣1n⟩)\tfrac{1}{\sqrt2}(|0^n\rangle + |1^n\rangle); W: 13(∣001⟩+∣010⟩+∣100⟩)\tfrac{1}{\sqrt3}(|001\rangle+|010\rangle+|100\rangle).

Entangled = not writable as ∣a⟩⊗∣b⟩|a\rangle\otimes|b\rangle. Reduced state of a Bell qubit = I/2I/2 (maximally mixed).

2. Single-qubit gate matrices (write all from memory)

X=(0110)Y=(0−ii0)Z=(100−1)H=12(111−1)X = \begin{pmatrix}0&1\\1&0\end{pmatrix}\quad Y = \begin{pmatrix}0&-i\\i&0\end{pmatrix}\quad Z = \begin{pmatrix}1&0\\0&-1\end{pmatrix}\quad H = \tfrac{1}{\sqrt2}\begin{pmatrix}1&1\\1&-1\end{pmatrix}
S=(100i)T=(100eiπ/4)P(λ)=(100eiλ)SX=12(1+i1−i1−i1+i)S = \begin{pmatrix}1&0\\0&i\end{pmatrix}\quad T = \begin{pmatrix}1&0\\0&e^{i\pi/4}\end{pmatrix}\quad P(\lambda) = \begin{pmatrix}1&0\\0&e^{i\lambda}\end{pmatrix}\quad SX = \tfrac12\begin{pmatrix}1{+}i&1{-}i\\1{-}i&1{+}i\end{pmatrix}
Rx(θ)=(cos⁡θ2−isin⁡θ2−isin⁡θ2cos⁡θ2)  Ry(θ)=(cos⁡θ2−sin⁡θ2sin⁡θ2cos⁡θ2)  Rz(θ)=(e−iθ/200eiθ/2)R_x(\theta){=}\begin{pmatrix}\cos\frac\theta2&-i\sin\frac\theta2\\-i\sin\frac\theta2&\cos\frac\theta2\end{pmatrix}\; R_y(\theta){=}\begin{pmatrix}\cos\frac\theta2&-\sin\frac\theta2\\\sin\frac\theta2&\cos\frac\theta2\end{pmatrix}\; R_z(\theta){=}\begin{pmatrix}e^{-i\theta/2}&0\\0&e^{i\theta/2}\end{pmatrix}
U(θ,ϕ,λ)=(cos⁡θ2−eiλsin⁡θ2eiϕsin⁡θ2ei(ϕ+λ)cos⁡θ2)RP(θ)=e−iθP/2=cos⁡θ2I−isin⁡θ2PU(\theta,\phi,\lambda) = \begin{pmatrix}\cos\frac\theta2 & -e^{i\lambda}\sin\frac\theta2\\ e^{i\phi}\sin\frac\theta2 & e^{i(\phi+\lambda)}\cos\frac\theta2\end{pmatrix}\qquad R_P(\theta) = e^{-i\theta P/2} = \cos\tfrac\theta2 I - i\sin\tfrac\theta2 P

Gate actions in words

Gate Action Bloch move
X bit-flip ∥0⟩↔∥1⟩\|0\rangle\leftrightarrow\|1\rangle 180° about x
Y bit+phase flip 180° about y
Z ∥1⟩→−∥1⟩\|1\rangle \to -\|1\rangle 180° about z
H ∥0⟩→∥+⟩\|0\rangle\to\|+\rangle, ∥1⟩→∥−⟩\|1\rangle\to\|-\rangle 180° about x+z diagonal
S ∥+⟩→∥+i⟩\|+\rangle\to\|{+i}\rangle 90° about z
T 8th root of Z 45° about z
Rx/Ry/Rz(θ) continuous θ about that axis

3. Multi-qubit gates

CXc→t:flip t iff c=1CZ=diag(1,1,1,−1)SWAP:∣ab⟩→∣ba⟩CX_{c\to t}: \text{flip } t \text{ iff } c{=}1 \qquad CZ = \mathrm{diag}(1,1,1,-1) \qquad SWAP: |ab\rangle\to|ba\rangle
CX0→1 (LE basis ∣q1q0⟩)=(1000000100100100)SWAP=(1000001001000001)CX_{0\to1} \text{ (LE basis } |q_1q_0\rangle{)} = \begin{pmatrix}1&0&0&0\\0&0&0&1\\0&0&1&0\\0&1&0&0\end{pmatrix}\qquad SWAP = \begin{pmatrix}1&0&0&0\\0&0&1&0\\0&1&0&0\\0&0&0&1\end{pmatrix}
  • General recipe: C-U=∣0⟩⟨0∣⊗I+∣1⟩⟨1∣⊗UC\text{-}U = |0\rangle\langle0|\otimes I + |1\rangle\langle1|\otimes U.
  • CCX (Toffoli) = AND into target; CSWAP (Fredkin) = controlled swap.
  • Symmetric (argument order irrelevant): cz, cp, swap, iswap, rxx, ryy, rzz. Asymmetric: cx, cy, ch, ecr, crx, cry, crz.

4. Identities (the exam's favorite pool)

Powers/inverses Conjugations Structural
H2=X2=Y2=Z2=IH^2{=}X^2{=}Y^2{=}Z^2{=}I HXH=ZHXH = Z, HZH=XHZH = X SWAP=CX01CX10CX01SWAP = CX_{01}CX_{10}CX_{01}
T2=S,  S2=Z,  T4=ZT^2 = S,\; S^2 = Z,\; T^4 = Z HYH=−YHYH = -Y CZ=(I⊗H)CX(I⊗H)CZ = (I{\otimes}H)CX(I{\otimes}H)
SS†=IS S^\dagger = I, TT†=IT T^\dagger = I SXS†=YSXS^\dagger = Y (H⊗H)CX01(H⊗H)=CX10(H{\otimes}H)CX_{01}(H{\otimes}H) = CX_{10}
SX2=XSX^2 = X HRx(θ)H=Rz(θ)HR_x(\theta)H = R_z(\theta) Y=iXZY = iXZ; XY=iZXY = iZ, YZ=iXYZ = iX, ZX=iYZX = iY
RP(α)RP(β)=RP(α+β)R_P(\alpha)R_P(\beta) = R_P(\alpha{+}\beta) distinct Paulis anticommute

Phase-gate ladder: Z=P(π)Z = P(\pi), S=P(π/2)S = P(\pi/2), T=P(π/4)T = P(\pi/4); Rz(λ)=e−iλ/2P(λ)R_z(\lambda) = e^{-i\lambda/2}P(\lambda) — equal only up to global phase ⇒ p(π) == z exactly, rz(π) = −iZ (equiv, not equal). Controlled versions differ for real.

Rotation periods: RP(2π)=−IR_P(2\pi) = -I, RP(4π)=IR_P(4\pi) = I.

5. Bloch sphere

∣ψ⟩=cos⁡θ2∣0⟩+eiϕsin⁡θ2∣1⟩,r⃗=(⟨X⟩,⟨Y⟩,⟨Z⟩)=(sin⁡θcos⁡ϕ,sin⁡θsin⁡ϕ,cos⁡θ)|\psi\rangle = \cos\tfrac\theta2|0\rangle + e^{i\phi}\sin\tfrac\theta2|1\rangle,\qquad \vec r = (\langle X\rangle, \langle Y\rangle, \langle Z\rangle) = (\sin\theta\cos\phi, \sin\theta\sin\phi, \cos\theta)
  • Poles: ∣0⟩|0\rangle north, ∣1⟩|1\rangle south. Equator: ∣+⟩|+\rangle +x, ∣−⟩|-\rangle −x, ∣+i⟩|{+i}\rangle +y, ∣−i⟩|{-i}\rangle −y.
  • Orthogonal states = antipodal points. Mixed states = inside the ball; I/2I/2 = center.
  • ρ=12(I+r⃗⋅σ⃗)\rho = \tfrac12(I + \vec r\cdot\vec\sigma); entangled qubit ⇒ short/zero arrow in per-qubit plots.
  • Q-sphere (whole register): node per bitstring, size = probability, color = phase, latitude = Hamming weight.

6. Operators, observables, density matrices

  • Hermitian (A†=AA^\dagger{=}A): observables, real eigenvalues. Unitary (U†U=IU^\dagger U{=}I): gates, ∣eig∣=1|{\rm eig}|=1. Paulis & H are both.
  • Eigenbases: Z → {∣0⟩,∣1⟩}\{|0\rangle,|1\rangle\}; X → {∣+⟩,∣−⟩}\{|+\rangle,|-\rangle\}; Y → {∣+i⟩,∣−i⟩}\{|{+i}\rangle,|{-i}\rangle\} (eigenvalues ±1).
  • Expectation: ⟨A⟩=⟨ψ∣A∣ψ⟩=Tr(Aρ)=∑jλjP(j)\langle A\rangle = \langle\psi|A|\psi\rangle = \mathrm{Tr}(A\rho) = \sum_j \lambda_j P(j). ⟨Z⟩=P(0)−P(1)\langle Z\rangle = P(0) - P(1).
  • Table: ⟨Z⟩∣0⟩=1\langle Z\rangle_{|0\rangle}{=}1, ⟨X⟩∣+⟩=1\langle X\rangle_{|+\rangle}{=}1, ⟨Y⟩∣+i⟩=1\langle Y\rangle_{|+i\rangle}{=}1, all others among these states 0. Ry(θ)∣0⟩R_y(\theta)|0\rangle: ⟨Z⟩=cos⁡θ\langle Z\rangle{=}\cos\theta, ⟨X⟩=sin⁡θ\langle X\rangle{=}\sin\theta. Bell: ⟨ZZ⟩=⟨XX⟩=1\langle ZZ\rangle{=}\langle XX\rangle{=}1, ⟨YY⟩=−1\langle YY\rangle{=}-1, singles 0.
  • Any observable = real combo of Pauli strings: ∣0⟩⟨0∣=12(I+Z)|0\rangle\langle0| = \tfrac12(I{+}Z), ∣1⟩⟨1∣=12(I−Z)|1\rangle\langle1| = \tfrac12(I{-}Z).
  • Density matrix: ρ=∑pk∣ψk⟩⟨ψk∣\rho = \sum p_k|\psi_k\rangle\langle\psi_k|; Trρ=1\mathrm{Tr}\rho = 1, ρ⪰0\rho \succeq 0. Purity Tr(ρ2)\mathrm{Tr}(\rho^2): 1 pure, 1/2n1/2^n maximally mixed. Off-diagonals = coherence (superposition); none = classical mixture.
  • Partial trace: reduced state of subsystem; Bell → I/2I/2 per qubit.
  • Fidelity (Qiskit convention): F=∣⟨ψ∣ϕ⟩∣2F = |\langle\psi|\phi\rangle|^2; 1 same, 0 orthogonal; global-phase blind.
  • Pauli string commutation: count differing non-I positions — odd ⇒ anticommute.
  • Measure X: apply H, then measure Z. Measure Y: apply S†S^\dagger then H, then measure Z.

7. Measurement & statistics

  • Partial measurement: P(s)=∑consistent∣α∣2P(s) = \sum_{\text{consistent}} |\alpha|^2; post-state = renormalized projection.
  • Shots: σ(p^)=p(1−p)/N≤12N\sigma(\hat p) = \sqrt{p(1{-}p)/N} \le \tfrac{1}{2\sqrt N}. 4× shots ⇒ ½ error. 1024 → ~1.6%, 10k → 0.5%.
  • Shots fix statistical error only; gate/readout noise is systematic → mitigation.
  • Depolarizing pp: ⟨P⟩→(1−p)⟨P⟩\langle P\rangle \to (1{-}p)\langle P\rangle; kk layers ⇒ (1−p)k(1{-}p)^k. Readout ε: →(1−2ϵ)⟨Z⟩\to(1{-}2\epsilon)\langle Z\rangle.
  • Mitigation map: DD = idle dephasing (XX echo); TREX = readout; ZNE = amplify λ=1,3,5 & extrapolate to 0 (cheap, can be biased); PEC = quasi-probability cancellation (unbiased, cost γ2k\gamma^{2k}); twirling = coherent → stochastic noise.

8. Algorithms (recognition level)

  • Phase kickback: C-UC\text{-}U on eigenvector ⇒ phase eiφe^{i\varphi} lands on control. Oracle trick: ∣x⟩∣−⟩→(−1)f(x)∣x⟩∣−⟩|x\rangle|-\rangle \to (-1)^{f(x)}|x\rangle|-\rangle.
  • H-sandwich: H⊗n∣x⟩=2−n/2∑y(−1)x⋅y∣y⟩H^{\otimes n}|x\rangle = 2^{-n/2}\sum_y (-1)^{x\cdot y}|y\rangle.
  • Deutsch–Jozsa: H → oracle → H; measure 0n0^n ⇔ constant, else balanced. 1 query.
  • Bernstein–Vazirani: same circuit, f=s⋅xf = s\cdot x; output = ss. 1 query.
  • Grover: sin⁡θ=M/N\sin\theta = \sqrt{M/N}; P(t)=sin⁡2((2t+1)θ)P(t) = \sin^2((2t{+}1)\theta); topt≈π4N/Mt_{\rm opt} \approx \tfrac\pi4\sqrt{N/M}; overshoot ⇒ P drops. N=4,M=1: 1 iteration, exact. Quadratic speedup.
  • QFT: ∣x⟩→2−n/2∑ye2πixy/2n∣y⟩|x\rangle \to 2^{-n/2}\sum_y e^{2\pi ixy/2^n}|y\rangle; O(n2)O(n^2) gates; QFT₁ = H.
  • QPE: m qubits + controlled-U2jU^{2^j} + inverse QFT ⇒ m-bit binary fraction of eigenphase φ. Exact iff 2mφ∈Z2^m\varphi \in \mathbb{Z}.
  • Shor: QPE-based order finding (period r of ax mod Na^x \bmod N) + gcd⁡(ar/2±1,N)\gcd(a^{r/2}\pm1, N). Poly time.
  • Teleportation: Bell pair + 2 classical bits; corrections Zb1Xb0Z^{b_1}X^{b_0}. Superdense: 1 qubit carries 2 bits; encode {I,X,Z,ZX}\{I,X,Z,ZX\} → 4 Bell states.
  • No-cloning: linearity forbids ∣ψ⟩↦∣ψ⟩∣ψ⟩|\psi\rangle \mapsto |\psi\rangle|\psi\rangle (CNOT entangles, doesn't copy).
  • Speedups: DJ/Simon exponential (query), BV polynomial, Grover quadratic, Shor (believed) exponential.

9. Hardware math

  • Universal native set: {rz, sx, x} + entangler (cx/cz/ecr). Any 1q gate = rz·sx·rz·sx·rz (Euler); rz is virtual (free, error-less).
  • General 2q unitary ≤ 3 CNOTs; nnq unitary O(4n)O(4^n) gates. SWAP = 3 CNOTs; distance-d routing ≈ 3(d−1)3(d{-}1) extra CNOTs.
  • Success ≈ ∏fg\prod f_g: 100 gates × 99.5% ≈ 61%. T1T_1 = relaxation, T2T_2 = dephasing.
  • ISA circuit = native gates + coupling-map compliant; V2 primitives require it.

10. Constants & conversions table

Thing Value
eiπ/4e^{i\pi/4} 1+i2\tfrac{1+i}{\sqrt2}
eiπ/2,eiπ,e3iπ/2e^{i\pi/2}, e^{i\pi}, e^{3i\pi/2} i,−1,−ii, -1, -i
12\tfrac{1}{\sqrt2} ≈0.7071\approx 0.7071; (12)2=12(\tfrac{1}{\sqrt2})^2 = \tfrac12
cos⁡π4=sin⁡π4\cos\frac\pi4 = \sin\frac\pi4 12\tfrac{1}{\sqrt2}
cos⁡π3,sin⁡π3\cos\frac\pi3, \sin\frac\pi3 12,32\tfrac12, \tfrac{\sqrt3}{2}
cos⁡π6,sin⁡π6\cos\frac\pi6, \sin\frac\pi6 32,12\tfrac{\sqrt3}{2}, \tfrac12
statevector index k bitstring of k, q0 = low bit

The 12 flash-facts (final pass before the exam)

  1. P=∣amplitude∣2P = |\text{amplitude}|^2; phases invisible to Z-sampling.
  2. Little-endian everywhere: x(0) on 2 qubits ⇒ '01'.
  3. HH: 0↔+, 1↔−; H2=IH^2 = I; HXH=ZHXH = Z.
  4. T2=ST^2 = S, S2=ZS^2 = Z; dg = inverse.
  5. RP(θ)=cos⁡θ2I−isin⁡θ2PR_P(\theta) = \cos\frac\theta2 I - i\sin\frac\theta2 P; period 4π; Rz(π)=−iZ≠ZR_z(\pi) = -iZ \ne Z but ≡ Z.
  6. Bell = h + cx; ⟨ZZ⟩=⟨XX⟩=+1\langle ZZ\rangle = \langle XX\rangle = +1, ⟨YY⟩=−1\langle YY\rangle = -1; reduced state I/2I/2.
  7. Orthogonal = antipodal on Bloch; S/T/Rz spin the equator.
  8. ⟨Z⟩ = P(0) − P(1); measure X via H; measure Y via S†,H.
  9. σ = 12N\tfrac{1}{2\sqrt N}; shots ≠ bias cure.
  10. Depolarizing shrinks: (1−p)k(1-p)^k; ZNE extrapolates back to λ=0.
  11. Kickback: phases land on the control; ∣x⟩∣−⟩→(−1)f(x)∣x⟩∣−⟩|x\rangle|-\rangle \to (-1)^{f(x)}|x\rangle|-\rangle.
  12. Grover: t≈π4N/Mt \approx \tfrac\pi4\sqrt{N/M}, and MORE ITERATIONS CAN HURT.