# Measurement and changes of basis {#measurement}

**Learning goals.** Project a state onto an orthonormal basis, retain the conjugation and cancellations, calculate conditional states, and connect probabilities to repeated experiments.

## A basis specifies a question

An orthonormal basis $\{|b_0\rangle,|b_1\rangle\}$ satisfies
$\langle b_j|b_k\rangle=\delta_{jk}$. Projective measurement in this basis gives

$$p(b_j)=|\langle b_j|\psi\rangle|^2.$$

For an ideal rank-one measurement, outcome $b_j$ leaves the system in $|b_j\rangle$ up to global phase. The prior state determines probabilities; the observed result determines the conditioned state afterward.

Writing $|\psi\rangle=c_0|b_0\rangle+c_1|b_1\rangle$ and multiplying by $\langle b_j|$ gives $c_j=\langle b_j|\psi\rangle$. A basis change calculates new coordinates of the same vector. Physically applying a gate changes the vector; a gate followed by Z measurement can implement a different measurement basis.

## One state, three full calculations

Our recurring example is

$$|\psi\rangle=\frac{2|0\rangle+3i|1\rangle}{\sqrt{13}}.$$

Its norm squared is

$$\frac{(2\langle0|-3i\langle1|)(2|0\rangle+3i|1\rangle)}{13}
=\frac{4+6i(0)-6i(0)-9i^2}{13}
=\frac{4+9}{13}=1.$$

### Z basis

$$\begin{aligned}
\langle0|\psi\rangle
&=\frac{2\langle0|0\rangle+3i\langle0|1\rangle}{\sqrt{13}}\\
&=\frac{2(1)+3i(0)}{\sqrt{13}}=\frac2{\sqrt{13}},\\
p(0)&=\left(\frac2{\sqrt{13}}\right)^*
\left(\frac2{\sqrt{13}}\right)=\frac4{13}.
\end{aligned}$$

Similarly,

$$\langle1|\psi\rangle=\frac{2(0)+3i(1)}{\sqrt{13}}
=\frac{3i}{\sqrt{13}},$$
$$p(1)=\frac{(-3i)(3i)}{13}=\frac{-9i^2}{13}=\frac9{13}.$$

### X basis

$$\begin{aligned}
\langle+|\psi\rangle
&=\frac{(\langle0|+\langle1|)(2|0\rangle+3i|1\rangle)}{\sqrt{26}}\\
&=\frac{2\langle0|0\rangle+3i\langle0|1\rangle
+2\langle1|0\rangle+3i\langle1|1\rangle}{\sqrt{26}}\\
&=\frac{2+0+0+3i}{\sqrt{26}}=\frac{2+3i}{\sqrt{26}}.
\end{aligned}$$

The squared modulus is

$$p(+)=\frac{(2-3i)(2+3i)}{26}
=\frac{4+6i-6i-9i^2}{26}
=\frac{13}{26}=\frac12.$$

For the other outcome,

$$\begin{aligned}
\langle-|\psi\rangle
&=\frac{(\langle0|-\langle1|)(2|0\rangle+3i|1\rangle)}{\sqrt{26}}\\
&=\frac{2+0-0-3i}{\sqrt{26}}=\frac{2-3i}{\sqrt{26}},\\
p(-)&=\frac{(2+3i)(2-3i)}{26}=\frac12.
\end{aligned}$$

### Y basis

Forming the bra conjugates the imaginary coefficient:

$$\langle+i|=\frac{\langle0|-i\langle1|}{\sqrt2},
\qquad\langle-i|=\frac{\langle0|+i\langle1|}{\sqrt2}.$$

Now expand, including the terms that vanish:

$$\begin{aligned}
\langle+i|\psi\rangle
&=\frac{(\langle0|-i\langle1|)(2|0\rangle+3i|1\rangle)}{\sqrt{26}}\\
&=\frac{2\langle0|0\rangle+3i\langle0|1\rangle
-2i\langle1|0\rangle+(-i)(3i)\langle1|1\rangle}{\sqrt{26}}\\
&=\frac{2+0-0-3i^2}{\sqrt{26}}=\frac5{\sqrt{26}},\\
p(+i)&=\frac{25}{26}.
\end{aligned}$$

For the negative outcome,

$$\begin{aligned}
\langle-i|\psi\rangle
&=\frac{(\langle0|+i\langle1|)(2|0\rangle+3i|1\rangle)}{\sqrt{26}}\\
&=\frac{2+0+0+3i^2}{\sqrt{26}}=-\frac1{\sqrt{26}},\\
p(-i)&=\left(-\frac1{\sqrt{26}}\right)^*
\left(-\frac1{\sqrt{26}}\right)=\frac1{26}.
\end{aligned}$$

A negative amplitude is allowed; a negative probability is not. Each basis has its own normalized distribution:

| Basis | First outcome | Second outcome |
|:--|:--|:--|
| Z | $p(0)=4/13$ | $p(1)=9/13$ |
| X | $p(+)=1/2$ | $p(-)=1/2$ |
| Y | $p(+i)=25/26$ | $p(-i)=1/26$ |

Do not add all six probabilities. These are three different experimental choices on freshly prepared copies.

::: {.lab #lab-basis}
**Laboratory L03 — Projection workbench.** Start with coefficients $2$ and $3i$. Select Z, X, or Y; reveal the bra, expansion, cancellations, amplitude, and modulus squared. Change the coefficients and sample a chosen number of shots.
:::

## General formulas and a sign check

For normalized $\alpha|0\rangle+\beta|1\rangle$,

$$p(0)=|\alpha|^2,\quad p(1)=|\beta|^2,$$
$$p(\pm)=\frac{|\alpha\pm\beta|^2}{2}
=\frac12\pm\operatorname{Re}(\alpha^*\beta),$$
$$p(\pm i)=\frac{|\alpha\mp i\beta|^2}{2}
=\frac12\pm\operatorname{Im}(\alpha^*\beta).$$

Check the Y sign rather than memorizing it:

$$|\alpha-i\beta|^2
=(\alpha^*+i\beta^*)(\alpha-i\beta)
=|\alpha|^2+|\beta|^2+i(\beta^*\alpha-\alpha^*\beta).$$

If $\alpha^*\beta=u+iv$, the final term is
$i((u-iv)-(u+iv))=i(-2iv)=2v$. Divide by two to obtain $1/2+v$. Real coefficients give balanced Y probabilities; an imaginary relative coefficient need not.

## Consecutive measurements

Prepare $|+\rangle$, measure Z, then measure X. Z gives 0 or 1 equally often. Either conditioned state has balanced X probabilities. Therefore

$$\Pr(\text{final }+)
=\Pr(0)\Pr(+\mid0)+\Pr(1)\Pr(+\mid1)
=\frac12\frac12+\frac12\frac12=\frac12.$$

Without the intermediate Z measurement, the final X outcome would be $+$ with certainty. Ignoring a measurement record does not undo the physical interaction.

For a projector $P_m$, possibly of higher rank,

$$p(m)=\langle\psi|P_m|\psi\rangle,\qquad
|\psi_m\rangle=\frac{P_m|\psi\rangle}{\sqrt{p(m)}}.$$

Only outcomes with $p(m)>0$ can be conditioned upon. A projector onto a subspace can retain coherence inside that subspace. Parity checks in quantum error correction exploit this fact.

## Observables and expectation values

If outcomes have numerical values $a_m$, define $A=\sum_ma_mP_m$. Then

$$\langle A\rangle=\sum_ma_mp(m)=\langle\psi|A|\psi\rangle.$$

For Pauli Z, eigenvalues $+1,-1$ correspond to $|0\rangle,|1\rangle$. The ket label 0 is not an eigenvalue zero. Our example gives
$\langle Z\rangle=-5/13$, $\langle X\rangle=0$, and $\langle Y\rangle=12/13$.

Variance is $\langle A^2\rangle-\langle A\rangle^2$. Each Pauli squares to identity, so $\operatorname{Var}(Z)=1-\langle Z\rangle^2$. Incompatible observables lack a shared complete eigenbasis. Their uncertainty is not merely a poorly calibrated detector.

::: {.lab #lab-practice}
**Laboratory L04 — Measurement practice.** Generate an integer-coefficient state and requested outcome. Enter a fraction or decimal; request a hint or reveal the derivation step by step.
:::

## Exercises

:::: {.exercise #ex03-1}
**3.1.** Calculate all three-basis probabilities for $(3|0\rangle+4|1\rangle)/5$.

::: {.solution}

Z: $9/25,16/25$. X amplitudes: $7/(5\sqrt2),-1/(5\sqrt2)$, giving $49/50,1/50$. Y amplitudes: $(3\mp4i)/(5\sqrt2)$, giving $1/2,1/2$.
:::

::::

:::: {.exercise #ex03-2}
**3.2.** Replace $3i$ by $-3i$ in the recurring example. What changes?

::: {.solution}

Z and X probabilities remain unchanged. The imaginary part of $\alpha^*\beta$ changes sign, exchanging Y probabilities: $p(+i)=1/26$, $p(-i)=25/26$.
:::

::::

:::: {.exercise #ex03-3}
**3.3.** A Z measurement returns 1. What happens on an immediate repeated Z measurement, and if X measurement is inserted?

::: {.solution}

The conditioned state is $|1\rangle$, so direct repetition returns 1 with certainty. Inserting X leaves $|+\rangle$ or $|-\rangle$; either gives final Z result 1 with probability $1/2$.
:::

::::

:::: {.exercise #ex03-4}
**3.4.** Verify orthonormality of $|b_0\rangle=\cos\eta|0\rangle+\sin\eta|1\rangle$ and $|b_1\rangle=-\sin\eta|0\rangle+\cos\eta|1\rangle$. Find $p(b_0)$ for input $|0\rangle$.

::: {.solution}

Both norms are one and the overlap is $-\cos\eta\sin\eta+\sin\eta\cos\eta=0$. The projection is $\cos\eta$, giving probability $\cos^2\eta$.
:::

::::

:::: {.exercise #ex03-5}
**3.5.** Find the shot-noise standard deviation of the observed $+i$ fraction for the recurring example in 2,600 shots.

::: {.solution}

$\sqrt{(25/26)(1/26)/2600}\approx0.00377$. This describes independent sampling, not preparation or measurement bias.
:::

::::
