Quantum Computing lessons
What is a qubit?
A simulated qubit: H gives it a 50/50 chance, then 200 measurements fill a histogram.
A normal computer stores everything as bits. Each bit is either 0 or 1.
A qubit is the quantum version. Until you read it, it holds two numbers called amplitudes, one for 0 and one for 1.
Reading a qubit is called measuring it. You always get a plain 0 or 1, with chances set by the amplitudes.
Amplitudes and chances
The two results a qubit can give are written \left|0\right\rangle and \left|1\right\rangle. These are called kets, and they just mean "the qubit is 0" and "the qubit is 1".
A qubit's state: \left|\psi\right\rangle = \alpha\left|0\right\rangle + \beta\left|1\right\rangle
The numbers \alpha and \beta are the amplitudes. Square an amplitude to get the chance of that result.
The two chances must add up to 1, so \alpha^2 + \beta^2 = 1. An amplitude can be negative, but its square never is.
Amplitude bars and their squares, which always fill exactly 100% between them.
Practice: Amplitude to chance
Type the chance of measuring 0 or 1 from a state written with its amplitudes.
Measuring collapses the state
Measuring a qubit gives one result, and the qubit then stays as that result. This is called collapse.
Measure it again and you get the same answer every time. The amplitudes you started with are gone.
So one measurement can never reveal the amplitudes. To see them, you prepare the same state many times and count the results.
A qubit is prepared, measured, then measured again: the first result is random, the repeats always match it.
Practice: Measure and predict
Questions on what measuring gives, once and again, and over many copies.
The Bloch sphere
The Bloch sphere pictures a qubit as an arrow from the centre of a ball. \left|0\right\rangle points straight up and \left|1\right\rangle points straight down.
The arrow's height sets the chances: the higher it points, the more likely a 0. Halfway down, on the equator, every state is 50/50.
Two equator states have names. In \left|+\right\rangle both amplitudes are \frac{1}{\sqrt{2}}, and in \left|-\right\rangle the second one is -\frac{1}{\sqrt{2}}.
The Bloch sphere tours from |0> to |1>; the height line and the chances update at each stop.
Practice: Sort by result
Sort kets and Bloch sphere pictures by what measuring them gives.
Quantum gates
A quantum gate changes a qubit's state by turning its arrow on the Bloch sphere. X, Z and H are each a half turn, so doing one twice undoes it.
The X gate swaps the two amplitudes, like a NOT gate. The Z gate flips the sign of the \left|1\right\rangle amplitude, and the H gate turns \left|0\right\rangle into \left|+\right\rangle.
A circuit draws one line per qubit with its gates on it. Read it left to right, like a sentence.
A short circuit plays gate by gate while the Bloch arrow turns half a turn about each gate's axis.
Practice: Reach the target
Build a circuit of up to three gates that turns the start state into the target.
Two qubits and CNOT
Two qubits can be read as \left|00\right\rangle, \left|01\right\rangle, \left|10\right\rangle or \left|11\right\rangle. Each of the four gets its own amplitude.
Every extra qubit doubles the count, so n qubits need 2^n amplitudes. Fifty qubits already need over a million billion.
The CNOT gate acts on two qubits. It flips the target qubit only when the control qubit is 1.
A CNOT gate steps through all four inputs, lighting the matching row of its truth table.
Practice: Trace the circuit
Work out the output bits of a short circuit of X and CNOT gates.
Entanglement
Apply H to the first qubit, then a CNOT, and something new appears. The pair ends up in a Bell state.
\left|00\right\rangle(Both qubits start at 0)\frac{1}{\sqrt{2}}\left|00\right\rangle + \frac{1}{\sqrt{2}}\left|\textcolor{#8b5cf6}{1}0\right\rangle(H on the first qubit)\frac{1}{\sqrt{2}}\left|00\right\rangle + \frac{1}{\sqrt{2}}\left|1\textcolor{#8b5cf6}{1}\right\rangle(CNOT flips the second when the first is 1)
Now neither qubit has a value of its own, only the pair does. This is entanglement.
Measure them and each result is random, yet the two always match. It cannot send messages, because neither side chooses its result.
H then CNOT makes a Bell pair; repeated shots only ever give 00 or 11.
Practice: Entangled results
Predict what the second qubit of an entangled pair gives.
Interference
When two paths lead to the same result, their amplitudes add, signs and all. So amplitudes can cancel, which chances never do.
Matching signs build up, which is constructive interference. Opposite signs cancel out, which is destructive interference.
H then H takes \left|0\right\rangle back to \left|0\right\rangle because the paths to 1 cancel. Put a Z in between and the paths to 0 cancel instead.
Amplitude paths through H, H and through H, Z, H, adding up or cancelling at the end.
Practice: Add the paths
Two paths reach the same result; add their amplitudes, then square for the chance.
Grover's search
Finding one marked item among N unsorted items can take N checks on a normal computer. Grover's algorithm needs only about \sqrt{N} rounds.
Each round flips the sign of the marked item's amplitude, then reflects every amplitude about the average. Interference grows the marked one and shrinks the rest.
That is a square root speedup, not a magic one. For a million items it means under a thousand rounds instead of up to a million checks.
Eight amplitude bars through two Grover rounds: flip the marked one, reflect about the mean.
Practice: Count Grover's rounds
Estimate the rounds Grover needs for a list, or the list size from the rounds.
Shor's algorithm and encryption
Much of the internet's security, including RSA, rests on one fact. Multiplying two big primes is easy, but splitting the answer back into them takes far too long.
Shor's algorithm turns factoring into finding how often a pattern repeats. A large, error-corrected quantum computer could find that repeat fast enough to break RSA.
Recent estimates need under a million qubits running for less than a week, still far beyond any machine today. New post-quantum encryption standards were published in 2024 and are already being rolled out.
The repeating pattern of 7 to the power x mod 15, its period, and the factors it gives.
Practice: What Shor breaks
Sort security methods by how a large quantum computer would affect them.
Noise and decoherence
Qubits are fragile: heat, stray signals and vibration nudge their amplitudes. Slowly the quantum state leaks into its surroundings, which is called decoherence.
Gates are imperfect too. The best two-qubit gates today fail roughly once in every thousand to ten thousand uses.
Useful programs need millions of gates. Without a fix, errors pile up long before the answer is ready.
The chance a whole run is error free, falling as the gate count grows, for three error rates.
Error correction
Quantum physics forbids copying an unknown qubit, so you can't simply keep backups. This is the no-cloning rule.
Error correction spreads one logical qubit across many physical qubits. Checks compare neighbours to find an error without reading the stored value.
In 2024 Google showed that making a code bigger made it more reliable, a key milestone. Current designs use from a few dozen to about a thousand physical qubits for each logical one.
A three-qubit code: an error flips one qubit, two parity checks find it, and it is flipped back.
Practice: Find the flipped qubit
Read the parity checks of a repetition code and tap the qubit that flipped.
Quantum hardware today
There are several ways to build a qubit, and no clear winner yet. Superconducting qubits are tiny circuits cooled to about a hundredth of a degree above absolute zero.
Trapped ion machines hold single charged atoms in electric fields and steer them with lasers. Neutral atom machines hold thousands of atoms in a grid of laser beams called tweezers.
Photonic machines use single particles of light travelling through chips. Light keeps its state well, but photons are easily lost.
The four main kinds of qubit, each with what it is, its strength and its weakness.
Practice: Match the hardware
Match each kind of quantum hardware to how it holds its qubits.
What quantum computers can't do
A quantum computer does not try every answer and read off the best one. Measuring gives one random result, so any speedup has to come from clever interference.
Only some problems have such tricks, like factoring, searching and simulating molecules. Email, video and games gain nothing.
As of late 2026, the biggest machines have hundreds to a few thousand physical qubits, but only tens of error-corrected logical qubits. Claimed wins over normal computers are on narrow science tasks, and no real encryption has been broken.
True or false: common claims about quantum computers.