Skip to content
NotesCS639

Quantum computing

Cheatsheet
|ψ⟩ = α|0⟩ + β|1⟩ |α|² + |β|² = 1

Kets are columns: |0⟩ = (1, 0)ᵀ, |1⟩ = (0, 1)ᵀ. The bra ⟨ψ| = (α*, β*) is the conjugate transpose.

|ψ⟩ = cos(θ/2)|0⟩ + eiφ sin(θ/2)|1⟩

Bloch sphere: θ from +z, φ around z. Global phase eiγ|ψ⟩ changes nothing; relative phase changes interference.

Two complex dimensions, one sphere

α and β give four real numbers. Normalization removes one freedom; ignoring global phase removes another. Two angles remain: 0 ≤ θ ≤ π and 0 ≤ φ < 2π.

(x, y, z) = (sin θ cos φ, sin θ sin φ, cos θ)

A pure state lies on the surface. A mixed state lies inside. The center is an equal mixture, not a zero-length ket.

Scaling amplitudes by a factor with magnitude other than 1 breaks normalization. Divide (2, i)ᵀ by √5 to normalize it; multiply by i to change only global phase.

Measurement

PZ(0) = |α|² = cos²(θ/2) PZ(1) = |β|²

After a Z measurement: outcome 0 → |0⟩; 1 → |1⟩. Another immediate Z measurement repeats it. Fresh samples need fresh preparations.

Z |0⟩, |1⟩

X |±⟩ = (|0⟩ ± |1⟩)/√2

Y |±i⟩ = (|0⟩ ± i|1⟩)/√2

|+⟩ and |−⟩ are both 50/50 in Z; perfectly distinguishable in X. Collapse is onto the measured basis, not always the poles.

Measuring in another basis
P(b) = |⟨b|ψ⟩|²

For X readout, apply H then measure Z. For Y, apply S† then H then measure Z. These rotations turn the desired basis into the computational basis; reported 0 means the + eigenstate, 1 means −.

On the Bloch sphere, measuring along a unit axis n gives P(+) = (1 + r·n)/2. Opposite ends of a diameter are orthogonal states.

|ψ′⟩ = U|ψ⟩ U†U = I · U⁻¹ = U†

Unitary gates preserve length and are reversible. Circuits run left → right; matrix products act right → left.

Single-qubit gates acting on amplitudes alpha and beta
Gate(α, β)ᵀ becomesRemember
X(β, α)ᵀSwap amplitudes
Y(−iβ, iα)ᵀY = iXZ
Z(α, −β)ᵀRelative phase π
H(α + β, α − β)ᵀ / √2|0⟩ ↔ |+⟩; |1⟩ ↔ |−⟩
S(α, iβ)ᵀS² = Z
T(α, eiπ/4β)ᵀT² = S

H² = I; HZH = X. H does not always make a 50/50 state. H|+⟩ = |0⟩.

Matrices & interference
X = Z = H = 1/√2

Start at |0⟩: H → |+⟩, Z → |−⟩, H → |1⟩. The phase difference becomes a population difference. From |1⟩ the same H–Z–H sequence returns |0⟩.

Replace Z with T: after H–T–H, P(0) = cos²(π/8) ≈ 0.854. T leaves the intermediate Z probabilities unchanged, but the last H exposes its phase.

Rk(θ) = cos(θ/2)I − i sin(θ/2)σk

σk is X, Y, or Z. These rotate the Bloch vector by θ about that axis. A gate cannot stretch a valid state off the sphere; noise and measurement need a different model.

Entanglement

|a⟩ ⊗ |b⟩ = (a₀b₀, a₀b₁, a₁b₀, a₁b₁)ᵀ

Basis order: |00⟩, |01⟩, |10⟩, |11⟩. n qubits need 2ⁿ complex amplitudes; one measurement returns just n bits.

CNOT|a,b⟩ = |a, b ⊕ a⟩

H on the first qubit, then CNOT: |00⟩ → (|00⟩ + |11⟩)/√2 = |Φ⁺⟩. Each qubit is random; their Z outcomes always match.

Pure-state test: a|00⟩ + b|01⟩ + c|10⟩ + d|11⟩ is a product state iff ad = bc. Otherwise, entangled.

Bell states & correlations
|Φ±⟩ = (|00⟩ ± |11⟩)/√2
|Ψ±⟩ = (|01⟩ ± |10⟩)/√2

The four Bell states form an orthonormal basis. |Φ⁺⟩ has matching X and Z outcomes, opposite Y outcomes. An equal classical mixture of |00⟩ and |11⟩ matches in Z too, but has no X correlation. One basis alone cannot establish entanglement.

A product state such as |+⟩⊗|+⟩ has independent outcomes. A Bell pair has no separate pure ket for either half. Neither party can use local measurements to signal to the other.

SWAP, Toffoli & Fredkin

SWAP: |a,b⟩ → |b,a⟩. Three CNOTs with alternating control: A→B, B→A, A→B.

Toffoli (CCX): |a,b,c⟩ → |a,b,c ⊕ ab⟩. With c = 0, writes AND while retaining its inputs.

Fredkin (CSWAP): swap the last two qubits iff the first is 1; preserves the number of 1s. Controlled gates act linearly on superpositions, without measuring the control.

No cloning: no operation copies every unknown quantum state. Teleportation consumes the original.

Teleportation

1 shared Bell pair + 2 classical bits → transfer 1 unknown qubit state.

Superdense coding ↗

1 shared Bell pair + send 1 qubit → transfer 2 chosen classical bits.

Teleport: CNOT(input→Alice), H(input), measure both. For bits m₀m₁, Bob applies Xm₁ then Zm₀.

00 → I 01 → X10 → Z11 → X then Z
Why the protocols work

After Alice’s two gates, the teleportation state is

½ ∑m₀,m₁ |m₀m₁⟩ ⊗ Xm₁Zm₀|ψ⟩.

Every branch has probability ¼. Bob’s correction undoes its two gates. Without the classical bits he has the equal mixture I/2, independent of |ψ⟩; no faster-than-light message.

Dense coding: encode chosen bits ab by Xb then Za on Alice’s half of |Φ⁺⟩. Send that half. Bob applies CNOT(A→B), H(A), then measures to recover ab. The four encodings I, X, Z, ZX select four distinguishable Bell states; Y is equivalent to ZX up to global phase.

No-cloning in one line: a device copying |0⟩ and |1⟩ maps |+⟩|0⟩ to |Φ⁺⟩ by linearity, not to |+⟩|+⟩.

Coherent error: a systematic wrong rotation. Decoherence: information lost to the environment. Idle time counts too.

T₁ · relaxation

|1⟩ population → |0⟩

P(1, t) = P(1, 0)e−t/T₁

T₂ · coherence

Transverse Bloch vector shrinks

rx,y(t) = rx,y(0)e−t/T₂
1/T₂ = 1/(2T₁) + 1/Tφ T₂ ≤ 2T₁

Exponential, zero-temperature model; Tφ is pure dephasing. Time constants are not deadlines: one T₁ leaves about 37% of the excited population.

Measuring T₁ / T₂ & telling errors apart

T₁: |0⟩ → X → wait t → Z readout; fit Ae−t/T₁ + B.

T₂ echo: |0⟩ → H → wait t/2 → X → wait t/2 → H → Z readout; fit A + Ce−t/T₂. The middle X refocuses slow phase drift. Without it, Ramsey measures T₂*, usually shorter.

Pauli model: X flips the bit, Z flips phase, Y does both. Z errors hide in immediate Z readout but alter later interference. A readout error instead mislabels the classical result.

Leakage leaves the |0⟩, |1⟩ subspace. Crosstalk depends on neighboring operations. Neither is fully described by independent Pauli errors.

Hardware

program → circuit → native gates → pulses

A QPU is an accelerator with classical control. DACs turn instructions into waveforms; ADCs turn readout signals into digital samples.

Transmon: a Josephson junction makes LC energy levels uneven, so |0⟩↔|1⟩ can be addressed selectively. A SQUID enables flux tuning.

Connectivity costs: mapping chooses physical qubits; routing inserts movement. SWAP = 3 CNOTs. One logical gate can become many native gates.

Native operations & the physical cost

Native sets differ: Rz and √X for single-qubit control; CZ, ECR, iSWAP, or FSim for entangling interactions. CZ changes only |11⟩’s sign; iSWAP exchanges |01⟩ and |10⟩ with a factor i. Abstract CNOT may need decomposition.

A virtual Z rotation changes the control phase reference; it can take effectively no extra pulse time. Fixed-frequency transmons trade tunability for simpler control; flux-tunable devices add flexibility and noise sensitivity.

Quantum simulation and factoring motivate specialized quantum algorithms. Exponential state size alone does not guarantee a speedup. Error correction encodes a logical qubit across many physical qubits; its overhead depends on the code and noise.

Reliability

Count ≠ depth ≠ duration. Count operations; depth counts dependent layers; duration includes gate latencies, routing, and idle time. Parallelism can add crosstalk.

Pno error ≈ ∏g(1 − εg)

Independent-error estimate only. A correct answer can survive an error; device fidelity alone does not predict application success.

TVD(P, Q) = ½ ∑x |P(x) − Q(x)| 0 ≤ TVD ≤ 1

For a defined answer: success rate = correct shots / all shots. For distributions: 1 − TVD is a similarity score, not quantum-state fidelity.

A distribution example & the limits of a score

Bell outcomes (00, 01, 10, 11): ideal (½, 0, 0, ½), observed (0.4, 0.1, 0.1, 0.4). TVD = 0.2; similarity = 0.8. The ½ avoids counting moved probability twice.

H(P) = −∑x P(x) log₂ P(x)

Entropy measures spread, not error. Ideal uniform output has high entropy; relaxation can lower it. Matching one basis can miss phase errors entirely.

Hellinger distance also permits a bounded 1 − D score. KL divergence and cross entropy are unbounded, so 1 − D is not generally meaningful for them. Ideal-output comparisons also require an ideal distribution that may be expensive to compute.

Randomized benchmarking & hardware comparisons

Apply random Clifford gates, then their combined inverse. Ideally the initial state returns. Fit survival versus length m:

P(m) = Aαm + B r = (d − 1)(1 − α)/d

d = 2ⁿ for n benchmarked qubits; r is average error per Clifford under the RB assumptions. A and B absorb preparation/readout effects. It is not a direct error rate for every native gate.

Compare native gate sets, two-qubit costs, T₁/T₂, readout/reset error, connectivity, and calibration time. “Fidelity ≈ 1 − error” needs a specified metric and experiment.