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)=αx2=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 ab|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=(0ii0)Z=(1001)H=12(1111)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+i1i1i1+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θ2isinθ2isinθ2cosθ2)  Ry(θ)=(cosθ2sinθ2sinθ2cosθ2)  Rz(θ)=(eiθ/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θ2eiλsinθ2eiϕsinθ2ei(ϕ+λ)cosθ2)RP(θ)=eiθP/2=cosθ2Iisinθ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 01\|0\rangle\leftrightarrow\|1\rangle 180° about x
Y bit+phase flip 180° about y
Z 11\|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

CXct:flip t iff c=1CZ=diag(1,1,1,1)SWAP:abbaCX_{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
CX01 (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=00I+11UC\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=(IH)CX(IH)CZ = (I{\otimes}H)CX(I{\otimes}H)
SS=IS S^\dagger = I, TT=IT T^\dagger = I SXS=YSXS^\dagger = Y (HH)CX01(HH)=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(λ)=eiλ/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θ20+eiϕsinθ21,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 (UU=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: Z0=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(θ)0R_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: 00=12(I+Z)|0\rangle\langle0| = \tfrac12(I{+}Z), 11=12(IZ)|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 SS^\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(1p)/N12N\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(1p)P\langle P\rangle \to (1{-}p)\langle P\rangle; kk layers ⇒ (1p)k(1{-}p)^k. Readout ε: (12ϵ)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: Hnx=2n/2y(1)xyyH^{\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=sxf = s\cdot x; output = ss. 1 query.
  • Grover: sinθ=M/N\sin\theta = \sqrt{M/N}; P(t)=sin2((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: x2n/2ye2πixy/2ny|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 axmodNa^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(d1)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=amplitude2P = |\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θ2Iisinθ2PR_P(\theta) = \cos\frac\theta2 I - i\sin\frac\theta2 P; period 4π; Rz(π)=iZZR_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: (1p)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.