Level 2, Tinkerer

Circuit

The wire is read from the left, so H runs before Z, and the measurement is the last mark. The same order, a start then a short bench of gates then a reading, is the shape of each puzzle.

A quantum circuit is a diagram of wires, one wire for each qubit, with gates drawn on the wires in the order they are applied. You read the diagram from left to right, and a measurement is usually the last mark on a wire.

Keith’s circuits wander off the grid and have to be copied out again before anyone else can run them. Malcolm’s have a start, a short bench of gates and a reading, which is also the shape of each puzzle.

An example

Draw one wire that starts certain to read 0, so its amplitudes are 1 and 0. Put H on it, then Z, then a measurement.

H gives about 0.71 and 0.71. Z flips the sign of the second, giving 0.71 and −0.71. Each square is a half, so the measurement reads 0 or 1 with even chances. Run it 100 times and expect about 50 of each.

Now swap the two gates. Z goes first, on amplitudes of 1 and 0. Flipping the sign of a 0 changes nothing. H then gives 0.71 and 0.71, and the measurement again reads half and half. The counts match, but the two states differ by one sign.

A second H just before the measurement shows the sign. After H, Z, H the new amplitude for 0 is 0.71 + (−0.71) = 0. The new amplitude for 1 is 0.71 − (−0.71) = 1.42, which is 1 once you divide by 1.41. That circuit reads 1 every time. Z, H, H reads 0 every time, because two H gates in a row undo each other. The same three boxes give opposite answers.

Two qubits need two wires. A gate that acts on both, such as the controlled NOT, is drawn as a line that joins them.

What it is not

A quantum circuit is not an electrical circuit. No current runs along the wire, and the wire is not a path the qubit travels along. Each wire is a timeline for one qubit, and the boxes mark what happens to it and when.

It is also not run once to get the answer. One run ends in one bit per wire. To learn the chances you run the same circuit many times and count the bits. Each of those runs is called a shot.

Each box is a gate, and the last mark is usually a measurement. One run of the circuit is a shot, and the H, Z, H trick is interference at work. The note The left-hand gate runs first has two more circuits made of the same boxes, and every puzzle is a one-wire circuit to build.

Used in

Longer explanation: How does a quantum computer work?

All the words