Simple Algorithm
Quantum Computing · Excited State · 22 min

Observables, Bases & Expectation Values

Measuring in any basis, Pauli observables and expectation values.

"Zero or one?" is just one question you can ask a qubit. Every Hermitian matrix defines another, and its average value can be estimated from shots. This is the language in which energies, Bloch vectors and error-correction checks are all written.

What you’ll learn

  • Turn a Hermitian operator into a projective measurement using its spectral decomposition.
  • Compute expectation values ⟨A⟩=⟨ψ∣A∣ψ⟩\expval{A} = \bra\psi A\ket\psi and variances, and read the Bloch vector off ⟨X⟩,⟨Y⟩,⟨Z⟩\expval{X},\expval{Y},\expval{Z}.
  • Measure in any single-qubit basis by rotating first, and derive the XX- and YY-readout circuits.
  • Explain when observables can be measured together, and measure a two-qubit parity without learning the individual bits.
  • Estimate the number of shots needed to reach a target precision.

Observables are Hermitian operators

An observable is a quantity you can measure, represented by a Hermitian operator A=A†A = A^\dagger. The spectral theorem lets you write it as

A=∑aa Pa,A = \sum_a a\,P_a,

where the aa are its distinct, real eigenvalues and PaP_a projects onto the corresponding eigenspace. Measuring AA means performing the projective measurement {Pa}\{P_a\} and reporting the eigenvalue aa as the result.

ObservableEigenvalue +1+1Eigenvalue −1-1Spectral form
ZZ∣0⟩\ket0∣1⟩\ket1∣0⟩ ⁣⟨0∣−∣1⟩ ⁣⟨1∣\dyad{0}-\dyad{1}
XX∣+⟩\ket+∣−⟩\ket-∣+⟩ ⁣⟨+∣−∣−⟩ ⁣⟨−∣\dyad{+}-\dyad{-}
YY∣+i⟩\ket{+i}∣−i⟩\ket{-i}∣+i⟩ ⁣⟨+i∣−∣−i⟩ ⁣⟨−i∣\dyad{+i}-\dyad{-i}
n^⋅σ⃗\hat n\cdot\vec\sigma∣n^⟩\ket{\hat n}, the Bloch point n^\hat n∣−n^⟩\ket{-\hat n}∣n^⟩ ⁣⟨n^∣−∣−n^⟩ ⁣⟨−n^∣\dyad{\hat n}-\dyad{-\hat n}
The Pauli observables and their eigenstates. Every single-qubit observable has the form c0I+c n^⋅σ⃗c_0\id + c\,\hat n\cdot\vec\sigma with real c0c_0 and c≥0c \ge 0: a spin component along some axis, rescaled and shifted.
Check your understanding

What are the possible outcomes of measuring the observable A=12(X+Z)A = \tfrac{1}{\sqrt2}(X+Z), and in which basis is it measured?

  1. ±1\pm1, in the eigenbasis of the Hadamard gate (the Bloch axis halfway between xx and zz)
  2. ±2\pm\sqrt2, in the ZZ basis
  3. 00 and 11, in the XX basis
  4. ±12\pm\tfrac{1}{\sqrt2}, by measuring half the shots in XX and half in ZZ
Show the answer

A. ±1\pm1, in the eigenbasis of the Hadamard gate (the Bloch axis halfway between xx and zz)

12(X+Z)=n^⋅σ⃗\tfrac{1}{\sqrt2}(X+Z) = \hat n\cdot\vec\sigma with n^=(1,0,1)/2\hat n = (1,0,1)/\sqrt2, a unit vector, so its eigenvalues are ±1\pm1. It is exactly the Hadamard matrix HH, which is Hermitian as well as unitary.

Expectation values and the Bloch vector

DerivationThe average outcome
  1. ⟨A⟩=∑aa p(a)=∑aa⟨ψ∣Pa∣ψ⟩=⟨ψ∣(∑aaPa)∣ψ⟩=⟨ψ∣A∣ψ⟩\expval{A} = \sum_a a\,p(a) = \sum_a a\bra\psi P_a\ket\psi = \bra\psi\Big(\sum_a aP_a\Big)\ket\psi = \bra\psi A\ket\psi

    The expectation value needs no diagonalization: sandwich AA between the state's bra and ket. For a mixed state, ⟨A⟩=Tr⁡(ρA)\expval{A} = \Tr(\rho A).

  2. (ΔA)2=⟨A2⟩−⟨A⟩2(\Delta A)^2 = \expval{A^2} - \expval{A}^2

    The variance of the outcome distribution, because A2=∑aa2PaA^2 = \sum_a a^2 P_a.

  3. P2=I  ⟹  (ΔP)2=1−⟨P⟩2(P=X,Y,Z)P^2 = \id \;\Longrightarrow\; (\Delta P)^2 = 1 - \expval{P}^2 \qquad (P = X, Y, Z)

    For a Pauli observable, the variance is fixed by the mean.

  4. ∣ψ⟩=cos⁡θ2∣0⟩+eiφsin⁡θ2∣1⟩  ⟹  (⟨X⟩,⟨Y⟩,⟨Z⟩)=(sin⁡θcos⁡φ, sin⁡θsin⁡φ, cos⁡θ)\ket\psi = \cos\tfrac\theta2\ket0 + e^{i\varphi}\sin\tfrac\theta2\ket1 \;\Longrightarrow\; \big(\expval{X},\expval{Y},\expval{Z}\big) = (\sin\theta\cos\varphi,\ \sin\theta\sin\varphi,\ \cos\theta)

    The three Pauli averages are the Cartesian coordinates of the Bloch vector r⃗\vec r. For example ⟨X⟩=2Re⁡(α∗β)=2cos⁡θ2sin⁡θ2cos⁡φ\expval{X} = 2\operatorname{Re}(\alpha^*\beta) = 2\cos\tfrac\theta2\sin\tfrac\theta2\cos\varphi.

Predict before you look

A qubit has Bloch angles θ=π/3\theta = \pi/3 and φ=0\varphi = 0. What is ⟨X⟩\expval{X}?

Show the answer

0.87

⟨X⟩=sin⁡θcos⁡φ=sin⁡60∘≈0.87\expval{X} = \sin\theta\cos\varphi = \sin 60^\circ \approx 0.87, so XX-basis shots give +1+1 with probability (1+0.87)/2≈0.93(1+0.87)/2 \approx 0.93.

Measuring in any basis

Hardware typically measures only ZZ. To measure an observable whose eigenbasis is {U∣0⟩,U∣1⟩}\{U\ket0, U\ket1\}, that is A=UZU†A = UZU^\dagger, apply U†U^\dagger first and then measure ZZ:

∣⟨0∣U†∣ψ⟩∣2=∣⟨U0∣ψ⟩∣2.\abs{\bra{0}U^\dagger\ket{\psi}}^2 = \abs{\braket{U0|\psi}}^2.

For X=HZHX = HZH, apply HH. For Y=(SH) Z (SH)†Y = (SH)\,Z\,(SH)^\dagger, apply (SH)†=HS†(SH)^\dagger = HS^\dagger: first S†S^\dagger, then HH.

With all three readouts in hand you can reconstruct an unknown state. The widget below prepares a fixed "mystery" state and measures it in whichever basis you choose.

Check your understanding

Suppose your data give ⟨X⟩≈0\expval{X}\approx 0, ⟨Y⟩≈0.87\expval{Y}\approx 0.87 and ⟨Z⟩≈0.5\expval{Z}\approx 0.5. Which state was prepared?

  1. 32∣0⟩+12∣1⟩\tfrac{\sqrt3}{2}\ket0 + \tfrac12\ket1
  2. 32∣0⟩+i2∣1⟩\tfrac{\sqrt3}{2}\ket0 + \tfrac{i}{2}\ket1
  3. 12∣0⟩+i32∣1⟩\tfrac12\ket0 + \tfrac{i\sqrt3}{2}\ket1
  4. ∣+i⟩\ket{+i}
Show the answer

B. 32∣0⟩+i2∣1⟩\tfrac{\sqrt3}{2}\ket0 + \tfrac{i}{2}\ket1

⟨Z⟩=cos⁡θ=0.5\expval{Z} = \cos\theta = 0.5 gives θ=60∘\theta = 60^\circ, and ⟨X⟩=0\expval{X} = 0 with ⟨Y⟩>0\expval{Y} > 0 gives φ=90∘\varphi = 90^\circ. So ∣ψ⟩=cos⁡30∘∣0⟩+eiπ/2sin⁡30∘∣1⟩=32∣0⟩+i2∣1⟩\ket\psi = \cos 30^\circ\ket0 + e^{i\pi/2}\sin 30^\circ\ket1 = \tfrac{\sqrt3}{2}\ket0 + \tfrac i2\ket1.

Commuting observables and parity checks

Two observables can be measured together, in a single shot, exactly when they commute.

Multi-qubit observables give the most useful examples. The parity Z⊗ZZ\otimes Z, with eigenvalue +1+1 on ∣00⟩,∣11⟩\ket{00},\ket{11} and −1-1 on ∣01⟩,∣10⟩\ket{01},\ket{10}, commutes with X⊗XX\otimes X, even though Z⊗IZ\otimes\id and X⊗IX\otimes\id anticommute: the two sign flips cancel.

Measuring Z⊗ZZ\otimes Z uses the rank-2 projectors 12(I±Z⊗Z)\tfrac12(\id\pm Z\otimes Z). It reveals whether two bits agree, without revealing either bit. With an ancilla qubit, two CNOTs copy the parity, and only the parity, onto the ancilla.

How many shots?

Each shot of a Pauli measurement returns ±1\pm1 with variance 1−⟨P⟩21-\expval{P}^2, so the sample mean of NN shots has standard error

se⁡=1−⟨P⟩2N  ≤  1N.\operatorname{se} = \sqrt{\frac{1-\expval{P}^2}{N}} \;\le\; \frac{1}{\sqrt N}.

Reaching precision ϵ\epsilon takes about N≈(1−⟨P⟩2)/ϵ2N \approx (1-\expval{P}^2)/\epsilon^2 shots: up to 10410^4 for ϵ=0.01\epsilon = 0.01. A Hamiltonian written as a sum of Paulis, H=∑kckPkH=\sum_k c_k P_k, has ⟨H⟩=∑kck⟨Pk⟩\expval{H} = \sum_k c_k\expval{P_k}, and commuting terms can be measured simultaneously. Grouping them is a major cost-saver in variational algorithms.

Think first Why can't you estimate ⟨X⟩\expval{X} and ⟨Z⟩\expval{Z} of a qubit from the same shots?

XX and ZZ anticommute, so they have no common eigenbasis. A shot in the ZZ basis yields a ZZ value and destroys the XX information: it collapses the state onto ∣0⟩\ket0 or ∣1⟩\ket1, for which XX is a coin flip. You have to split your shots between bases.

Key takeaways

  • An observable is a Hermitian A=∑aaPaA=\sum_a aP_a; measuring it is the projective measurement {Pa}\{P_a\}, with the eigenvalues as outcome labels.
  • ⟨A⟩=⟨ψ∣A∣ψ⟩=Tr⁡(ρA)\expval{A} = \bra\psi A\ket\psi = \Tr(\rho A). For Paulis (ΔP)2=1−⟨P⟩2(\Delta P)^2 = 1-\expval{P}^2, and (⟨X⟩,⟨Y⟩,⟨Z⟩)(\expval X,\expval Y,\expval Z) is the Bloch vector.
  • To measure UZU†UZU^\dagger, apply U†U^\dagger and then measure ZZ: HH for XX; S†S^\dagger then HH for YY.
  • Commuting observables share an eigenbasis and can be measured together. Parity checks like Z⊗ZZ\otimes Z learn one bit of correlation and nothing else.
  • Estimating ⟨P⟩\expval{P} to precision ϵ\epsilon takes about (1−⟨P⟩2)/ϵ2(1-\expval{P}^2)/\epsilon^2 shots.

Check yourself

In the interactive lesson these are scored with your confidence, and what you miss comes back for review.

Question 1

A qubit gives outcome 00 (the +1+1 eigenvalue of ZZ) with probability 0.90.9. What are ⟨Z⟩\expval{Z} and ΔZ\Delta Z?

  1. ⟨Z⟩=0.9\expval{Z}=0.9 and ΔZ=0.1\Delta Z = 0.1
  2. ⟨Z⟩=0.8\expval{Z}=0.8 and ΔZ=0.36\Delta Z = 0.36
  3. ⟨Z⟩=0.8\expval{Z}=0.8 and ΔZ=0.6\Delta Z = 0.6
  4. ⟨Z⟩=0.4\expval{Z}=0.4 and ΔZ=0.6\Delta Z = 0.6
Show the answer

C. ⟨Z⟩=0.8\expval{Z}=0.8 and ΔZ=0.6\Delta Z = 0.6

⟨Z⟩=0.9−0.1=0.8\expval{Z} = 0.9 - 0.1 = 0.8 and (ΔZ)2=1−0.82=0.36(\Delta Z)^2 = 1 - 0.8^2 = 0.36, so ΔZ=0.6\Delta Z = 0.6.

Question 2

Your hardware measures only ZZ. Which gates, applied in this order before the measurement, implement a measurement of YY?

  1. HH only
  2. SS, then HH
  3. HH, then S†S^\dagger
  4. S†S^\dagger, then HH
Show the answer

D. S†S^\dagger, then HH

You need VV with V†ZV=YV^\dagger Z V = Y. With V=HS†V = HS^\dagger (first S†S^\dagger, then HH): V†ZV=SHZHS†=SXS†=YV^\dagger ZV = SHZHS^\dagger = SXS^\dagger = Y. It maps ∣+i⟩↦∣0⟩\ket{+i}\mapsto\ket0 and ∣−i⟩↦∣1⟩\ket{-i}\mapsto\ket1.

Question 3

Which pair of two-qubit observables can be measured simultaneously in a single shot?

  1. Z⊗ZZ\otimes Z and X⊗XX\otimes X
  2. Z⊗IZ\otimes\id and X⊗IX\otimes\id
  3. Z⊗ZZ\otimes Z and X⊗IX\otimes\id
  4. X⊗YX\otimes Y and X⊗ZX\otimes Z
Show the answer

A. Z⊗ZZ\otimes Z and X⊗XX\otimes X

Z⊗ZZ\otimes Z and X⊗XX\otimes X anticommute on each qubit, so the two signs cancel and they commute. Their common eigenbasis is the Bell basis.

Question 4

You measure Z⊗ZZ\otimes Z on 12(∣01⟩+∣10⟩)\tfrac{1}{\sqrt2}(\ket{01}+\ket{10}) and obtain −1-1. What is the state afterward?

  1. ∣01⟩\ket{01} or ∣10⟩\ket{10}, each with probability 12\tfrac12
  2. Unchanged: 12(∣01⟩+∣10⟩)\tfrac{1}{\sqrt2}(\ket{01}+\ket{10})
  3. 12(∣00⟩+∣11⟩)\tfrac{1}{\sqrt2}(\ket{00}+\ket{11})
  4. ∣00⟩\ket{00}
Show the answer

B. Unchanged: 12(∣01⟩+∣10⟩)\tfrac{1}{\sqrt2}(\ket{01}+\ket{10})

The state already lies in the −1-1 eigenspace of Z⊗ZZ\otimes Z, spanned by ∣01⟩\ket{01} and ∣10⟩\ket{10}. The projector 12(I−Z⊗Z)\tfrac12(\id - Z\otimes Z) leaves it alone: a parity measurement neither reveals nor disturbs which bit is which.

Go deeper

Further reading

  • M. A. Nielsen & I. L. Chuang, Quantum Computation and Quantum Information, §2.1 (Hermitian operators, simultaneous diagonalization) and §2.2.5 (projective measurements) (Cambridge, 10th anniv. ed., 2010).
  • J. J. Sakurai & J. Napolitano, Modern Quantum Mechanics, 2nd ed., Ch. 1 (2011).
  • R. de Wolf, Quantum Computing: Lecture Notes, arXiv:1907.09415.