How a Computer Works

Part two · a different kind of switch

A quantum computer is not a faster computer.

It is a different machine built on a different kind of bit. For almost everything you do — mail, games, spreadsheets — it would be slower, costlier and worse. For a handful of problems it is so much better that no classical machine will ever catch up. This page is about that difference, and about why it is so hard to use.

Same deal as part one: everything is live, and the simulator underneath is exact.

Bit Qubit
State 0 or 1 Two amplitudes, one for 0 and one for 1 — any point on a sphere
Reading it Tells you the state and changes nothing Gives 0 or 1 at random — and the rest of the state is gone
Copying Free Impossible: nothing can copy an unknown qubit
n of them Hold one of 2n values Hold 2n amplitudes at once — yet hand back only n bits when read
Errors Almost never Constantly — the outside world leaks in

The one-line version: a quantum computer does not try every answer at once and pick the right one. It sets up waves of possibility and arranges for the wrong answers to cancel out.

01 The atom, again

A bit that can point anywhere

A classical bit is a switch: up or down. A qubit is described by two numbers called amplitudes — one for 0, one for 1 — and those numbers can be negative, or even complex. The tidy way to picture that is a sphere: 0 at the north pole, 1 at the south, and every other point a superposition of the two.

One qubit — apply gates, drag the sphere to look around

Every operation you can do to a single qubit is a rotation of that sphere — watch the arrow sweep as each gate turns it. That is what a quantum gate is. Not a lump of wiring the data flows through, as in part one, but a precisely timed nudge — a pulse of microwaves or a flash of laser light — aimed at a qubit that sits still.

Latitude and longitude

How far the arrow tips toward the south pole sets the odds of reading 1. How far it has turned around the vertical axis — the phase — has no effect on those odds at all. Z, S and T only ever turn the phase, so they never change the odds — applied straight to |0⟩ they appear to do nothing at all. The phase is invisible to a measurement, and it is the most important number on this page: section 3 is about why.

02 Looking

Reading a qubit destroys it

You never get to see the arrow. A measurement asks one question — 0 or 1? — and the qubit answers at random, with odds set by its latitude. Then it stays where it landed: the superposition is gone, and measuring again only repeats the answer.

Prepare a qubit, then look at it

The only way to learn the odds is to prepare the same state again and again and count — which is exactly what real machines do. A quantum program is typically run thousands of times, and the answer is read off the histogram. Notice that the estimate is never exact: that sampling error is part of every quantum result.

03 The actual trick

Arrows that cancel

Here is the experiment that separates quantum from merely random. Flip a fair coin twice and the result is random; flipping it again cannot make it less so. Apply the qubit version — the Hadamard gate, H — twice, and the result is certain: back to 0, every time.

The reason is that amplitudes are not probabilities. Every route to an outcome contributes an arrow, and the arrows for the same outcome add up tip to tail — so arrows pointing opposite ways cancel. Probabilities can only ever pile up. Turn the phase between the two gates and watch the answer swing from certainly 0 to certainly 1.

Two coin flips versus two Hadamards

That is the entire engine. Every quantum algorithm is a choreography of phases, arranged so that the arrows for wrong answers cancel and the arrows for the right answer line up. It is not trying every possibility and keeping the best — a measurement would just hand back one at random. It is making the right one likely.

04 Two at once

Two qubits, one state

Two qubits have four amplitudes, one each for 00, 01, 10 and 11. Usually that is just two separate qubits side by side. But apply H to the first and then a controlled-NOT — flip the second only where the first is 1 — and you get a state that cannot be split into two parts at all: an entangled pair.

Make a Bell pair — click the gates to switch them on and off

Measure either qubit and you get a fair coin toss. Measure both and they always agree. Neither qubit has a direction of its own — its arrow shrinks to nothing — because all the information lives in the relationship between them. (It still cannot carry a message: each side, on its own, only ever sees a fair coin.)

Here is why that matters. Every qubit you add doubles the number of amplitudes the machine is juggling at once, and a classical computer trying to keep up has to store every one of them.

The cost of pretending to be a quantum computer

The catch that keeps it honest

Those amplitudes are real, but you cannot read them. Measure n qubits and you get n bits back; the rest is gone. The power is not storage — it is that one operation shifts every amplitude at once, and interference can steer all of them together. The art is arranging for a useful answer to survive the measurement.

05 Programs

A circuit you can build

A quantum program is written as a circuit: one wire per qubit, time running left to right, gates placed along the wires. A dot joined to a gate means controlled — the gate only acts where the dot's qubit is 1. Click any slot to change it, and step through to watch the state change.

Run the GHZ state with the noise turned up, and the clean 000 / 111 split starts sprouting outcomes that should be impossible. Then load the teleportation example and watch the bottom qubit's sphere: by the last step it points exactly where the top one pointed after step 2. In a real lab the last two steps are replaced by measuring the top two qubits and sending two ordinary bits down a wire; the simulator uses the equivalent controlled gates instead.

07 The hard part

Why you don't have one

A qubit must be isolated well enough that the world does not jostle it, yet reachable enough to rotate on command. Those demands pull in opposite directions, and every way of building one is a different compromise.

Superconducting circuits

0 and 1: two energy levels of a tiny loop of superconducting metal on a chip.

Flipped by: microwave pulses lasting tens of nanoseconds — the fastest gates of any platform.

The catch: they only work at around 0.01 kelvin — hundreds of times colder than deep space — and hold their state for a millisecond at best.

Trapped ions

0 and 1: two energy levels of a single charged atom, held in vacuum by electric fields.

Flipped by: laser or microwave pulses.

The catch: exquisitely accurate and long-lived — seconds or more — but gates are about a thousand times slower, and long chains of ions are hard to scale.

Neutral atoms

0 and 1: energy levels of uncharged atoms, each held in its own beam of focused laser light.

Flipped by: lasers; neighbours are entangled by briefly puffing atoms up into enormous "Rydberg" states.

The catch: arrays of thousands of atoms have been built, but atoms get lost and operations are slower than on chips.

Photons

0 and 1: which path, or which polarisation, a single particle of light takes.

Flipped by: ordinary optics — beam splitters and phase shifters.

The catch: light barely interacts with light, so two-qubit operations are hard and probabilistic, and every photon lost is an error.

None of them is anywhere near error-free. Even the best two-qubit gates fail somewhere around one time in a thousand — better on a few machines, worse on most — while a useful algorithm needs billions of operations.

How long a circuit survives its own errors

The way out is error correction: spread one reliable logical qubit across many physical ones, and keep checking them in small groups for disagreement — without ever measuring the data itself, which would destroy it. The leading scheme, the surface code, lays qubits out as a grid.

A surface code patch — click a data qubit to give it an error

The price is steep. At today's error rates, one dependable logical qubit is expected to need hundreds to a thousand physical ones, and recent estimates for breaking today's RSA encryption come to under a million physical qubits running for about a week. The largest machines so far hold hundreds to a few thousand.

The milestone that matters

Error correction only helps if the physical qubits are already good enough — below a threshold. Above it, adding qubits adds more errors than it removes. Experiments in the last few years have shown logical qubits getting more reliable as they were made bigger, which is the first real evidence that the whole plan can work.

08 What it's for

A co-processor for a few hard problems

A quantum computer will not replace the one you are reading this on. It is a specialist, like a graphics card, that a classical computer hands a narrow class of problems.

natural fit

Simulating molecules and materials

Nature is quantum, so simulating it classically runs into the same exponential wall as section 4. A quantum computer sidesteps that by being the same kind of system — the reason the idea was proposed in the first place. Catalysts, batteries and drugs are the targets; useful sizes still need error-corrected machines.

real, and a threat

Breaking today's public-key encryption

Shor's algorithm factors large numbers exponentially faster than any known classical method, which breaks RSA and elliptic-curve cryptography. No machine can run it at that scale yet, but data recorded today could be decrypted later — so the switch to quantum-resistant encryption is already under way, with the first standards published in 2024.

modest

Search

Grover's square-root speed-up is real and proven, but after error-correction overheads it rarely beats a well-built classical computer on a practical problem.

unproven

Optimisation and machine learning

Heavily promoted, actively researched, and so far without a clear demonstration of beating the best classical methods on a problem anyone needed solved.

no

Everything else

Web pages, video, games, spreadsheets, databases: no speed-up at all. Reading data in and out is slow, and a quantum computer would be a spectacularly expensive way to add up a column.

Every quantum computer is run by a classical one: racks of ordinary processors timing the pulses, reading out results and decoding errors as fast as they arrive. The tower from part one is still standing. It has just grown a very strange new floor at the bottom.

Back to part one How a classical computer works From one switch to a running program, with an 8-bit CPU you can step through.