Free course · 8 lessons · no signup

Quantum computing,
one visual at a time.

Every simulation on this page is real. A state-vector simulator runs in your browser and the pictures are drawn from its actual amplitudes. Drag the spheres. Break things. The fastest way to understand a qubit is to push one around.

Lesson 1

The linear algebra you actually need

Quantum mechanics has a reputation. The mathematics used on this site does not deserve one: it is a column of two numbers, and matrices that shuffle those numbers around. If you can multiply a 2×2 matrix by a 2-vector, nothing in the seven lessons that follow is out of reach.

There are four ideas, and that is the whole toolkit. A state is a vector. A gate is a matrix. A probability is a squared magnitude. Two qubits combine with a tensor product.

1. A state is a column of numbers

Write the two definite answers as vectors: |0⟩ is the column (1, 0) and |1⟩ is the column (0, 1). Every other state is a mixture of the two, |ψ⟩ = a|0⟩ + b|1⟩, which is just the column (a, b). Those two numbers are the amplitudes, and they are complex, which turns out to be the entire source of the interesting behaviour.

One rule constrains them: |a|² + |b|² = 1, so the vector has length 1. That is not yet the sphere you will drag around in Lesson 2: two complex numbers are four real ones, and one constraint leaves three. The last step is that multiplying both amplitudes by the same phase, a global phase, changes nothing you could ever measure. Treat states that differ only by a global phase as the same state and two parameters remain, which is exactly a point on the surface of a sphere.

|0⟩ = [ 1 ] |1⟩ = [ 0 ] |ψ⟩ = [ a ] [ 0 ] [ 1 ] [ b ] the one rule: |a|² + |b|² = 1 every state has length 1 global phase: e^{iγ}(a, b) ≡ (a, b) unobservable, so drop it bra-ket notation, decoded |ψ⟩ a column of numbers, the "ket" ⟨ψ| the same numbers as a row, conjugated, the "bra" ⟨φ|ψ⟩ a dot product: how much two states overlap

2. A gate is a matrix

A quantum gate does one thing to your state: it multiplies the column by a matrix. The Hadamard gate, which you will meet properly next lesson, is nothing more mysterious than the matrix below, and applying it is ordinary row-times-column arithmetic.

Every legal gate matrix is unitary, which means it preserves the length of the vector. Two consequences follow immediately and both matter. Probabilities always still sum to 1, because the length never changes. And every gate is reversible, because a unitary matrix always has an inverse. There is no quantum gate that erases information, which is why quantum circuits can be run backwards and why so much effort goes into uncomputing scratch work.

Interactive · matrix times vector applied: (nothing yet)
the same two numbers, drawn as an arrow
Multiply the vector by
Press X twice, or H twice, and you land exactly back where you started. That is reversibility, visible: the matrix undoes itself. Press S four times for the same effect by a longer route, and watch the arrow walk around the equator rather than jump.

3. Probability is the square of the magnitude

The amplitudes are not probabilities. To get a probability you square the magnitude: you see 0 with probability |a|² and 1 with probability |b|². This step is where the interesting information goes to die. Squaring throws away sign, and more generally throws away phase, so states that are genuinely different can be indistinguishable to a measurement. Lesson 4 is entirely about that gap, and Lesson 5 is about exploiting it.

4. Two qubits multiply, they do not stack

Put two qubits side by side and you do not get four numbers by writing two lists next to each other. You get the tensor product: every amplitude of the first qubit multiplied by every amplitude of the second. Two numbers and two numbers make four.

Interactive · the tensor product
the four combined amplitudes
Three qubits give eight amplitudes, ten give a thousand, fifty give a quadrillion. At about 300 qubits the list of numbers you would need to write down is longer than the count of atoms in the observable universe. That doubling is the whole reason simulating quantum systems on a classical computer becomes hopeless, and the reason the simulator behind this page stops at a handful of qubits.

What you can safely skip: determinants, Gram-Schmidt, matrix decompositions, and most of a first linear algebra course. Eigenvectors are worth knowing eventually, since a measurement basis is a set of them, but you can get through every lesson here without that. Vectors, matrix multiplication, complex numbers and the tensor product are enough.

Common mistake: treating the amplitudes as probabilities that happen to be written oddly. They are not. Probabilities are non-negative and simply add up. Amplitudes can be negative or complex, and two of them can add to zero. Everything a quantum computer does that a classical one cannot comes out of that single difference.

Lesson 2

The qubit is an arrow, not a coin

A classical bit is 0 or 1. A qubit's state is a point on the surface of a sphere, the Bloch sphere. The north pole is |0⟩, the south pole is |1⟩, and every other point is a valid state that is neither.

Two angles fix that point. θ tilts the arrow away from the north pole and controls how much |0⟩ versus |1⟩ you have. φ spins it around the vertical axis, and that is the phase, which Lesson 4 is entirely about.

In terms of the column (a, b) from Lesson 1, the state is a = cos(θ/2), b = eiφ sin(θ/2). Note the half angle: the south pole is θ = 180°, but that is only 90° of rotation in the amplitudes, which is what takes cos to 0. Opposite points on the sphere are orthogonal states, not negatives of each other.

Interactive · drag the sphere to rotate
drag to look around
Notice that the arrow always has length 1. It can point anywhere on the surface, but it can never be shorter, at least for a single isolated qubit. Lesson 6 shows the one thing that shrinks it.

Common mistake: "A qubit is 0 and 1 at the same time." Closer: a qubit has an amplitude for 0 and an amplitude for 1, and those amplitudes are complex numbers that can cancel each other out. Nothing about a coin does that.

Lesson 3

Superposition, and the Hadamard gate

The Hadamard gate (H) is the workhorse of quantum computing. Applied to |0⟩ it produces |+⟩, an equal superposition where measuring gives 0 half the time and 1 half the time.

But look at what happens when you apply H twice. If H just randomised the qubit, two H's would leave you randomised. Instead you get |0⟩ back, every single time. Randomness does not undo itself; superposition does.

Interactive · one qubit circuit: (empty)
measurement probabilities
Apply a gate
Measure repeatedly
Try: H then H. Then try H, measure ×1000, and watch it land near 50/50. Then H Z H, and see Lesson 5.

The key point: superposition is not "the computer secretly picked one". The two branches are both present and can interfere with each other later. That is the entire resource quantum computing runs on.

Lesson 4

Phase: the half you cannot measure

Amplitudes are complex numbers. Each has a magnitude (which sets the probability) and an angle, which is the phase. Measurement throws the phase away completely, which is why it feels like it should not matter.

Drag the phase slider below. The probability bars do not move. At all. The Bloch arrow meanwhile is spinning around the equator, so the state is genuinely changing. You just cannot see it in a measurement.

Interactive · phase has no effect on probability
the state is moving
the probabilities are not
Bar colour encodes phase, so you can see the amplitude changing even while its height stays fixed. This is the one thing a classical probability distribution cannot do.

Hold this thought: phase is invisible to measurement but not invisible to later gates. Lesson 5 converts phase into something you can actually see.

Lesson 5

Interference is where the speedup comes from

Here is the circuit that makes phase real: H → phase(φ) → H. The first H splits into two paths. The phase gate shifts one path relative to the other. The second H brings them back together, and where the phases are opposed, the amplitudes cancel.

Sweep φ below. At 0° you get |0⟩ with certainty. At 180° you get |1⟩ with certainty. Same circuit, same starting state, opposite outcome, all from a parameter that was invisible one lesson ago.

Interactive · H → phase(φ) → H
outcome probabilities
P(measure 0)100%
P(measure 1)0%
Every quantum algorithm with a real speedup is doing a version of this: arranging for the wrong answers to cancel and the right answer to survive.

Common mistake: "Quantum computers try every answer in parallel." They do explore many branches, but you only get one measurement, and a random branch is useless. The work is in the interference pattern that makes the useful branch likely.

Lesson 6

Entanglement: the arrows disappear

Two qubits. Apply H to the first, then a CNOT (flip the second if the first is 1). The result is a Bell pair: 50% |00⟩, 50% |11⟩, and nothing else.

Now watch the Bloch spheres as you build it. They shrink to nothing. That is not a rendering bug. It is the definition of entanglement. Neither qubit has a state of its own any more. All the information lives in the correlation between them.

Interactive · two qubits circuit: (empty)
qubit 0
qubit 1
entanglement between the two qubitsnone
Build the Bell pair
joint probabilities
Measure both qubits
After building the Bell pair, run 200 shots. You will see |00⟩ and |11⟩ only, never |01⟩ or |10⟩. The two qubits always agree, even though each one alone is completely random.

Why the sphere shrinks: the arrow's length measures how much of a definite state a qubit has on its own. For a Bell pair it is exactly zero. Maximum entanglement means maximum local ignorance.

Lesson 7

Measurement is destructive, and that is the whole problem

Measuring collapses the state. In the standard interpretation, that means not "reveals what it secretly was" but collapses: before measurement the qubit had no definite value; after measurement it is pinned, and the superposition is gone for good. (For a single qubit this cannot be proven experimentally. The theorems that rule out hidden values, Bell and Kochen–Specker, need entanglement or larger systems.)

Set up a superposition below and measure it. Then measure again. And again. The first measurement is random; every one after that in the same basis returns the same answer, because there is nothing left to be random about. Measure in a different basis in between, say X after Z, and the next Z measurement is a fresh 50/50.

Interactive · collapse
superposition intact
This is why quantum algorithms cannot simply "read the answer out of the superposition". You get one shot, and you must have arranged beforehand for it to be worth taking.

On Schrödinger's cat: the thought experiment was an objection. Schrödinger was arguing the interpretation must be wrong because a half-dead cat is absurd. It has since been widely repurposed as an explanation of the very thing it was written to criticise.

Lesson 8

Putting it together: Grover's search

Eight boxes, one prize. Classically you open boxes until you find it, 4.5 tries on average, (N+1)/2, and seven in the worst case, since if the first seven are empty you know the prize is in the last box without opening it. Grover's algorithm finds it in two iterations, ⌊(π/4)√8⌋ of them, and the mechanism is exactly what the last seven lessons built up.

Start with an equal superposition over all eight (Lesson 3). The oracle flips the phase of the marked item, invisible to measurement (Lesson 4). Then diffusion reflects every amplitude about their mean, converting that phase difference into a height difference (Lesson 5). Repeat.

Interactive · Grover on 3 qubits step 0 · initialise
amplitude of each of the 8 items · colour shows phase
probability of finding the marked item12.5%
Marked item
Run the algorithm
Run "full iteration" twice: the marked item goes 12.5% → 78% → 94.5%. Now run it a third time and watch it crash back to 33%. Grover overshoots: the amplitude rotates past the target and keeps going, so knowing when to stop is part of the algorithm, not an afterthought.

The honest caveat: this is a quadratic speedup, √N instead of N. Real and provable, but not the exponential kind. Once error-correction overhead is included, the crossover point where this beats a classical search is a long way off.

Where to go next

You now have the core concepts: superposition, phase, interference, entanglement, measurement, and how an algorithm chains them. Go break something in the playground, or read how these ideas map onto real industrial problems in the algorithms section.