What is a qubit, and what can you do with one?

Twenty minutes, no prior knowledge: one qubit, three gates, one measurement, a two-qubit circuit worked by hand, and a lab where you run it yourself.

You'll be able to say what a qubit, a gate and a measurement are, and build and run a two-qubit entangling circuit.

The lesson in four lines

A qubit is a two-state system that can also be put in a combination of its two states. A gate turns that combination in a controlled, reversible way. A measurement forces a single answer, 0 or 1, with odds set by the combination. Send two qubits through a Hadamard gate and a CNOT gate and you get the smallest example of entanglement: two fair coins that always agree.

How long it takes: the Plain depth about 8 minutes, Working about 6 more, Formal about 6 more, and the lab about 4. Plain, Working, the lab and the three check questions come to about 20 minutes; Formal is for readers who want the mathematics. Stop after any depth: each is complete without the next. Reading time is counted at 200 words a minute for prose and 120 for the equation-heavy depths. This is the first lesson of the Quantum × AI track, so nothing before it is assumed.

Plain

A qubit: a switch that can also point in between

A bit is a switch that is either 0 or 1. A qubit is any physical thing with two distinguishable states that we agree to call 0 and 1: the spin of an electron, the polarisation of a photon, the two lowest energy levels of a superconducting circuit. (What the hardware really is gets its own lesson, What is a qubit made of?) What makes it a qubit and not just a bit is that it can also be in a combination of the two.

The picture that works best is an arrow drawn from the centre of a sphere. Arrow straight up means 0. Straight down means 1. Any other direction is a combination, and how high the arrow points says how much of each.

Superposition: a combination with amounts

A combination of 0 and 1 is called a superposition. It is not “0 or 1, we just don’t know which”, and it is not “0 and 1 stored at once, so both answers come free”. It is a third thing: a state described by two amounts, one for 0 and one for 1. The amounts are called amplitudes. They can be negative, and that is the whole point: amounts can cancel each other, like two waves meeting, which a plain “we don’t know which” can never do. Nearly everything a quantum computer is good for comes from arranging that the wrong answers cancel and the right one adds up.

The arrow on the sphere: the Bloch sphere

Every state of one qubit is a point on the surface of a sphere, the Bloch sphere, named after Felix Bloch, whose 1946 equations for a spin in a magnetic field it follows. North pole: 0. South pole: 1. Anywhere on the equator: an equal mix of 0 and 1, and the position around the equator, an angle, is called the phase. You cannot see phase by asking “0 or 1?” right away, yet it decides what the next gate does. The arrow is a picture of the state, not an arrow in space.

Measurement: you get one answer

Measuring a qubit asks “0 or 1?” and you get exactly one of them. The odds come from the arrow: straight up always gives 0, straight down always gives 1, and on the equator it is a fair coin. In general the chance of reading 0 is (1 + z)/2, where z is the height of the arrow, from −1 at the south pole to +1 at the north pole. Afterwards the qubit is in the state you found, so asking again gives the same answer: the combination has been used up. That is the first reason quantum computing is not “trying every answer at once”. You only ever read out one.

Gates: turning the arrow

A gate is a controlled turn of the arrow. Three to know:

Every gate is reversible, so a circuit throws nothing away until you measure.

The trick: H, Z, H. Start at 0. H lifts the arrow to the equator. Z swings it to the other side of the equator. H brings it down again, and it lands on 1. Z changed nothing you could have read, yet it changed the final answer. That is interference: the two routes to “0” cancel and the two routes to “1” add. You can build it in the lab.

Two qubits. The CNOT gate takes a control qubit and a target qubit. If the control is 1 it flips the target; if the control is 0 it does nothing. On plain 0s and 1s it is an ordinary logic gate. On combinations it does something no ordinary gate does, as the next section shows.

One worked circuit: H, then CNOT

Start with two qubits, both 0, written 00. Apply H to the first. It becomes an even combination of 0 and 1, so the pair is an even combination of 00 and 10. Now apply CNOT with the first qubit as control. The 00 part stays 00. The 10 part has a 1 in the control, so the second qubit flips and it becomes 11. The pair is now an even combination of 00 and 11, written (|00⟩ + |11⟩)/√2, with amplitude 1/√2 on each.

Measure both. You get 00 half the time and 11 half the time, and never 01 or 10. Look at either qubit alone and it is a fair coin, yet the two always agree. Neither qubit has an arrow of its own any more: only the pair has a state. The pair is entangled, and this one is called a Bell state. Nothing is being sent between the qubits: each observer sees only a fair coin, and learns that the other agreed only by comparing notes.

The First Lab

Two qubits, q0 and q1, start at 0. Build a circuit of up to eight gates, then measure. The bars show the exact odds; “measure” draws results from those odds with a random-number generator in your browser. Nothing is stored or sent. Watch the arrow lengths under the bars: when a CNOT entangles the pair, both arrows vanish.

Four goals

  1. Make q0 read 1 every time.
    Show a solution One gate is the shortest possible.
  2. Make q0 a fair coin: 0 half the time, 1 half the time.
    Show a solution One gate is the shortest possible.
  3. Make q0 read 1 every time using only H and Z, no X.
    Show a solution Three gates is the shortest possible.
  4. Make the two qubits always agree while each is a fair coin.
    Show a solution Two gates is the shortest possible.

“Shortest possible” is checked, not assumed: a script tries every circuit up to five gates over these eight gates and reports the shortest that works.

Check yourself · 1 of 3

A qubit is in an even combination of 0 and 1. You measure it, then measure it again straight away. What do you see?

The first measurement picks 0 or 1 with equal odds and leaves the qubit in the state it found. A second measurement of that state has no odds left to give, so it repeats the answer.

The tempting wrong answers.

  • “A chance result, then a fresh chance result.” Picking this treats each measurement as a new coin toss, forgetting that the first one used up the combination.
  • “Both values together, and then one of them.” Picking this believes the combination shows up in the readout; a readout is always exactly one value.
  • “The value it secretly held from the start, twice.” Picking this pictures a hidden value; amplitudes can cancel (the H, Z, H trick below), which a hidden 0 or 1 never could.
Working

Amplitudes, and the odds they give

Write a one-qubit state as |ψ⟩ = α|0⟩ + β|1⟩, where the amplitudes α and β are complex numbers with |α|² + |β|² = 1. The chance of reading 0 is |α|², and of reading 1 is |β|². The arrow is the same state in angles: choose θ, measured from the north pole, and φ, around the equator, and write α = cos(θ/2) and β = eiφ sin(θ/2). The arrow then points to (sin θ cos φ, sin θ sin φ, cos θ), and the chance of reading 0 is cos²(θ/2) = (1 + cos θ)/2 = (1 + z)/2, the rule from the Plain section.

StateAmplitudes (α, β)Arrow (x, y, z)
|0⟩(1, 0)(0, 0, 1)
|1⟩(0, 1)(0, 0, −1)
|+⟩ = (|0⟩ + |1⟩)/√2(1/√2, 1/√2)(1, 0, 0)
|−⟩ = (|0⟩ − |1⟩)/√2(1/√2, −1/√2)(−1, 0, 0)
|+i⟩ = (|0⟩ + i|1⟩)/√2(1/√2, i/√2)(0, 1, 0)
|−i⟩ = (|0⟩ − i|1⟩)/√2(1/√2, −i/√2)(0, −1, 0)

Only the relative phase between α and β can ever be observed. Multiplying both by the same eiγ changes no measurement, which is why the sphere needs two angles and not three.

Gates are matrices

A gate acts on the pair (α, β) as a matrix. The three from the Plain section are

Each is unitary: it keeps |α|² + |β|² = 1 and can be undone by running it backwards. Here X² = Z² = H² = I, and the three-gate trick is the identity HZH = X. Followed by hand: start with (1, 0). H gives (1/√2, 1/√2). Z flips the sign of the second: (1/√2, −1/√2). H again gives ((1/√2)(1/√2) + (1/√2)(−1/√2), (1/√2)(1/√2) − (1/√2)(−1/√2)) = (1/2 − 1/2, 1/2 + 1/2) = (0, 1). The two routes to 0 contribute +1/2 and −1/2 and cancel; the two routes to 1 contribute +1/2 each and add to 1.

Two qubits

Two qubits have four amplitudes: |ψ⟩ = a|00⟩ + b|01⟩ + c|10⟩ + d|11⟩, with the first qubit written first. Reading both gives 00 with chance |a|², 01 with |b|², 10 with |c|² and 11 with |d|². CNOT with the first qubit as control swaps the amplitudes of |10⟩ and |11⟩ and leaves |00⟩ and |01⟩ alone. The worked circuit is

|00⟩ → (H on the first) → (|00⟩ + |10⟩)/√2 → (CNOT) → (|00⟩ + |11⟩)/√2.

Product, or entangled? If each qubit had an arrow of its own, the pair would be a product (α|0⟩ + β|1⟩) ⊗ (γ|0⟩ + δ|1⟩) = αγ|00⟩ + αδ|01⟩ + βγ|10⟩ + βδ|11⟩, so a = αγ, b = αδ, c = βγ, d = βδ, and then ad = αβγδ = bc. A state with ad − bc ≠ 0 therefore cannot be a product. For the Bell state a = d = 1/√2 and b = c = 0, so ad − bc = 1/2 ≠ 0: entangled, with no arrow for either qubit.

Measuring one qubit of a pair

Read the first qubit of the Bell state. The chance of 0 is |a|² + |b|² = 1/2. If you read 0, only the terms with a 0 in the first place survive, and the state is renormalised to |00⟩, so the second qubit will now read 0 for certain. Read 1 instead and the state is |11⟩. That is why the two always agree, while neither alone is predictable.

Check yourself · 2 of 3 · a new case

A qubit has amplitudes 0.6 for 0 and 0.8 for 1. You measure it. What is the chance of reading 1?

The chance of reading 1 is |β|², here 0.8² = 0.64. As a check, the chance of reading 0 is 0.6² = 0.36, and 0.36 + 0.64 = 1, which is why the amplitudes of a qubit always satisfy |α|² + |β|² = 1.

The tempting wrong answers.

  • “80%: the amplitude 0.8, as it stands.” Picking this reads an amplitude as if it were a probability; the odds are the squares of the amplitudes.
  • “36%: the amplitude 0.6, squared.” Picking this squares the wrong amplitude, giving the chance of reading 0 instead.
  • “40%: whatever is left after 0.6.” Picking this subtracts from 1 without squaring; the two chances add to 1, not the two amplitudes.
Formal

Why the arrow lives on a sphere

A pure one-qubit state is a unit vector in ℂ², and a global phase is invisible, so states are points of the complex projective line ℂP¹, which is a sphere. In density-matrix terms, ρ = |ψ⟩⟨ψ| = (I + r·σ)/2, where σ = (X, Y, Z) are the Pauli matrices and r = (tr ρX, tr ρY, tr ρZ). The state is pure exactly when |r| = 1; mixed states fill the inside of the ball. The chance of reading 0 is tr(ρ|0⟩⟨0|) = (1 + rz)/2.

A gate U acts as ρ → UρU†, and for every single-qubit unitary the map r → Rr is a rotation R in SO(3). U and −U give the same rotation, so SU(2) covers SO(3) twice. X is a half-turn about the x axis and Z a half-turn about the z axis. H is a half-turn about the axis (x̂ + ẑ)/√2: it sends (x, y, z) to (z, −y, x), which swaps the north pole with the +x point and leaves the axis itself fixed. That is why H takes |0⟩ to |+⟩.

Entanglement as a shrinking arrow

Take a two-qubit pure state a|00⟩ + b|01⟩ + c|10⟩ + d|11⟩ and trace out one qubit. The other qubit’s arrow has length |r| with |r|² = 1 − C², where C = 2|ad − bc| is the concurrence (Wootters 1998). C = 0 is a product state, with an arrow of length 1. C = 1 is maximal entanglement: no arrow at all, and the qubit is in the maximally mixed state ρ = I/2. The Bell state has C = 1. The “arrow length” the lab prints under each qubit is exactly |r|, so the lab shows entanglement as an arrow that shrinks when a CNOT acts on a superposition.

Measurement, formally

A projective measurement in the Z basis has projectors P0 = |0⟩⟨0| and P1 = |1⟩⟨1|. Outcome k has probability ⟨ψ|Pk|ψ⟩, and the state afterwards is Pk|ψ⟩/√pk. Measuring the first qubit of two applies Pk ⊗ I. Because PkPk = Pk, a repeat gives the same outcome with probability 1. General measurements, and what happens when the environment does the measuring, are developed in The Machinery.

Everything on this page is recomputed by tools/verify_first_qubit.mjs: the lab’s simulator against a second, independent one on all 4,681 circuits of up to four gates, the matrix identities, the six arrows, the concurrence formula on 20,000 random states, and the shortest-circuit claims by exhaustive search.

Check yourself · 3 of 3 · a new case

You apply H to the first qubit, then CNOT with it as control, then X to the second qubit, and measure both. Which results appear?

After H and CNOT the pair is an even combination of 00 and 11. X on the second qubit flips its bit in each part: 00 becomes 01 and 11 becomes 10. The two readings still always differ, and each qubit alone is still a fair coin.

The tempting wrong answers.

  • “00 and 11, about half each, as in the plain Bell state.” Picking this ignores the X, as if a gate after the entangling step could not change what is read.
  • “All four results, about a quarter each.” Picking this thinks a gate on one qubit of an entangled pair scrambles the pair, when X only swaps 0 and 1 on that qubit.
  • “Only 01, because X sets the second qubit to 1.” Picking this takes X to set a bit rather than flip it, and forgets the first qubit is still a fair coin.

Go deeper

Why machines need error correction

Qubits are fragile, and an AI decoder is how the best machines keep them alive.

How AI fixes quantum computing’s errors →

Drive the Bloch sphere

Rotate a single qubit’s arrow with the gates and watch the numbers.

The Bloch widget →

The mathematics, topic by topic

Every claim proved or marked as not.

The Machinery →

Primary sources

Next in this trackHow does AI fix quantum errors?Prove itCircuit Golf: reach the target in the fewest gatesJudge a claimWho is actually ahead in the race?