Bases & Expectation Values
Bases & Expectation Values
A measurement is always made in a basis. The computational () basis is just one choice; the and bases ask different questions of the same qubit, and the relative phase that can't see becomes a definite answer in or . This lesson makes "measure in a basis" precise, ties the three Pauli bases to the three Bloch axes, and shows the one trick real hardware needs — rotate the basis you care about onto , then measure — with runnable Braket code on the free local simulator.
Learning Objectives
After this lesson you will be able to:
- Write the eigenbases of , , and the Born rule for a measurement in any orthonormal basis.
- Reduce a measurement in an arbitrary basis to a basis-change unitary followed by a computational-basis readout.
- Compute an expectation value from outcome probabilities, and recognize as the Bloch coordinates.
- Build Braket circuits that measure a qubit in the , , and bases and estimate from shot counts.
- Relate the finite-shot error of an estimate to the variance of a observable.
Intuition
In 1.2.1 we only ever measured in the computational basis — the question "are you or ?" But and give identical -statistics () despite being different states; their distinguishing relative phase is invisible to . Ask a different question — "are you or ?", the -basis measurement — and the two states separate perfectly. Each Pauli observable corresponds to one of the three Bloch axes (1.2.2); measuring it projects the Bloch vector onto that axis. Real devices only ever measure along , so to ask an or question we first rotate that axis onto with a gate, then read out. The averaged answer over many shots is the expectation value, and the three expectation values are exactly the coordinates of the Bloch vector.
Theory
The three Pauli bases
Each Pauli operator is Hermitian with eigenvalues ; its two eigenvectors form an orthonormal basis of (1.1.2, Appendix E):
| Observable | Eigenvalue | Eigenvalue | Bloch axis |
|---|---|---|---|
These are the three "natural" bases of a single qubit, mutually unbiased: a state definite in one basis is maximally uncertain in the other two (e.g. gives in both and ).
The Born rule in an arbitrary basis
Let be any orthonormal basis. Measuring in that basis yields outcome with probability (1.1.2)
and collapses the state to . For the basis, and ; for , replace by .
Measurement as a basis change onto
Hardware measures one fixed basis (the computational basis). To measure an observable , collect its eigenvectors as the columns of a unitary , so that . Then rotates the eigenbasis onto the computational basis, and
measuring on = applying , then a computational-basis measurement. For the Pauli bases this needs just one or two gates:
Indeed , (so rotates the -basis onto ); and , with (derived in Exercise E3). After the rotation, computational outcome corresponds to eigenvalue and outcome to .
Expectation values, and the link to the Bloch vector
The expectation value of is the mean eigenvalue over many measurements (1.1.2):
For a -valued observable (any Pauli) this collapses to a difference of two probabilities,
so an estimate is immediate from shot counts: . Computing all three Pauli expectation values reconstructs the Bloch vector of 1.2.2:
So the abstract "measure three observables" is the concrete "find the point on the sphere."
Worked Examples
Example 1 — in all three bases
For : in , so . In , is the eigenstate, so deterministically and . In , , so . The Bloch vector is — the axis, exactly as 1.2.2 predicted. Only the measurement "sees" the relative phase that distinguishes from .
Example 2 — Expectation values of a tilted real state
Take (real amplitudes, , ). Then , , and (real amplitudes never tilt toward ). Bloch vector , with as required for a pure state.
Hands-on (Python)
Exact, in NumPy
import numpy as np
ket0 = np.array([1, 0], dtype=complex)
ket1 = np.array([0, 1], dtype=complex)
X = np.array([[0, 1], [1, 0]], dtype=complex)
Y = np.array([[0, -1j], [1j, 0]], dtype=complex)
Z = np.array([[1, 0], [0, -1]], dtype=complex)
def expect(A, psi):
"""Exact expectation <psi|A|psi> (real for Hermitian A)."""
return np.real(psi.conj() @ A @ psi)
plus = (ket0 + ket1) / np.sqrt(2) # |+>
print(np.round([expect(A, plus) for A in (X, Y, Z)], 6)) # [1. 0. 0.] -> Bloch +x
# Born probabilities in the X basis come from <+|psi>, <-|psi>:
minus = (ket0 - ket1) / np.sqrt(2)
psi = np.cos(np.pi/6)*ket0 + np.sin(np.pi/6)*ket1 # Worked Example 2
print(round(abs(np.vdot(plus, psi))**2, 6), # 0.933013 = p(+) in X basis
round(abs(np.vdot(minus, psi))**2, 6)) # 0.066987 = p(-) in X basis
print(np.round([expect(A, psi) for A in (X, Y, Z)], 6)) # [0.866025 0. 0.5]Estimating on Braket (local simulator — free) ⚙️
Braket always measures in the computational () basis, so we rotate the axis we want onto before
measuring — H for , S† then H (.si(0).h(0)) for , nothing for — then read
from the counts. (The deeper Braket result-type API arrives in
Term 2.1; here we sample, as in
1.3.1.)
# bases_and_expectation.py — free, local, no AWS account needed.
from braket.circuits import Circuit
from braket.devices import LocalSimulator
device = LocalSimulator() # free local state-vector simulator
def estimate_pauli(prep, basis, shots=20000):
"""Estimate <sigma> on the state prepared by `prep` (a function adding gates)."""
c = Circuit()
prep(c) # state preparation
if basis == "X":
c.h(0) # rotate X-basis onto Z
elif basis == "Y":
c.si(0).h(0) # rotate Y-basis onto Z (S† then H)
# basis == "Z": measure directly
counts = device.run(c, shots=shots).result().measurement_counts
n0, n1 = counts.get("0", 0), counts.get("1", 0)
return (n0 - n1) / (n0 + n1) # <sigma> = p(+) - p(-)
prep_plus = lambda c: c.h(0) # |+> = H|0>
print("Estimated <X>,<Y>,<Z> on |+>:",
[round(estimate_pauli(prep_plus, b), 3) for b in ("X", "Y", "Z")])
# ≈ [1.0, 0.0, 0.0] -> the +x axis, matching the exact NumPy resultWhy ±1 estimates are cheap. A Pauli outcome is with variance (0.2.2), so the standard error of is . With shots, on lands within of essentially every run.
Exercises
E1 (easy). For , give the -basis probabilities and . Which Bloch axis is this?
Solution
, , so and . Likewise , while : the axis, the south pole. ∎
E2 (easy). Which single Pauli basis perfectly distinguishes from , and which one cannot tell them apart at all?
Solution
The basis distinguishes them with certainty (, ). The basis cannot: both give . ( also gives for each.) The distinguishing information is the relative phase, visible only along . ∎
E3 (medium). Show that rotates the eigenbasis onto the computational basis, i.e. and .
Solution
. Then $S^\dagger\lvert{+}i\rangle = \tfrac1{\sqrt2}(\lvert0\rangle + (-i)(i)\lvert1\rangle)
= \tfrac1{\sqrt2}(\lvert0\rangle+\lvert1\rangle) = \lvert+\rangleH\lvert+\rangle=\lvert0\rangle$. Similarly
and .
So in a circuit, .si(0).h(0) (apply , then ) implements . ∎
E4 (medium). A qubit is measured and reports , , . What is the state? What if instead ?
Solution
The Bloch vector is . First case: = north pole = . Second case: = axis = . For a pure state , so the three expectation values fix the state up to global phase. ∎
E5 (hard). You want to estimate of a state with true value to within at confidence. About how many shots are needed?
Solution
A outcome is with . The estimator has standard error . For a half-width at (): shots (from 0.2.2). Note the worst case is (variance ), needing . ∎
Checkpoint
- Write the eigenstates of , , and the Bloch axis each basis measures.
- State the Born rule for a measurement in an arbitrary orthonormal basis.
- How do you measure (and ) on hardware that only measures ?
- Give the formula for in terms of the two outcome probabilities, and connect to the Bloch sphere.
- Why is the standard error of a Pauli expectation estimate at most ?
Answers
- : (); : (); : ().
- ; outcome collapses the state to .
- Rotate the target eigenbasis onto first: apply to measure , apply then to measure , then read out in the computational basis.
- ; the three Pauli expectation values are the Cartesian coordinates of the Bloch vector .
- A observable has variance , so the mean's standard error is .
Further Reading
- [NC] Nielsen & Chuang, §2.2.3–2.2.5 — measurement, observables, and changing measurement basis.
- [Pre] Preskill, Ph219, Ch. 2 — qubit observables and mutually unbiased bases.
- [SDK]
amazon-braket-sdk-python— theCircuitgate set (h,s,si) andmeasurement_counts.
← Prev: The Bloch Sphere · Up: Term 1 · Next: Projective Measurement →