UbQbit / Insights / Q-Day experiments
  1. 1The qubit
  2. 2Shor
  3. 3Grover
  4. 4Signatures
  5. 5Your deadline

A qubit you can hold

Turn a qubit with the same gates a quantum computer uses, then measure it a thousand times to see the odds. Everything after this builds on what you see here.

One qubit Exact simulation

The arrow is one qubit. Pointing up means 0, pointing down means 1. Press a gate to turn the arrow, then measure it to see which answer you get.

drag to rotate · or use the arrow keys

Press a gate

A gate is one step in a quantum program. Every gate turns the arrow; they differ in which way and how far. Press one and this line explains what it did.

If you measured now

Chance of 0100%
Chance of 10%
Show the maths

|ψ⟩ = 1.000|0⟩ + 0.000|1⟩

The computer stores a qubit as two numbers, one for 0 and one for 1. Square the size of each and you get its chance. When a number picks up an i, that’s the phase changing: the part of the arrow’s position a measurement can’t see.

Measure

  • Turn 0 into 1 using one gate.
  • Make a fair coin, with an equal chance of 0 and 1.
  • Start from 0 and apply H twice. Where does the qubit end up?
  • Make a fair coin, then measure 1,000 copies of it.

Back at 0. You’d expect two coin flips in a row to leave you at 50/50, but the second H undid the first. That cancelling is called interference, and every quantum algorithm relies on it.

What a qubit is

An ordinary computer stores everything as bits. A bit is a switch that’s either off or on, written 0 or 1. A qubit is the quantum computer’s version of a bit, and the easiest way to picture one is the arrow above. Pointing straight up is 0 and pointing straight down is 1, but unlike a switch, the arrow can point anywhere on the ball in between.

The catch is that you never get to see the arrow. When you read a qubit, which is called measuring it, you only ever get a 0 or a 1. Where the arrow points sets the odds. Near the top you’ll probably get 0, near the bottom you’ll probably get 1, and anywhere on the middle line it’s an even toss. An arrow that isn’t pointing straight up or down is what physicists call a superposition.

What a gate is

A quantum program is a list of steps, and each step is called a gate. The name is borrowed from the logic gates inside ordinary chips, like AND and NOT. On this ball, every gate does the same kind of thing: it turns the arrow. What makes one gate different from another is the line it turns the arrow around, and how far.

  • XFlips the arrow upside down, so 0 becomes 1 and 1 becomes 0. It’s the quantum version of NOT.
  • HNamed after the mathematician Jacques Hadamard. It lays an arrow that points at 0 or 1 down on the middle line, where both answers are equally likely, and it stands a lying-down arrow back up. Most quantum programs begin with an H on every qubit.
  • ZSpins the arrow half a turn around the up–down line. The odds stay exactly where they were. What changes is the phase, which is explained below.
  • YFlips the arrow like X and spins it like Z, in one move.
  • S, TSmaller spins around the up–down line: a quarter of a turn for S and an eighth for T. Along with H and one more gate that links two qubits together, these are enough to build any quantum program at all, including the one that breaks RSA.

What measuring does

Measuring is the only way to get anything out of a qubit, and it isn’t gentle. The arrow is forced to pick 0 or 1, it jumps to that end, and wherever it was pointing before is lost. Measure it again and you’ll get the same answer every time.

So a single measurement tells you very little about the odds. A quantum computer runs the same program many times and counts the results, which is what the 1,000-copies button does. It can’t simply copy the qubit and measure the copies, because the laws of physics don’t allow a qubit to be copied.

The part you can’t see

The arrow’s height sets the odds. Its position around the middle line is called its phase, and turning the arrow that way leaves the odds untouched, so no measurement can see it. Press Z on a fresh qubit and nothing seems to happen.

Phase still matters, because it changes what the next gate does. Press H twice and the arrow ends up back at 0. Press H, then Z, then H, and it lands on 1 instead. The only difference was a step you couldn’t have detected.

Why “both at once” is misleading

You’ll often hear that a qubit is 0 and 1 at the same time, so a quantum computer tries every answer at once. If that were true, you could read every answer out. You can’t. Measure a qubit and you get one bit, and everything else is gone. Make a fair coin, press “Measure it”, and watch the arrow snap to one end.

What a quantum computer really does is arrange its gates so that the routes to wrong answers cancel each other out and the routes to the right answer add up, the way the second H undid the first. That cancelling is called interference. Without it, a quantum computer would be an expensive way to make random numbers.

Why this worries cryptographers

One qubit is easy to imitate on an ordinary computer: this page does it with four numbers. Every qubit you add doubles that. Ten qubits take about 2,000 numbers, and 50 qubits take about two quadrillion, which is 18 petabytes of memory.

Real qubits are fragile, so a useful machine has to spread each one across many physical qubits and fix errors as they happen. Build one big enough and it can run Shor’s algorithm, which breaks RSA, one of the main kinds of encryption in use today. That’s the next experiment.