You are reading without signing in. Sign in or continue as guest to take quizzes and climb the ranks.
Observables, Hamiltonians & Real Applications
Turn 0/1 counts into ⟨Z⟩, measure X and Y by rotating first, and add Pauli terms into the energy that chemistry and optimisation minimise.
- 01Compute ⟨Z⟩ = P(0) − P(1) from a histogram.
- 02Measure ⟨X⟩ and ⟨Y⟩ with a basis change before the measurement.
- 03Write a Hamiltonian as a weighted sum of Pauli strings and estimate its energy term by term.
A measurement gives bits, but chemistry and optimisation ask for numbers such as an energy or a cost. The bridge is an observable: give each outcome a value and average over the shots. For Z the rule is simple: outcome 0 counts as +1 and outcome 1 counts as −1.
01Measuring X and Y
| Observable | Gates before the measurement | Why |
|---|---|---|
| Z | none | the hardware measures Z |
| X | h | H swaps the X and Z axes |
| Y | sdg, h | S† turns the Y axis into the X axis, then H as above |
⟨Z⟩ and ⟨X⟩ of one state
ry(pi/3) tilts the qubit 60° from |0⟩. Simulate: P(0) ≈ 0.75 and P(1) ≈ 0.25, so ⟨Z⟩ ≈ 0.5. Now add h q[0]; before the measurement and simulate again: P(0) ≈ 0.933, so ⟨X⟩ = 2·0.933 − 1 ≈ 0.87, the exact value being √3/2.
OPENQASM 3.0;
include "stdgates.inc";
qubit[1] q;
bit[1] c;
ry(pi/3) q[0];
c[0] = measure q[0];
02Several qubits: Pauli strings
A Pauli string such as Z₀Z₁ multiplies the ±1 values of its qubits: outcomes with an even number of 1s count +1, odd ones −1. For the Bell state (|00⟩ + |11⟩)/√2 every shot is 00 or 11, so ⟨Z₀Z₁⟩ = +1, while ⟨Z₀⟩ alone is 0. Measuring X₀X₁ means an h on both qubits first; the Bell state gives +1 there too.
Correlations as expectation values
Simulate: only 00 and 11, so ⟨Z₀Z₁⟩ = +1. Add h q[0]; h q[1]; before the measurement: still only 00 and 11, so ⟨X₀X₁⟩ = +1 as well. Two independent qubits in |+⟩|+⟩ would give ⟨Z₀Z₁⟩ = 0.
OPENQASM 3.0;
include "stdgates.inc";
qubit[2] q;
bit[2] c;
h q[0];
cx q[0], q[1];
c = measure q;
03Hamiltonians: energy as a sum of Pauli terms
- Chemistry: once electrons are mapped to qubits, a molecule's energy becomes a sum of Pauli strings. The smallest textbook case, H₂ in a minimal basis, can be reduced to two qubits with terms such as Z₀, Z₁, Z₀Z₁, X₀X₁ and Y₀Y₁. VQE searches for the θ that makes ⟨H⟩ as low as possible; that minimum approximates the ground-state energy.
- Optimisation: in MaxCut an edge (i, j) contributes (1 − ZᵢZⱼ)/2, which is 1 when the two nodes are on different sides and 0 otherwise. Summing over the edges gives the cost Hamiltonian that QAOA works with. Portfolio selection and scheduling problems are written the same way, as weighted Z and ZZ terms.
2 questions · one try each counts
1000 shots give 900 zeros and 100 ones. What is the estimate of ⟨Z⟩?
Sign in to answer and climb the ranks; you will come back to this lesson.
H = 2Z − X and the state is |+⟩. What is ⟨H⟩?
Sign in to answer and climb the ranks; you will come back to this lesson.