Skip to content
TheQuantaSpace
← Research
Quantum1 min read

Qubits for software engineers

Skip the mysticism. A qubit is a vector, a gate is a matrix, and measurement is a weighted coin flip. Here's the mental model, with enough linear algebra to run it yourself.

A classical bit is 0 or 1. A qubit is a unit vector in a two-dimensional complex space:

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

α and β are amplitudes. When you measure, you get 0 with probability |α|² and 1 with probability |β|², and the state collapses to whichever you observed.

Gates are matrices

Operations on qubits are unitary matrices. The Hadamard gate takes a definite |0⟩ into an equal superposition:

const H = [
  [1 / Math.SQRT2, 1 / Math.SQRT2],
  [1 / Math.SQRT2, -1 / Math.SQRT2],
];
const zero = [1, 0];
const plus = H.map((row) => row[0] * zero[0] + row[1] * zero[1]); // [0.707, 0.707]

Measure plus and you get a fair coin. Apply H again before measuring, though, and the amplitudes interfere: the |1⟩ contributions cancel and you get 0 every time. Interference, not “trying every answer at once”, is where quantum speedups come from.

Why it’s hard to scale

Simulating n qubits classically needs 2ⁿ amplitudes, which is why quantum hardware is interesting. But real qubits are fragile: noise leaks information into the environment (decoherence), and today’s machines need error correction, which uses many physical qubits per reliable logical qubit.

The takeaway for engineers: learn the linear algebra, play with a simulator, and be skeptical of any claim that doesn’t mention error rates.

  • #quantum-computing
  • #fundamentals