The Qubit
The Qubit
The qubit is the hydrogen atom of quantum computing — the simplest nontrivial quantum system, and the one we'll never stop using. Here we make it concrete: what it is physically, how superposition and the Born rule look in , and — for the first time in this program — how to build and run a real quantum circuit on AWS Braket. Everything stays on the free local simulator.
Learning Objectives
After this lesson you will be able to:
- Define a qubit as a two-level quantum system and give physical realizations.
- Write a general qubit state and compute computational-basis measurement probabilities.
- Explain superposition and how a single Hadamard creates it.
- Build, run, and read out a circuit on the Braket
LocalSimulator(free). - Connect the simulator's amplitudes and shot counts to the Born rule.
Intuition
A bit is a switch: or . A qubit is a quantum two-level system whose state can be any superposition of and — a complex blend that, when measured, yields or with probabilities set by the amplitudes. Physically a qubit can be the spin of an electron (), the polarization of a photon (H/V), two energy levels of an atom or a superconducting circuit (Term 4.4), and more. What makes all of them "qubits" is shared mathematics: the state space is , and the rules are the four postulates of Course 1.1.
Theory
The qubit state
By Postulate 1 (1.1.1), a qubit's state is a unit vector in :
with the computational basis \lvert0\rangle = \begin{psmallmatrix}1\\0\end{psmallmatrix}, \lvert1\rangle = \begin{psmallmatrix}0\\1\end{psmallmatrix}. The amplitudes are complex; their magnitudes give probabilities and their relative phase encodes interference (1.1.1).
Born rule for a qubit
Measuring in the computational basis ( observable, 1.1.2):
A result of collapses the state to ; a result of to .
Superposition and the Hadamard
The most important single-qubit operation for creating superposition is the Hadamard gate H = \tfrac1{\sqrt2}\begin{psmallmatrix}1&1\\1&-1\end{psmallmatrix} (Appendix E):
Starting from the definite state , one produces an equal superposition: measuring it in the computational basis gives or with probability each. This is the "fair quantum coin," and it's the natural first circuit to run. (Gates get the full treatment in Term 2; here we use as our entry point.)
Worked Examples
Example 1 — Probabilities of a general qubit
For : and (the phase does not affect the magnitude). Sum . ✓ The phase would matter if we measured in the or basis (1.2.3).
Example 2 — The Hadamard "coin"
Apply to : , so a -measurement gives and each with probability . Apply a second : since , — measuring now gives with certainty. Two "random" coin flips compose to a deterministic result: interference, not classical randomness. We'll see this directly on the simulator below.
Hands-on (Python)
First, in NumPy
import numpy as np
ket0 = np.array([1, 0], dtype=complex)
ket1 = np.array([0, 1], dtype=complex)
H = np.array([[1, 1], [1, -1]], dtype=complex) / np.sqrt(2)
plus = H @ ket0 # |+>
print(np.round(plus, 4)) # [0.7071 0.7071]
print(np.abs(plus)**2) # [0.5 0.5] Born probabilities
print(np.allclose(H @ (H @ ket0), ket0)) # True: HH = I (interference -> back to |0>)Now on AWS Braket (local simulator — free) ⚙️
This is your first Braket circuit. It runs entirely on your machine via LocalSimulator — no AWS
account, no cost (see Appendix A). Three concepts: a
Circuit holds gates; LocalSimulator executes it; shots is how many times we sample the
measurement.
# the_qubit.py — free, local, no AWS account needed.
from braket.circuits import Circuit
from braket.devices import LocalSimulator
# Build a one-qubit circuit: H on qubit 0 prepares |+>.
circ = Circuit().h(0)
print(circ) # ASCII circuit diagram
# Run it. Braket measures all qubits in the computational (Z) basis by default.
device = LocalSimulator() # default backend: state-vector ("braket_sv")
result = device.run(circ, shots=1000).result()
print(result.measurement_counts) # ~ Counter({'0': ~500, '1': ~500})T : |0|
q0 : -H-
Counter({'0': 508, '1': 492})The counts are samples from the Born distribution — finite-shot estimates with the error from 0.2.2. Now confirm the interference of Example 2 — two Hadamards return a definite :
circ2 = Circuit().h(0).h(0) # H then H = identity on |0>
counts = LocalSimulator().run(circ2, shots=1000).result().measurement_counts
print(counts) # Counter({'0': 1000}) — always 0If you also want the exact amplitudes (simulator-only superpower; real hardware never gives these), add a state-vector result type:
circ3 = Circuit().h(0)
circ3.state_vector() # request the full amplitude vector
sv = LocalSimulator().run(circ3, shots=0).result().values[0]
print(np.round(sv, 4)) # [0.7071+0.j 0.7071+0.j] = |+>⚠️ Cost reminder.
LocalSimulatoris free. The on-demand simulators (SV1/DM1/TN1) and QPUs are billed — we don't touch them until Term 5, and never automatically. Everything in Terms 1–4 runs locally.
Exercises
E1 (easy). For , give the -measurement probabilities and predict the approximate counts for 1000 shots.
Solution
, . Over 1000 shots expect ≈ 200 '0' and ≈ 800 '1', with statistical spread
counts.
E2 (easy). Write the Braket circuit that prepares from the default , and predict its measurement counts.
Solution
Circuit().x(0) (Pauli- = NOT flips ). Counts: all '1'
(Counter({'1': 1000})), since the state is the definite .
E3 (medium). Using only NumPy, verify that applying to gives and that its -measurement probabilities are also . Why do and give identical computational-basis statistics despite being different states?
Solution
; each. They share -statistics because those depend only on amplitude magnitudes; the distinguishing relative phase ( vs ) only shows up in a different basis (e.g. ), where and with certainty — see 1.2.3.
E4 (medium). Run (or simulate by hand) Circuit().h(0).h(0).h(0) on . What are the
output statistics and why?
Solution
Three Hadamards: , so the state is and the counts are ≈ 50/50. An odd number of 's acts like a single ; an even number like the identity.
E5 (hard). A state (real amplitudes). You run many shots and observe . Estimate , and state how many shots you'd need to pin to within at 95% confidence.
Solution
rad (). For a estimate of a probability at 95% confidence, Hoeffding gives with , : shots (from 0.2.2).
Checkpoint
- What is a qubit, and what is its state space? Name two physical realizations.
- Write a general qubit state and its computational-basis measurement probabilities.
- What does a single Hadamard do to , and what do two do? Why?
- In the Braket code, what are
Circuit,LocalSimulator,shots, andmeasurement_counts? - Why are local-simulator runs free, and which Braket resources are not?
Answers
- A two-level quantum system; state space . Realizations: electron spin, photon polarization, atomic/superconducting energy levels (any two).
- with ; , .
- One : (equal superposition). Two: returns — interference, not random.
Circuitis the gate sequence;LocalSimulatorruns it on your machine;shots= number of measurement samples;measurement_countsis the histogram of outcome bit-strings.LocalSimulatorruns on your own CPU (no AWS service invoked); on-demand simulators (SV1/DM1/TN1) and QPUs are billed cloud resources (Term 5).
Further Reading
- [NC] Nielsen & Chuang, §1.2, §2.2 — the qubit and superposition.
- [Mer] Mermin, Quantum Computer Science, Ch. 1 — qubits for computer scientists.
- [SDK]
amazon-braket-sdk-pythonREADME & examples — theCircuit/LocalSimulatorAPI.
← Prev: 1.1.4 Composite Systems Postulate · Up: Term 1 · Next: The Bloch Sphere →