Quantum Computing 101
Qubits
A qubit is the smallest unit of quantum information: two amplitudes that decide what a measurement will show.
In this lesson you will learn to
- Explain what a qubit has that a classical bit does not.
- Write a qubit as α|0⟩ + β|1⟩ and as a two-entry vector.
- Turn amplitudes into measurement probabilities and check that a state is normalized.
- Build a one-qubit state in Qiskit and read its amplitudes.
Bits and Qubits
A classical computer processes information using bits. A bit is always exactly one of two values, 0 or 1. Inside a processor that value is a voltage, and logic gates combine voltages, but at every moment each bit has a definite value that you could read without disturbing it.
Quantum mechanics describes physical systems whose measurements are probabilistic. Light gives us a concrete example. A photon can be measured for horizontal or vertical polarization. The measurement returns one of those two results, but before measurement its polarization state can contain an amplitude for each possibility.
Any two-level quantum system like this can serve as a qubit. We name its two measurable outcomes |0⟩ and |1⟩, the basis states. For the photon, horizontal could be |0⟩ and vertical |1⟩; in a superconducting chip they are two energy levels of a tiny circuit. The mathematics is the same either way.
Amplitudes and Probabilities
A general qubit state is written |ψ⟩ = α|0⟩ + β|1⟩. The numbers α and β are amplitudes. They can be positive, negative or even complex, and that extra information is what lets qubits do things coins cannot.
Amplitudes are not probabilities. The probability of measuring 0 is |α|², the squared size of α, and the probability of measuring 1 is |β|². This rule is called the Born rule.
A measurement must return something, so the two probabilities add up to one: |α|² + |β|² = 1. A state that satisfies this is called normalized.
Worked example: normalize and measure a qubit
Take a qubit whose |0⟩ amplitude is √3/2 and whose |1⟩ amplitude is 1/2.
from qiskit import QuantumCircuit
from qiskit.quantum_info import Statevector
import math
qc = QuantumCircuit(1)
qc.ry(math.pi / 3, 0) # rotate |0> until the amplitudes are sqrt(3)/2 and 1/2
state = Statevector.from_instruction(qc)
print(state.data)
# [0.8660254+0.j 0.5 +0.j]
print(state.probabilities())
# [0.75 0.25]›Check yourself: Is (|0⟩ + |1⟩)/2 a valid qubit state?
No. Its probabilities add up to (1/2)² + (1/2)² = 1/2, not 1. Dividing by √2 instead of 2 fixes it: (|0⟩ + |1⟩)/√2 gives 1/2 + 1/2 = 1.
State Vectors
Writing α|0⟩ + β|1⟩ every time gets long, so we stack the two amplitudes into a column vector. The top entry belongs to |0⟩ and the bottom entry to |1⟩. The starting state |0⟩ is the vector [1, 0].
Gates are matrices that multiply this vector. Every gate keeps the vector normalized, so the probabilities always still add up to one. The Hadamard gate H, for example, turns |0⟩ into an equal mix of |0⟩ and |1⟩.
Basis states as column vectors
The first vector entry is the amplitude of |0⟩; the second is the amplitude of |1⟩.
Worked example: apply H to |0⟩
Multiply the Hadamard matrix by the state vector for |0⟩. Every output entry is shown.
from qiskit import QuantumCircuit
from qiskit.quantum_info import Statevector
qc = QuantumCircuit(1)
qc.h(0)
print(Statevector.from_instruction(qc).data)
# [0.70710678+0.j 0.70710678+0.j]›Check yourself: Which vector represents −|1⟩, and what are its measurement probabilities?
[0, −1]. P(0) = 0 and P(1) = |−1|² = 1, exactly like |1⟩. A sign on the whole state is a global phase, and no measurement can ever detect it.
Key Takeaways
- A qubit state is α|0⟩ + β|1⟩, where α and β are amplitudes.
- Measuring gives 0 with probability |α|² and 1 with probability |β|² (the Born rule).
- A valid state is normalized: |α|² + |β|² = 1.
- Amplitudes can be negative or complex; probabilities never are.
- The state vector [α, β] lets gates act by matrix multiplication.
What To Practice
These challenges turn the ideas from this lesson into circuits. The first three need only one or two gates each, so start at the top and work down.
- Your First GateEasy ★Flip |0⟩ into |1⟩ with a single gate: the quantum NOT.
- Signed Hadamard ChainEasy ★Put every qubit in an equal superposition, adding a minus sign where asked.
- Bloch CompassEasy ★Reach |0⟩, |1⟩, |+⟩, |−⟩, |+i⟩ and |−i⟩ using only a few fixed gates.
- Loaded Twin CoinsEasy ★Choose an RY angle so the amplitudes give exactly the probability you want.