---
title: Dirac notation, commutators and the generalized uncertainty principle
heading: Kets, bras, and why some pairs of quantities can't both be sharp
eyebrow: B10 · Lesson 17 · Dirac notation, commutators and the generalized uncertainty principle
xp: 45
---

::: hook
Dirac's notation writes a state as a **ket** $|\psi\rangle$ without committing to a basis, so the same equations cover wave functions, spins and qubits. It makes the structure of the last two lessons easy to read, and it's the language of every quantum-computing paper and datasheet. With it comes the most useful single tool in the formalism, the **commutator** $[\hat A, \hat B] = \hat A\hat B - \hat B\hat A$. Whether two operators commute decides whether their quantities can both be sharp, gives a lower bound on their uncertainties, and tells you which quantities are conserved.
:::

::: play
- The stems are the uncertainty product $\sigma_x\sigma_p$, in units of ħ, for each energy eigenstate: the infinite well's and the harmonic oscillator's, with the bound ½ drawn as a dashed line.
- Every state sits above the bound. Only the oscillator's ground state reaches it, at exactly ½ (n = 0, just off the left edge).
- Higher states have more nodes, so both their position spread and their momentum spread grow. The marker picks one state for the readouts.
:::
:::

```sim plot
view: graph
x: n = 1..8
y: y = 0..9
slider: N = 1..8 step 1 = 1
plot: sqrt(n^2*pi^2/3 - 2)/2 | stems | label: well, σₓσₚ/ħ
plot: n + 0.5 | stems | color: ch2 | label: oscillator, σₓσₚ/ħ
plot: 0.5 | dashed | label: bound ½
marker: n = N | label: state
readout: well, σₓσₚ/ħ = sqrt(N^2*pi^2/3 - 2)/2
readout: oscillator, σₓσₚ/ħ = N + 0.5
```

::: predict
## The commutator of position and momentum is $[\hat x, \hat p] = i\hbar$. What does the generalized uncertainty principle give for $\sigma_x\sigma_p$?

- [ ] $\ge \hbar$
- [x] $\ge \frac\hbar2$
- [ ] $= 0$
- [ ] $\ge 2\hbar$

::: reveal
$\sigma_A\sigma_B \ge \frac12\lvert\langle[\hat A, \hat B]\rangle\rvert = \frac12\lvert i\hbar\rvert = \frac\hbar2$. Heisenberg's relation from lesson 3 is one case of a general theorem: any two observables that don't commute have a joint lower bound on their spreads.
:::
:::

::: nameit
## Kets and bras

- A state is a ket $|\psi\rangle$; in a basis $|n\rangle$ its components are $\langle n|\psi\rangle$, and in position they're $\psi(x) = \langle x|\psi\rangle$.
- The **bra** $\langle\phi|$ is the conjugate transpose, so $\langle\phi|\psi\rangle$ is the inner product.
- $|\psi\rangle\langle\phi|$ is an operator; $\hat P_n = |n\rangle\langle n|$ projects onto $|n\rangle$.
- Completeness: $\sum_n|n\rangle\langle n| = \hat 1$. Inserting it anywhere expands in that basis.
- The probability that a measurement asking "are you in $|\phi\rangle$?" says yes is $\lvert\langle\phi|\psi\rangle\rvert^2$.

## Commutators

$$[\hat x, \hat p] = i\hbar, \qquad [\hat A, \hat B\hat C] = [\hat A, \hat B]\hat C + \hat B[\hat A, \hat C]$$

so, for example, $[\hat x, \hat p^2] = 2i\hbar\hat p$ and $[\hat p, f(\hat x)] = -i\hbar f'(\hat x)$.

## The generalized uncertainty principle

For any two observables, in any state,

$$\sigma_A\sigma_B \ge \frac12\left\lvert\langle[\hat A, \hat B]\rangle\right\rvert$$

It follows from the Schwarz inequality. Commuting observables have no such bound, and they share a basis of eigenvectors (they're compatible).

## Time evolution and conservation

$$\frac{d\langle Q\rangle}{dt} = \frac i\hbar\langle[\hat H, \hat Q]\rangle + \left\langle\frac{\partial\hat Q}{\partial t}\right\rangle$$

A quantity whose operator commutes with $\hat H$ (and doesn't depend on time) is conserved. With Q = x and Q = p this gives Ehrenfest's theorem.

## Energy and time

Taking A = H gives $\sigma_H\,\Delta t \ge \frac\hbar2$, where Δt is how long it takes some observable to change by one standard deviation. A state with a spread of energies $\sigma_H$ changes on a time scale of about $\hbar/\sigma_H$; for an equal superposition of two levels a gap ΔE apart, the state becomes orthogonal to its start after $\frac{h}{2\Delta E}$.
:::

::: example
## Find $\sigma_x\sigma_p$ for the infinite well's ground state.

::: solution
1. **Position spread.** For a well of width a, $\langle x^2\rangle = a^2\left(\frac13 - \frac{1}{2\pi^2}\right)$ and $\langle x\rangle = \frac a2$, so
   $$\sigma_x^2 = a^2\left(\frac{1}{12} - \frac{1}{2\pi^2}\right)$$
2. **Momentum spread.** $\langle p\rangle = 0$, and
   $$\begin{aligned} \langle p^2\rangle &= 2mE_1 \\ &= \frac{\pi^2\hbar^2}{a^2} \end{aligned}$$
3. **The product.**
   $$\begin{aligned} \sigma_x\sigma_p &= \hbar\pi\sqrt{\frac{1}{12} - \frac{1}{2\pi^2}} \\ &= \frac\hbar2\sqrt{\frac{\pi^2}{3} - 2} \\ &= 0.568\hbar \end{aligned}$$
4. **Compare with the bound.** It's above the bound of ħ/2, as a sine bump isn't a Gaussian.

**Answer:** $\sigma_x\sigma_p = 0.568\hbar$.
:::
:::

::: example
## A qubit is in $\frac{1}{\sqrt2}(|0\rangle + e^{i\phi}|1\rangle)$. What's the probability that it's found in $\frac{1}{\sqrt2}(|0\rangle + |1\rangle)$?

::: solution
1. **Overlap.**
   $$\langle +|\psi\rangle = \frac12(1 + e^{i\phi})$$
2. **Probability.**
   $$\begin{aligned} \lvert\langle +|\psi\rangle\rvert^2 &= \frac{2 + 2\cos\phi}{4} \\ &= \cos^2\frac\phi2 \end{aligned}$$
3. **What the phase does.** The relative phase, invisible to a measurement in the $|0\rangle, |1\rangle$ basis, decides the result in this one. It's the same as a Mach–Zehnder interferometer, where the path difference shows up as which port the light leaves by.

**Answer:** the probability is $\cos^2\frac\phi2$.
:::
:::

::: example
## The ground state of an infinite well gives $\sigma_x\sigma_p = 0.568\hbar$. What do states 2 and 3 give?

::: solution
1. **The product for state n.**
   $$\sigma_x\sigma_p = \frac\hbar2\sqrt{\frac{n^2\pi^2}{3} - 2}$$
2. **Put in n = 2 and 3.** That gives 1.670ħ for n = 2 and 2.627ħ for n = 3.
3. **Why they grow.** Only Gaussian states reach the minimum ħ/2; the box's ground state comes within 14%, and higher states move further away because their momentum spread grows with n while their position spread stays about $\frac{L}{\sqrt{12}}$.

**Answer:** state 2 gives 1.670ħ and state 3 gives 2.627ħ.
:::
:::

::: check
given: n = 2 | 3 | 5
answer: sqrt(n^2*pi^2/3 - 2)/2
tolerance: 0.1%

## What's $\sigma_x\sigma_p$, in units of ħ, for state n = {n} of an infinite well?

::: right
Right. $\frac12\sqrt{\frac{n^2\pi^2}{3} - 2}$ = {answer}.
:::

::: misses
- [n + 0.5] That's the harmonic oscillator's.
- [any] Not yet. $\sigma_x^2 = a^2\left(\frac{1}{12} - \frac{1}{2n^2\pi^2}\right)$ and $\sigma_p = \frac{n\pi\hbar}{a}$.
:::
:::

::: check
given: p = 30 | 70 | 140
answer: cos(p°/2)^2
tolerance: 0.1%

## A qubit $\frac{1}{\sqrt2}(|0\rangle + e^{i\phi}|1\rangle)$ with φ = {p}°: what's the probability of finding it in $\frac{1}{\sqrt2}(|0\rangle + |1\rangle)$?

::: right
Right. $\cos^2\frac\phi2$ = {answer}.
:::

::: misses
- [cos(p°)^2] Use half the phase: $\lvert 1 + e^{i\phi}\rvert^2 = 4\cos^2\frac\phi2$.
- [0.5] The phase matters in this basis.
- [any] Not yet. $\lvert\langle +|\psi\rangle\rvert^2$.
:::
:::

::: check
given: d = 5 | 20 | 100
answer: 4.1357/(2*d)
unit: ps
tolerance: 0.5%

## An equal superposition of two levels {d} meV apart: how long until the state is orthogonal to where it started?

::: right
Right. $\frac{h}{2\Delta E}$ = {answer} ps.
:::

::: misses
- [4.1357/d] That's a full period of the beat; orthogonal comes halfway.
- [0.6582/(2*d)] Use h (4.136 meV·ps), not ħ.
- [any] Not yet. The relative phase must reach π: $\frac{\Delta E\,t}{\hbar} = \pi$.
:::
:::

::: check
given: t = 0 | 30 | 60
answer: 0.25*cos(t°)
tolerance: 0.1%

## A spin-½ points at {t}° from the z axis. What lower bound does the generalized uncertainty principle put on $\sigma_{S_x}\sigma_{S_y}$, in units of ħ²? ($[\hat S_x, \hat S_y] = i\hbar\hat S_z$ and $\langle S_z\rangle = \frac\hbar2\cos\theta$.)

::: right
Right. $\frac12\lvert\langle i\hbar S_z\rangle\rvert = \frac{\hbar^2}{4}\cos\theta$, so {answer}ħ².
:::

::: misses
- [0.5*cos(t°)] The bound has a factor ½ in front of $\lvert\langle[\hat A, \hat B]\rangle\rvert$.
- [any] Not yet. $\sigma_A\sigma_B \ge \frac12\lvert\langle[\hat A, \hat B]\rangle\rvert$.
:::
:::

::: check
given: k = 2 | 5 | 12
answer: 0.0762*k
unit: eV·nm
tolerance: 0.5%

## A free-electron packet has $\langle p\rangle = \hbar k_0$ with $k_0$ = {k} nm⁻¹. Using $[\hat H, \hat x] = -\frac{i\hbar}{m}\hat p$, what's $\lvert\langle[\hat H, \hat x]\rangle\rvert$, in eV·nm?

::: right
Right. $\frac{\hbar}{m}\langle p\rangle = \frac{\hbar^2k_0}{m} = 2 \times 0.0381k_0$ = {answer}, and dividing by ħ gives the packet's speed.
:::

::: misses
- [0.0381*k] $\frac{\hbar^2}{m}$ is twice $\frac{\hbar^2}{2m}$.
- [any] Not yet. $\frac{\hbar^2}{m} = 0.0762$ eV·nm².
:::
:::

::: check
kind: choice

## A quantity Q is conserved in every state when

- [x] $\hat Q$ commutes with $\hat H$ (and doesn't depend on time)
- [ ] $\hat Q$ is Hermitian
- [ ] $\hat Q$ commutes with $\hat x$
- [ ] the state is normalized

::: misses
- [2] All observables are Hermitian; most aren't conserved.
- [3] That makes it a function of position, which needn't be constant.
- [4] Normalization is always assumed.
:::
:::

::: check
kind: parts
given: n = 1 | 2 | 4

## A particle is in state {n} of an infinite well.

::: part
answer: 0.5*sqrt(n^2*pi^2/3 - 2)
unit: ħ
tolerance: 0.5%

### What is $\sigma_x\sigma_p$, in units of ħ?

::: misses
- [0.5] Only Gaussian states reach the minimum.
- [any] $\frac\hbar2\sqrt{\frac{n^2\pi^2}{3} - 2}$.
:::
:::

::: part
answer: n*pi
unit: ħ/L
tolerance: 0.5%

### What is $\sigma_p$, in units of ħ/L?

::: misses
- [any] $\langle p\rangle = 0$ and $\langle p^2\rangle = \left(\frac{n\pi\hbar}{L}\right)^2$.
:::
:::
:::

::: check
kind: derivation
vars: n = 1..10

## State n of an infinite well of width L (take L = 1).

::: step
answer: sqrt(1/12 - 1/(2*n^2*pi^2))

### What is $\sigma_x$?
:::

::: step
answer: 0.5*sqrt(n^2*pi^2/3 - 2)

### What is $\sigma_x\sigma_p$ in units of ħ?
:::

::: right
Right. For large n, $\sigma_x \to \frac{L}{\sqrt{12}}$, the spread of a uniform distribution: the classical limit.
:::
:::

::: explain
## Why can't two observables whose operators don't commute both have definite values?

::: model
A definite value of an observable means the state is an eigenvector of its operator. If two operators shared every eigenvector, then applying them in either order to any state written in that basis would give the same thing, and they'd commute. So operators that don't commute can't share a complete set of eigenvectors, and in general a state that's sharp for one is a mixture of eigenvectors of the other, with a spread of results. The generalized uncertainty principle makes this quantitative: the product of the two spreads is at least half the size of the commutator's expectation value. For position and momentum the commutator is the constant iħ, so no state escapes the bound.
:::
:::

::: practice

::: check
given: n = 1..10 int
answer: sqrt(n^2*pi^2/3 - 2)/2
tolerance: 0.1%

## Well state n = {n}: $\sigma_x\sigma_p$ in units of ħ?

::: misses
- [any] $\frac12\sqrt{\frac{n^2\pi^2}{3} - 2}$.
:::
:::

::: check
given: p = 30 | 45 | 60 | 120 | 150 | 170
answer: cos(p°/2)^2
tolerance: 0.1%

## Probability of $|+\rangle$ for relative phase {p}°?

::: misses
- [any] $\cos^2\frac\phi2$.
:::
:::

::: check
given: d = 1 | 2 | 5 | 10 | 20 | 40
answer: 4.1357/(2*d)
unit: ps
tolerance: 0.5%

## Time to orthogonal for levels {d} meV apart?

::: misses
- [any] $\frac{h}{2\Delta E}$.
:::
:::
:::
