Bits and qubits
A bit is 0 or 1. A qubit is described by two numbers called amplitudes, but when you look at it you still get only 0 or 1. Learn what that really means.
In 60 seconds
Bits and qubits
A bit is 0 or 1. A qubit is described by two numbers called amplitudes, but when you look at it you still get only 0 or 1. Learn what that really means.
What a qubit is
|0⟩ and |1⟩. The strange-looking brackets are just labels, read as "ket 0" and "ket 1". Engineers build qubits in several ways, for example tiny superconducting circuits kept very cold, single charged atoms (ions) held by electric fields, or particles of light.state = a|0⟩ + b|1⟩
a = amplitude for 0
b = amplitude for 1
rule: |a|² + |b|² = 1| Bit | Qubit | |
|---|---|---|
| What it can be | 0 or 1 | Any state a|0⟩ + b|1⟩ with |a|² + |b|² = 1 |
| What you read out | 0 or 1, exactly as stored | 0 or 1, at random, with chances |a|² and |b|² |
| Can you copy it? | Yes, as often as you like | No: an unknown qubit state cannot be copied (the no-cloning theorem) |
| Numbers needed to describe n of them | n bits | 2ⁿ amplitudes (for a general state of n qubits) |
Clearing up a common myth
- A qubit is 0 and 1 at the same time, so it holds twice the information
- A quantum computer tries every answer at once and picks the best
- Qubits are magic, and nobody understands them
- A qubit has a state with two amplitudes, but one measurement gives you just one bit
- Measuring gives one random outcome; a good quantum algorithm uses interference to make the right answers likely
- Quantum mechanics is a precise, well-tested theory with clear maths, the same maths you will use in this track
Checking a state
import numpy as np
states = {
"|0>": [1.0, 0.0],
"equal mix": [1 / np.sqrt(2), 1 / np.sqrt(2)],
"60/40 style": [0.6, 0.8],
"not valid": [0.5, 0.5],
}
for name, (a, b) in states.items():
total = abs(a) ** 2 + abs(b) ** 2
print(f"{name:12s} a={a:.3f} b={b:.3f} |a|^2+|b|^2 = {total:.3f}")Watch and read more
Lab
Two small Python functions: one that lists all classical bit patterns, and one that checks if two amplitudes form a valid qubit state.
The problem
Run this in the browser, or with Python 3 and numpy.
- Finish
bit_patterns(n)so it returns a list of every n-bit string, for examplebit_patterns(2)gives["00", "01", "10", "11"]. (Hint:itertools.product("01", repeat=n).) - Finish
is_valid_state(a, b)so it returns True only when |a|² + |b|² is 1. Allow a tiny rounding error, for example 1e-9. - Print how many patterns there are for n = 1 to 10. Write one sentence: a register of 10 bits holds how many of these patterns at once?
Practice lab
Edit the code and run it. Python runs in your browser — nothing is sent to our server.
No output. Add print(...) to see values.
You are done when
Hard questions
Try to answer before you reveal. If you can answer these, you understood the lesson.
Q1If a qubit has two amplitudes that can be any valid numbers, why can't we store a whole book in one qubit?Reveal
Because we can never read the amplitudes directly. One measurement gives one bit, and it destroys the old state. Even with many copies of a state you would need many measurements to estimate the amplitudes roughly, and the no-cloning theorem says you cannot make copies of an unknown state. A known result (Holevo's bound) says one qubit can carry at most one classical bit of readable information in this setting.
Q2A friend says: "Two amplitudes means a qubit is 50% zero and 50% one." When is that true, and when is it wrong?Reveal
It is only true for states where |a|² = |b|² = 0.5, such as a = b = 1/√2. Other states give other chances, like 36% and 64%. And even for equal chances, the signs (and phases) of the amplitudes matter: 1/√2 and −1/√2 give the same chances when measured, but behave differently when gates are applied, because they interfere differently.
Questions people ask
Is a qubit just a bit we are unsure about?
No. A bit you are unsure about is really 0 or 1, and you just do not know which. A qubit's amplitudes can interfere with each other, and experiments show effects that no "hidden 0 or 1" explanation can produce in general. Lesson 3 comes back to this.
Why do qubits need to be kept so cold or so isolated?
Any tiny disturbance from the outside world, such as heat, stray light or vibration, can disturb the amplitudes. This is called noise or decoherence. Cold and isolation reduce it, but no one has removed it fully. The last lesson covers this.
Can I have a qubit at home?
Not a real one, but you can use a simulator on your own computer, which is what this track does. Some organisations also let students run small programs on real quantum hardware over the internet; check what is currently offered.
What does the |0⟩ notation mean?
It is called Dirac or "bra-ket" notation. |0⟩ is just a name for the state that always gives 0 when measured. In code we write it as the list [1, 0], and |1⟩ as [0, 1].
Lesson test
5 questions. Get 3 right (60%) to pass and complete this lesson.