Simple Algorithm
Quantum Computing · Excited State · 22 min

Dirac Notation & State Vectors

Kets, bras, outer products and projectors: fluent bra-ket algebra.

Physicists rarely write column vectors. They write ∣ψ⟩\ket\psi, ⟨ϕ∣\bra\phi and ∣ψ⟩ ⁣⟨ϕ∣\ketbra{\psi}{\phi}, and the linear algebra does itself. Once you can read a ket, a bra and an outer product, most quantum calculations reduce to sliding brackets together.

What you’ll learn

  • Translate fluently between kets and bras and column and row vectors, including the antilinear rule for bras.
  • Build operators from outer products, read off matrix elements ⟨i|A|j⟩\mel{i}{A}{j}, and take adjoints in bra-ket form.
  • Use projectors and the completeness relation ∑i∣i⟩ ⁣⟨i∣=I\sum_i\dyad{i}=\id to compute probabilities and post-measurement states.
  • Write spectral decompositions and expectation values in Dirac notation.

Kets, bras and brackets

A ket ∣ψ⟩\ket\psi is a column vector. Its bra ⟨ψ∣\bra\psi is the conjugate-transposed row vector. A bra glued to a ket gives a number, the inner product:

∣ψ⟩=(αβ),⟨ψ∣=(α∗β∗),⟨ϕ∣ψ⟩=ϕ0∗α+ϕ1∗β.\ket\psi=\begin{pmatrix}\alpha\\ \beta\end{pmatrix},\qquad \bra\psi=\begin{pmatrix}\alpha^*&\beta^*\end{pmatrix},\qquad \braket{\phi|\psi}=\phi_0^*\alpha+\phi_1^*\beta.

Mathematically, ⟨ϕ∣\bra\phi is the linear functional ∣ψ⟩↦⟨ϕ∣ψ⟩\ket\psi\mapsto\braket{\phi|\psi}: a bra eats a ket and returns their overlap. Dirac's pun: a bra and a ket make a bracket.

The rule that trips everyone up: bras are antilinear. The bra of c∣ψ⟩c\ket\psi is c∗⟨ψ∣c^*\bra\psi, and the bra of α∣0⟩+β∣1⟩\alpha\ket0+\beta\ket1 is α∗⟨0∣+β∗⟨1∣\alpha^*\bra0+\beta^*\bra1. Hence ⟨ϕ∣ψ⟩∗=⟨ψ∣ϕ⟩\braket{\phi|\psi}^*=\braket{\psi|\phi} and ⟨ψ∣ψ⟩=∥ψ∥2≥0\braket{\psi|\psi}=\norm\psi^2\ge0.

Think first What is the bra of ∣+i⟩=12(∣0⟩+i∣1⟩)\ket{+i}=\tfrac1{\sqrt2}(\ket0+i\ket1), and what is ⟨+i∣+i⟩\braket{+i|+i}?

⟨+i∣=12(⟨0∣−i⟨1∣)\bra{+i}=\tfrac1{\sqrt2}(\bra0-i\bra1). Then ⟨+i∣+i⟩=12(⟨0∣0⟩+(−i)(i)⟨1∣1⟩)=12(1+1)=1\braket{+i|+i}=\tfrac12\big(\braket{0|0}+(-i)(i)\braket{1|1}\big)=\tfrac12(1+1)=1, using ⟨0∣1⟩=⟨1∣0⟩=0\braket{0|1}=\braket{1|0}=0. Forgetting the conjugate would give 12(1+i2)=0\tfrac12(1+i^2)=0.

Check your understanding

Compute ⟨+i∣−i⟩\braket{+i|-i}, where ∣±i⟩=12(∣0⟩±i∣1⟩)\ket{\pm i}=\tfrac1{\sqrt2}(\ket0\pm i\ket1).

  1. 11
  2. 00
  3. ii
  4. −1-1
Show the answer

B. 00

⟨+i∣−i⟩=12(⟨0∣−i⟨1∣)(∣0⟩−i∣1⟩)=12(1+(−i)(−i))=12(1−1)=0\braket{+i|-i}=\tfrac12(\bra0-i\bra1)(\ket0-i\ket1)=\tfrac12\big(1+(-i)(-i)\big)=\tfrac12(1-1)=0. The two YY eigenstates are orthogonal, as eigenvectors of a Hermitian operator with different eigenvalues must be.

Outer products build operators

Reverse the order and you get a matrix. The outer product ∣ψ⟩ ⁣⟨ϕ∣\ketbra{\psi}{\phi} is a column times a row, and it acts by sliding brackets together:

(∣ψ⟩ ⁣⟨ϕ∣)∣χ⟩=∣ψ⟩⟨ϕ∣χ⟩=⟨ϕ∣χ⟩ ∣ψ⟩.\big(\ketbra{\psi}{\phi}\big)\ket\chi=\ket\psi\braket{\phi|\chi}=\braket{\phi|\chi}\,\ket\psi.

It measures how much ∣χ⟩\ket\chi points along ∣ϕ⟩\ket\phi and outputs that much ∣ψ⟩\ket\psi. Every operator is a sum of outer products of basis vectors, weighted by its matrix elements:

A=∑i,j⟨i|A|j⟩ ∣i⟩ ⁣⟨j∣,X=∣0⟩ ⁣⟨1∣+∣1⟩ ⁣⟨0∣,Z=∣0⟩ ⁣⟨0∣−∣1⟩ ⁣⟨1∣A=\sum_{i,j}\mel{i}{A}{j}\,\ketbra{i}{j},\qquad X=\ketbra{0}{1}+\ketbra{1}{0},\qquad Z=\dyad{0}-\dyad{1}
Read ∣i⟩ ⁣⟨j∣\ketbra{i}{j} as "take ∣j⟩\ket j to ∣i⟩\ket i". Adjoints swap and conjugate: (c∣ψ⟩ ⁣⟨ϕ∣)†=c∗∣ϕ⟩ ⁣⟨ψ∣\big(c\ketbra{\psi}{\phi}\big)^\dagger=c^*\ketbra{\phi}{\psi}.
DerivationA gate from its action on a basis
  1. U=∣+i⟩ ⁣⟨0∣+∣−i⟩ ⁣⟨1∣U=\ketbra{+i}{0}+\ketbra{-i}{1}

    A unitary is fixed by where it sends a basis. Suppose U∣0⟩=∣+i⟩U\ket0=\ket{+i} and U∣1⟩=∣−i⟩U\ket1=\ket{-i}. Then

  2. U=12(∣0⟩+i∣1⟩)⟨0∣+12(∣0⟩−i∣1⟩)⟨1∣U=\tfrac1{\sqrt2}\big(\ket0+i\ket1\big)\bra0+\tfrac1{\sqrt2}\big(\ket0-i\ket1\big)\bra1

    Check: U∣0⟩=∣+i⟩⟨0∣0⟩+∣−i⟩⟨1∣0⟩=∣+i⟩U\ket0=\ket{+i}\braket{0|0}+\ket{-i}\braket{1|0}=\ket{+i}. For the matrix, expand the kets in the computational basis:

  3. U=12(11i−i)=(100i)12(111−1)=SHU=\tfrac1{\sqrt2}\begin{pmatrix}1&1\\ i&-i\end{pmatrix}=\begin{pmatrix}1&0\\0&i\end{pmatrix}\tfrac1{\sqrt2}\begin{pmatrix}1&1\\1&-1\end{pmatrix}=SH

    The coefficient of ∣i⟩ ⁣⟨j∣\ketbra{i}{j} is the entry UijU_{ij}:

  4. U†U=∑k,l∣ek⟩⟨fk∣fl⟩⟨el∣=∑k∣ek⟩ ⁣⟨ek∣=IU^\dagger U=\sum_{k,l}\ket{e_k}\braket{f_k|f_l}\bra{e_l}=\sum_k\dyad{e_k}=\id

    So "first HH, then SS" maps the ZZ basis onto the YY basis. In general ∑k∣fk⟩ ⁣⟨ek∣\sum_k\ketbra{f_k}{e_k} is the unitary taking one orthonormal basis to another:

Check your understanding

Simplify (∣0⟩ ⁣⟨1∣)2\big(\ketbra{0}{1}\big)^2.

  1. ∣0⟩ ⁣⟨1∣\ketbra{0}{1}
  2. ∣0⟩ ⁣⟨0∣\dyad{0}
  3. 00
  4. I\id
Show the answer

C. 00

∣0⟩ ⁣⟨1∣ ∣0⟩ ⁣⟨1∣=∣0⟩⟨1∣0⟩⟨1∣=0\ketbra{0}{1}\,\ketbra{0}{1}=\ket0\braket{1|0}\bra1=0, since ⟨1∣0⟩=0\braket{1|0}=0. The operator sends ∣1⟩→∣0⟩\ket1\to\ket0 and kills ∣0⟩\ket0, so applying it twice kills everything; as a matrix, (0100)2=0\begin{pmatrix}0&1\\0&0\end{pmatrix}^2=0.

Projectors, completeness and measurement

For a unit vector, Pψ=∣ψ⟩ ⁣⟨ψ∣P_\psi=\dyad\psi is the projector onto ∣ψ⟩\ket\psi: Pψ∣χ⟩=⟨ψ∣χ⟩∣ψ⟩P_\psi\ket\chi=\braket{\psi|\chi}\ket\psi keeps only the component along ∣ψ⟩\ket\psi, and Pψ2=Pψ=Pψ†P_\psi^2=P_\psi=P_\psi^\dagger. For any orthonormal basis the projectors add up to the identity, the completeness relation:

∑i∣i⟩ ⁣⟨i∣=I,e.g.∣0⟩ ⁣⟨0∣+∣1⟩ ⁣⟨1∣=∣+⟩ ⁣⟨+∣+∣−⟩ ⁣⟨−∣=I\sum_i\dyad{i}=\id,\qquad\text{e.g.}\quad \dyad{0}+\dyad{1}=\dyad{+}+\dyad{-}=\id
A resolution of the identity. Inserting it anywhere is the most useful move in quantum mechanics.

Insert it into ⟨ψ∣ψ⟩=1\braket{\psi|\psi}=1 and you get ∑i∣⟨i∣ψ⟩∣2=1\sum_i\abs{\braket{i|\psi}}^2=1: the outcome probabilities of a measurement in that basis add up to one. The Born rule and the collapse read

Pr⁡(i)=⟨ψ∣Pi∣ψ⟩=∣⟨i∣ψ⟩∣2,∣ψ⟩ ⟼ Pi∣ψ⟩Pr⁡(i).\Pr(i)=\bra\psi P_i\ket\psi=\abs{\braket{i|\psi}}^2,\qquad \ket\psi\ \longmapsto\ \frac{P_i\ket\psi}{\sqrt{\Pr(i)}}.
DerivationProbabilities in the X basis
  1. ∣+⟩ ⁣⟨+∣=12(∣0⟩+∣1⟩)(⟨0∣+⟨1∣)=12(∣0⟩ ⁣⟨0∣+∣0⟩ ⁣⟨1∣+∣1⟩ ⁣⟨0∣+∣1⟩ ⁣⟨1∣)=12(I+X)\dyad{+}=\tfrac12\big(\ket0+\ket1\big)\big(\bra0+\bra1\big)=\tfrac12\big(\dyad0+\ketbra{0}{1}+\ketbra{1}{0}+\dyad1\big)=\tfrac12(\id+X)

    Expand ∣+⟩ ⁣⟨+∣\dyad+ in the computational basis:

  2. Pr⁡(+)=⟨ψ∣12(I+X)∣ψ⟩=12(1+⟨X⟩ψ)\Pr(+)=\bra\psi\tfrac12(\id+X)\ket\psi=\tfrac12\big(1+\expval{X}_\psi\big)

    So the probability of outcome ++ is an expectation value:

  3. Pr⁡(+)=12(1+sin⁡θcos⁡φ)\Pr(+)=\tfrac12\big(1+\sin\theta\cos\varphi\big)

    For ∣ψ⟩=cos⁡θ2∣0⟩+eiφsin⁡θ2∣1⟩\ket\psi=\cos\tfrac\theta2\ket0+e^{i\varphi}\sin\tfrac\theta2\ket1, ⟨X⟩=sin⁡θcos⁡φ\expval{X}=\sin\theta\cos\varphi, the xx-coordinate of the Bloch vector:

Predict before you look

For ∣ψ⟩=cos⁡π6∣0⟩+sin⁡π6∣1⟩\ket\psi=\cos\tfrac\pi6\ket0+\sin\tfrac\pi6\ket1 (so θ=π/3\theta=\pi/3, φ=0\varphi=0), what is Pr⁡(+)\Pr(+) in an XX-basis measurement, in percent?

Show the answer

93 %

12(1+sin⁡π3)=12(1+0.866)≈0.933\tfrac12\big(1+\sin\tfrac\pi3\big)=\tfrac12(1+0.866)\approx0.933. Directly: ⟨+∣ψ⟩=12(cos⁡π6+sin⁡π6)≈0.966\braket{+|\psi}=\tfrac1{\sqrt2}\big(\cos\tfrac\pi6+\sin\tfrac\pi6\big)\approx0.966, whose square is ≈0.933\approx0.933.

Spectra and expectation values in bra-ket form

A Hermitian operator with non-degenerate eigenvalues is a weighted sum of projectors onto its eigenvectors, its spectral decomposition (with degeneracy, group equal eigenvalues into higher-rank projectors):

A=∑aa ∣a⟩ ⁣⟨a∣,f(A)=∑af(a) ∣a⟩ ⁣⟨a∣,⟨A⟩ψ=⟨ψ∣A∣ψ⟩=∑aa ∣⟨a∣ψ⟩∣2.A=\sum_aa\,\dyad{a},\qquad f(A)=\sum_af(a)\,\dyad{a},\qquad \expval{A}_\psi=\bra\psi A\ket\psi=\sum_aa\,\abs{\braket{a|\psi}}^2.

For example X=∣+⟩ ⁣⟨+∣−∣−⟩ ⁣⟨−∣X=\dyad+-\dyad-, so X\sqrt X, e−iθX/2e^{-i\theta X/2} or any other function of XX comes for free.

DiracMatrix languageType
∣ψ⟩\ket\psicolumn vector ψ\psivector
⟨ψ∣\bra\psirow vector ψ†\psi^\daggerdual vector
⟨ϕ∣ψ⟩\braket{\phi|\psi}ϕ†ψ\phi^\dagger\psinumber
∣ψ⟩ ⁣⟨ϕ∣\ketbra{\psi}{\phi}ψ ϕ†\psi\,\phi^\dagger (rank one)operator
⟨ϕ|A|ψ⟩\mel{\phi}{A}{\psi}ϕ†A ψ\phi^\dagger A\,\psinumber
⟨ϕ|A|ψ⟩∗=⟨ψ|A†|ϕ⟩\mel{\phi}{A}{\psi}^*=\mel{\psi}{A^\dagger}{\phi}(ϕ†Aψ)∗=ψ†A†ϕ(\phi^\dagger A\psi)^*=\psi^\dagger A^\dagger\phinumber
∣a⟩∣b⟩=∣ab⟩\ket a\ket b=\ket{ab}a⊗ba\otimes b (Kronecker product)vector of two systems
Juxtaposing two kets is a tensor product of two systems, never an inner product.
Think first What is Tr⁡(∣ψ⟩ ⁣⟨ϕ∣)\Tr\big(\ketbra{\psi}{\phi}\big)?

Insert completeness: Tr⁡(∣ψ⟩ ⁣⟨ϕ∣)=∑i⟨i∣ψ⟩⟨ϕ∣i⟩=∑i⟨ϕ∣i⟩⟨i∣ψ⟩=⟨ϕ∣ψ⟩\Tr\big(\ketbra{\psi}{\phi}\big)=\sum_i\braket{i|\psi}\braket{\phi|i}=\sum_i\braket{\phi|i}\braket{i|\psi}=\braket{\phi|\psi}. Note the order: the bra ends up on the left. In matrix language, Tr⁡(ψϕ†)=ϕ†ψ\Tr(\psi\phi^\dagger)=\phi^\dagger\psi.

Pitfalls, and where to go deeper

Think first Simplify (∣a⟩ ⁣⟨b∣)(∣c⟩ ⁣⟨d∣)\big(\ketbra{a}{b}\big)\big(\ketbra{c}{d}\big).

∣a⟩⟨b∣c⟩⟨d∣=⟨b∣c⟩ ∣a⟩ ⁣⟨d∣\ket a\braket{b|c}\bra d=\braket{b|c}\,\ketbra{a}{d}. The inner bracket collapses to a number; the outer ket and bra survive. For orthonormal basis vectors this is the matrix-unit rule EabEcd=δbcEadE_{ab}E_{cd}=\delta_{bc}E_{ad}.

Key takeaways

  • A ket is a column vector and its bra the conjugate-transposed row; bras are antilinear, (c∣ψ⟩)†=c∗⟨ψ∣(c\ket\psi)^\dagger=c^*\bra\psi.
  • Outer products ∣ψ⟩ ⁣⟨ϕ∣\ketbra{\psi}{\phi} are operators; A=∑ij⟨i|A|j⟩∣i⟩ ⁣⟨j∣A=\sum_{ij}\mel{i}{A}{j}\ketbra{i}{j}, and ∑k∣fk⟩ ⁣⟨ek∣\sum_k\ketbra{f_k}{e_k} maps one orthonormal basis to another.
  • Completeness ∑i∣i⟩ ⁣⟨i∣=I\sum_i\dyad i=\id: insert it to expand states, multiply matrices, compute traces and normalize probabilities.
  • Born rule in bra-ket form: Pr⁡(i)=⟨ψ∣Pi∣ψ⟩\Pr(i)=\bra\psi P_i\ket\psi, with post-measurement state Pi∣ψ⟩/Pr⁡(i)P_i\ket\psi/\sqrt{\Pr(i)}.
  • The spectral decomposition A=∑aa∣a⟩ ⁣⟨a∣A=\sum_aa\dyad a gives expectation values and functions of operators directly.

Check yourself

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

Question 1

What is the bra corresponding to the ket c∣ψ⟩c\ket\psi, for a complex number cc?

  1. c∗⟨ψ∣c^*\bra\psi
  2. c⟨ψ∣c\bra\psi
  3. ∣c∣⟨ψ∣\abs{c}\bra\psi
  4. ⟨ψ∣/c\bra\psi/c
Show the answer

A. c∗⟨ψ∣c^*\bra\psi

Taking the bra is conjugate transposition, which conjugates scalars: (c∣ψ⟩)†=c∗⟨ψ∣(c\ket\psi)^\dagger=c^*\bra\psi. This antilinearity is what makes ⟨ψ∣ψ⟩\braket{\psi|\psi} real and non-negative.

Question 2

Which operator is ∣+⟩ ⁣⟨0∣+∣−⟩ ⁣⟨1∣\ketbra{+}{0}+\ketbra{-}{1}?

  1. XX
  2. ZZ
  3. HH
  4. I\id
Show the answer

C. HH

It sends ∣0⟩→∣+⟩\ket0\to\ket+ and ∣1⟩→∣−⟩\ket1\to\ket-: the Hadamard gate. The coefficients of ∣i⟩ ⁣⟨j∣\ketbra{i}{j} give 12(111−1)\tfrac1{\sqrt2}\begin{pmatrix}1&1\\1&-1\end{pmatrix}.

Question 3

Simplify ∣0⟩ ⁣⟨+∣ ∣−⟩ ⁣⟨1∣\ketbra{0}{+}\,\ketbra{-}{1}.

  1. ∣0⟩ ⁣⟨1∣\ketbra{0}{1}
  2. 00
  3. 12∣0⟩ ⁣⟨1∣\tfrac12\ketbra{0}{1}
  4. ∣0⟩ ⁣⟨1∣−∣+⟩ ⁣⟨−∣\ketbra{0}{1}-\ketbra{+}{-}
Show the answer

B. 00

∣0⟩⟨+∣−⟩⟨1∣=0\ket0\braket{+|-}\bra1=0 because ⟨+∣−⟩=0\braket{+|-}=0. Slide the inner bracket together first; it is a number.

Question 4

A state ∣ψ⟩\ket\psi is measured in the orthonormal basis {∣bk⟩}\{\ket{b_k}\}. Which expression gives the probability of outcome kk?

  1. ⟨bk∣ψ⟩\braket{b_k|\psi}
  2. ⟨ψ∣ψ⟩⟨bk∣bk⟩\braket{\psi|\psi}\braket{b_k|b_k}
  3. Tr⁡∣bk⟩ ⁣⟨bk∣\Tr\dyad{b_k}
  4. ⟨ψ∣(∣bk⟩ ⁣⟨bk∣)∣ψ⟩\bra\psi\big(\dyad{b_k}\big)\ket\psi
Show the answer

D. ⟨ψ∣(∣bk⟩ ⁣⟨bk∣)∣ψ⟩\bra\psi\big(\dyad{b_k}\big)\ket\psi

⟨ψ∣Pk∣ψ⟩=⟨ψ∣bk⟩⟨bk∣ψ⟩=∣⟨bk∣ψ⟩∣2\bra\psi P_k\ket\psi=\braket{\psi|b_k}\braket{b_k|\psi}=\abs{\braket{b_k|\psi}}^2, the Born rule.

Question 5

What is ⟨+∣Z∣+⟩\bra{+}Z\ket{+}?

  1. 00
  2. 11
  3. −1-1
  4. 12\tfrac12
Show the answer

A. 00

Z∣+⟩=∣−⟩Z\ket+=\ket-, so ⟨+∣Z∣+⟩=⟨+∣−⟩=0\bra+Z\ket+=\braket{+|-}=0: outcomes ±1\pm1 are equally likely.

Go deeper

Further reading

  • P. A. M. Dirac, "A new notation for quantum mechanics," Math. Proc. Cambridge Phil. Soc. 35, 416 (1939).
  • M. A. Nielsen & I. L. Chuang, Quantum Computation and Quantum Information, §2.1–2.2 (Cambridge, 10th anniv. ed., 2010).
  • J. J. Sakurai & J. Napolitano, Modern Quantum Mechanics, ch. 1 (Cambridge, 3rd ed., 2020).