---
title: "Interactive Quantum Computing Demos in Your Browser"
description: "Play eight browser demos on qubits, gates, interference, entanglement, teleportation, error correction, quantum keys, and the ciphers that quantum replaces."
url: https://tadams.net/quantum
---

# Quantum demos

Eight small demos about how qubits work and what they mean for secret messages. Each part of the first seven takes a few minutes. Intercepts, the last, is a code-breaking game that takes longer.

New to qubits: read the short guide below, Quantum basics, then start with [Bloch sphere golf](https://tadams.net/quantum/bloch-golf).

## The demos

- [Bloch sphere golf](https://tadams.net/quantum/bloch-golf): A qubit is drawn as an arrow in a ball, called the Bloch sphere. Turn the arrow to a target point in as few gates as possible. You learn how one qubit works, how gates turn it, and how it can change in a way that a measurement cannot see.
- [Circuit puzzle](https://tadams.net/quantum/circuit): Put gates on two or three qubits until what they give matches the target. The puzzles build up superposition, interference, and entanglement, and end with a hidden box whose kind a quantum circuit can tell with one use.
- [The bomb tester](https://tadams.net/quantum/bomb-tester): Some boxes hold a bomb so sensitive that one photon, a single particle of light, sets it off. Find the live bombs without setting them off. It shows how a path that a photon did not take still changes the result, and how many small steps make the test almost perfectly safe.
- [Entanglement games](https://tadams.net/quantum/chsh): Players who cannot talk try to win a game. Entangled qubits, one for each player, let them win more rounds than any plan made ahead of time. The CHSH game shows why no plan made ahead of time can match entanglement, and why the link carries no message. The three-player GHZ game never loses a round.
- [Teleportation](https://tadams.net/quantum/teleportation): Move a hidden qubit state to Bob with a linked pair and two ordinary bits, and nobody reads it on the way. It shows why this breaks neither the speed of light nor the rule against copies, and what a real, imperfect pair can still do. Superdense coding does the reverse: two bits on one qubit.
- [Eavesdropper](https://tadams.net/quantum/eavesdropper): Play Eve, a spy, and try to read a secret key sent on single particles of light without Alice and Bob finding errors. You see how the BB84 method sends a key, why tapping a quantum line leaves marks, how an attack on the hardware leaves none, and how linked pairs let a key test itself.
- [Keep it alive](https://tadams.net/quantum/error-correction): Noise flips qubits at random, and you cannot look at them. Keep a message alive with nothing but two lights that show whether the qubits match. It shows how to repair a message you cannot read, when the repair stops helping, and why real machines need so many qubits.
- [Intercepts](https://tadams.net/quantum/intercepts): Break 19 coded messages that Eve, a spy, recorded: from ciphers that a pencil can break to new locks that no known quantum method breaks. Part 1 covers the classical ciphers. Part 2 covers the one-time pad, quantum keys, what a quantum computer does to the locks in use today, and the new locks built to resist it.

A short guide

## Quantum basics

### Bits and qubits

A bit is 0 or 1. A qubit also has two basic states, written |0⟩ and |1⟩. The bar and the angle bracket only mark a qubit state, so |0⟩ reads as "the state 0". A qubit can also be in a mix of the two, called a superposition. Think of the qubit as an arrow in a ball, called the Bloch sphere: |0⟩ points up, |1⟩ points down, and every other direction is a superposition. [Bloch sphere golf](https://tadams.net/quantum/bloch-golf) lets you move this arrow.

With two qubits, one label holds both: |01⟩ means the first qubit is 0 and the second is 1.

A qubit state is α|0⟩ + β|1⟩, where the amplitudes α and β are complex numbers with |α|² + |β|² = 1. Up to a global phase, each state is one point on the Bloch sphere. [Bloch sphere golf](https://tadams.net/quantum/bloch-golf) shows that point as you apply gates.

### Measurement

When you measure a qubit, you get 0 or 1, never a mix. The direction of the arrow sets the chance of each result. After the measurement, the qubit stays at the result you got. So one measurement cannot show you the whole arrow. The Measure button in [Bloch sphere golf](https://tadams.net/quantum/bloch-golf) lets you see this.

A measurement asks the arrow one question: up or down? You can also turn the qubit first and so ask along a different line through the ball, such as left or right. Ask the same way twice and you get the same answer. Ask along a line at right angles to the arrow, and the result is a fair coin flip. A line in between gives an uneven coin. Either way, the arrow moves to match the result.

A measurement in the 0 and 1 basis gives 0 with probability |α|² and 1 with probability |β|². This is the Born rule. The state is then |0⟩ or |1⟩, to match the result.

### Phase and interference

Two arrows can give the same chances and still point different ways around the middle of the ball. That difference is the phase. A measurement cannot see the phase, but a later gate can turn it into a difference in the chances. Parts of a state add up or cancel out, the way waves do. This is interference. Quantum algorithms use it to make right answers more likely and wrong answers less likely. The Hidden sign puzzle in the [circuit puzzle](https://tadams.net/quantum/circuit) is about a phase you cannot see in the chances. The [bomb tester](https://tadams.net/quantum/bomb-tester) uses interference to find a bomb without setting it off.

|+⟩ = (|0⟩ + |1⟩) / √2 and |−⟩ = (|0⟩ − |1⟩) / √2 both give P(0) = ½. But H|+⟩ = |0⟩ and H|−⟩ = |1⟩: the relative phase decides the result. Amplitudes add as complex numbers, so they can cancel. The [circuit puzzle](https://tadams.net/quantum/circuit) shows each amplitude as a dial. The [bomb tester](https://tadams.net/quantum/bomb-tester) shows what a measurement does to that cancellation.

### Gates

A gate changes the state of one or more qubits. On one qubit, each gate turns the ball. H, the Hadamard gate, turns a sure 0 into a fair coin. X flips 0 and 1, and S and T spin the arrow around the middle. Each gate has a reverse gate that undoes it, so no gate loses information.

A gate is a unitary matrix U, so U†U = I and U† undoes U. Every one-qubit gate is a rotation of the Bloch sphere, up to a global phase. H and T together approximate any one-qubit gate, and with CNOT they make a universal set.

### Entanglement

Two qubits can be linked, or entangled, so that their results are tied together even when the qubits are far apart. In a Bell pair, the simplest linked pair, each qubit by itself is a fair coin. When both are measured along the same line, as in these demos, their results always match. The link does not carry a message: each side sees only coin flips until the two sides compare their results. In [the CHSH game](https://tadams.net/quantum/chsh), linked qubits win more rounds than any plan made ahead of time. The same page has a three-player game that linked qubits win every time. [Teleportation](https://tadams.net/quantum/teleportation) uses a link to move a qubit’s state, and to send two bits on one qubit.

The Bell state (|00⟩ + |11⟩) / √2 is not a product of two one-qubit states. Its correlations break the CHSH inequality: the best quantum strategy wins cos²(π/8) ≈ 85.4% of rounds, and the best classical strategy wins 75%. By the no-signaling theorem, each side's results do not depend on the other side's choice of angle. [The CHSH game](https://tadams.net/quantum/chsh) lets you set the angles. That page also has the GHZ game, which a three-qubit state wins with certainty against a classical 75%. [Teleportation](https://tadams.net/quantum/teleportation) and superdense coding show what an ebit buys when classical bits or a qubit also travel.

### No copies

Nobody can make a copy of an unknown qubit, and reading a qubit along the wrong line changes it. Quantum key distribution uses this. A spy who reads the qubits on their way leaves errors, and the two sides find those errors when they compare a few bits. [Eavesdropper](https://tadams.net/quantum/eavesdropper) lets you play the spy, and then attack a real laser that sends some photons in pairs. Last, it builds a key from linked pairs, which catch a spy with the CHSH game.

The no-cloning theorem: no unitary takes |ψ⟩|0⟩ to |ψ⟩|ψ⟩ for every |ψ⟩. In BB84, a spy who measures a fraction f of the qubits in random bases causes an error rate of f/4 in the kept bits. [Eavesdropper](https://tadams.net/quantum/eavesdropper) runs 1,000 rounds to show it, then adds photon-number splitting and decoy states, and Ekert’s protocol, where a CHSH test on Bell pairs exposes the spy.

### Noise and error correction

Qubits are fragile, and noise changes them at random. You cannot fix this with copies, and you cannot read a qubit to check it. Instead, one message is spread over many qubits, and checks ask only whether qubits match. [Keep it alive](https://tadams.net/quantum/error-correction) lets you repair a message that you cannot see.

A code stores one logical qubit in many physical qubits. Its stabilizer measurements locate errors and reveal nothing about the logical state. The code helps only below a threshold error rate. [Keep it alive](https://tadams.net/quantum/error-correction) runs the three-qubit repetition code, then the surface code that real machines use.

## How the simulation works

The demos follow their qubits with exact math, one gate at a time, in your browser. When a demo measures, it picks each result with the chance that the math gives. One part of Keep it alive runs the surface code, a large grid of qubits that real machines use to fix errors. It has too many qubits for this exact math, so it follows only the errors.

A state on n qubits is a vector of 2n complex amplitudes, one for each basis state. A gate is a unitary matrix that acts on that vector. A measurement gives one basis state, with a probability equal to the squared magnitude of its amplitude (the Born rule).

The golf, circuit, bomb tester, teleportation, error correction, and CHSH demos apply each gate to the full state vector in plain JavaScript, with no external library, and sample measurements from the exact probabilities. Eavesdropper uses only the four BB84 states, so it applies the measurement rule for those states directly. Its photon-number splitting part samples photon counts from a Poisson distribution, and its Ekert part runs each pair as a two-qubit state vector. The surface code part of Keep it alive has too many qubits for a state vector, so it follows Pauli errors through the circuit. Part 2 of Intercepts runs its Grover search as a state vector, and samples its period finder from the exact distribution.

Use the switch at the bottom of the screen to read each page simply or with the math.
