Skip to main content
← All Series

Quantum Computing from Scratch

Building a NumPy quantum simulator from a single qubit to Shor's algorithm, density matrices, noise, and error correction. Nothing asserted that the code cannot show.

13 parts

The Whole Machine Is an Array

This series builds quantum computing from nothing but NumPy: a qubit is a length-two complex array, a gate is a small matrix, and everything mysterious (superposition, entanglement, interference, measurement) is something you can watch happen inside the array rather than take on faith.

The arc runs in three movements. Posts 0 through 3 build the pure-state machinery and cash it in on Grover’s search. Posts 4 through 6 build the quantum Fourier transform, phase estimation, and Shor’s algorithm, the payoff of the pure-state picture. Posts 7 through 12 rebuild the engine to scale, then give up the pure-state picture itself: density matrices, noise and decoherence, error correction, the consolidated engine in full, and a closing essay on what the Born rule does and does not mean.

The Code

Every post executes its own code. The library behind the series, qfs, lives at queelius/quantum-from-scratch with a test suite that includes differential checks against Qiskit. The consolidated engine, reproduced verbatim in post 11, is about fifty lines.

Posts in this Series

Showing 13 of 13 posts
1 of 13

What is a qubit?

I wanted to understand quantum computing properly, which for me means building the thing rather than driving a framework that does the linear algebra in the basement and hands back an answer.