Simple Algorithm
Quantum Computing · Excited State · 24 min

The Language: Linear Algebra

Complex vectors, inner products and bases: the grammar of quantum mechanics.

Every statement in quantum computing is, underneath, a statement about complex vectors and matrices. Master five ideas (vectors, inner products, bases, operators, eigenvalues) and the rest of the subject becomes readable.

What you’ll learn

  • Represent qubit states as complex unit vectors and translate between column vectors and Bloch angles.
  • Compute inner products and overlaps, and explain why the inner product conjugates its first argument.
  • Expand a state in different orthonormal bases and predict measurement probabilities in each.
  • Write operators as matrices, form adjoints, and recognize Hermitian and unitary matrices.
  • Derive that Hermitian matrices have real eigenvalues and orthogonal eigenvectors.

States are complex unit vectors

In the Ground State lessons a qubit was α∣0⟩+β∣1⟩\alpha\ket{0}+\beta\ket{1}. Strip away the notation and that is a column vector in the complex vector space C2\C^2:

∣0⟩=(10),∣1⟩=(01),∣ψ⟩=α∣0⟩+β∣1⟩=(αβ).\ket{0}=\begin{pmatrix}1\\0\end{pmatrix},\qquad \ket{1}=\begin{pmatrix}0\\1\end{pmatrix},\qquad \ket{\psi}=\alpha\ket{0}+\beta\ket{1}=\begin{pmatrix}\alpha\\ \beta\end{pmatrix}.

A system with dd perfectly distinguishable outcomes lives in Cd\C^d, and nn qubits live in C2n\C^{2^n}, a Hilbert space of dimension 2n2^n. Physical states are the unit vectors.

Complex numbers are essential, not decoration. Write each amplitude in polar form z=reiφz=re^{i\varphi} with modulus ∣z∣=z∗z\abs{z}=\sqrt{z^*z}. The moduli fix the probabilities; the phases fix how amplitudes interfere. Up to an unobservable global phase, every qubit vector is (cos⁡θ2, eiφsin⁡θ2)T\big(\cos\tfrac\theta2,\ e^{i\varphi}\sin\tfrac\theta2\big)^T.

Inner products: lengths, angles, overlaps

The inner product of u,v∈Cdu,v\in\C^d is

⟨u,v⟩=∑i=1dui∗ vi=u†v,\langle u,v\rangle=\sum_{i=1}^d u_i^*\,v_i=u^\dagger v,

where u†u^\dagger is the conjugate transpose, a row vector. (Dirac notation, next lesson, writes it ⟨u∣v⟩\braket{u|v}.) It is linear in vv, conjugate-linear in uu, satisfies ⟨u,v⟩∗=⟨v,u⟩\langle u,v\rangle^*=\langle v,u\rangle, and ⟨v,v⟩>0\langle v,v\rangle>0 for v≠0v\neq0. The norm is ∥v∥=⟨v,v⟩\norm{v}=\sqrt{\langle v,v\rangle}.

Think first Why the complex conjugate? Compute ∑ivivi\sum_i v_iv_i (no conjugate) for v=12(1, i)Tv=\tfrac{1}{\sqrt2}(1,\,i)^T.

12(1⋅1+i⋅i)=12(1−1)=0\tfrac12(1\cdot1+i\cdot i)=\tfrac12(1-1)=0: a non-zero vector would have "length" zero. With the conjugate, 12(1+(−i)(i))=1\tfrac12\big(1+(-i)(i)\big)=1. Conjugation makes ⟨v,v⟩=∑i∣vi∣2\langle v,v\rangle=\sum_i\abs{v_i}^2 real and positive.

Physically, ⟨u,v⟩\langle u,v\rangle is the amplitude for a system prepared in vv to be found in uu, and ∣⟨u,v⟩∣2\abs{\langle u,v\rangle}^2 is a probability. That only makes sense if it never exceeds 11 for unit vectors, which is the Cauchy–Schwarz inequality.

DerivationCauchy–Schwarz: overlaps are valid probabilities
  1. ∣⟨u,v⟩∣≤∥u∥ ∥v∥\abs{\langle u,v\rangle}\le\norm{u}\,\norm{v}

    Claim. Assume u≠0u\neq0 (otherwise both sides vanish).

  2. w=v−⟨u,v⟩⟨u,u⟩ u,⟨u,w⟩=0w=v-\frac{\langle u,v\rangle}{\langle u,u\rangle}\,u,\qquad \langle u,w\rangle=0

    Remove from vv its component along uu.

  3. 0≤⟨w,w⟩=⟨w,v⟩=⟨v,v⟩−⟨u,v⟩∗ ⟨u,v⟩⟨u,u⟩0\le\langle w,w\rangle=\langle w,v\rangle=\langle v,v\rangle-\frac{\langle u,v\rangle^*\,\langle u,v\rangle}{\langle u,u\rangle}

    Expand, using ⟨w,u⟩=0\langle w,u\rangle=0. Conjugate-linearity in the first slot produces ⟨u,v⟩∗\langle u,v\rangle^*.

  4. ∣⟨u,v⟩∣2≤⟨u,u⟩ ⟨v,v⟩\abs{\langle u,v\rangle}^2\le\langle u,u\rangle\,\langle v,v\rangle

    Rearrange. Equality holds iff w=0w=0, i.e. v∝uv\propto u. For unit vectors 0≤∣⟨u,v⟩∣2≤10\le\abs{\langle u,v\rangle}^2\le1, with 11 exactly when the states agree up to a phase.

Check your understanding

With ∣+⟩=12(1, 1)T\ket{+}=\tfrac1{\sqrt2}(1,\,1)^T and ∣+i⟩=12(1, i)T\ket{+i}=\tfrac1{\sqrt2}(1,\,i)^T, what is ∣⟨+, +i⟩∣2\abs{\langle +,\,+i\rangle}^2?

  1. 00
  2. 12\tfrac12
  3. 11
  4. 12\tfrac{1}{\sqrt2}
Show the answer

B. 12\tfrac12

⟨+,+i⟩=12(1⋅1+1⋅i)=1+i2\langle +,+i\rangle=\tfrac12(1\cdot1+1\cdot i)=\tfrac{1+i}{2}, with squared modulus 1+14=12\tfrac{1+1}{4}=\tfrac12. The states are 90∘90^\circ apart on the Bloch sphere: neither equal nor orthogonal.

Bases: one state, many coordinate systems

An orthonormal basis of Cd\C^d is a set {e1,…,ed}\{e_1,\dots,e_d\} with ⟨ei,ej⟩=δij\langle e_i,e_j\rangle=\delta_{ij}. Every vector expands uniquely, and the coefficients are inner products:

v=∑ici ei,ci=⟨ei,v⟩,∑i∣ci∣2=∥v∥2.v=\sum_i c_i\,e_i,\qquad c_i=\langle e_i,v\rangle,\qquad \sum_i\abs{c_i}^2=\norm{v}^2.

The last identity (Parseval) is why the probabilities ∣ci∣2\abs{c_i}^2 of a measurement in that basis add up to one.

BasisVectorsEigenbasis of
ZZ (computational)∣0⟩=(1,0)T\ket0=(1,0)^T, ∣1⟩=(0,1)T\ket1=(0,1)^TZZ
XX (Hadamard)∣±⟩=12(1,±1)T\ket\pm=\tfrac1{\sqrt2}(1,\pm1)^TXX
YY (circular)∣±i⟩=12(1,±i)T\ket{\pm i}=\tfrac1{\sqrt2}(1,\pm i)^TYY

Changing basis changes the coordinates, not the state. ∣+i⟩\ket{+i} has coordinates 12(1, i)\tfrac1{\sqrt2}(1,\,i) in the ZZ basis, (1+i2,1−i2)\big(\tfrac{1+i}{2},\tfrac{1-i}{2}\big) in the XX basis and (1,0)(1,0) in the YY basis. A measurement in a basis samples from the squared moduli of those coordinates.

Predict before you look

The state ∣ψ⟩=cos⁡π8∣0⟩+sin⁡π8∣1⟩\ket\psi=\cos\tfrac\pi8\ket0+\sin\tfrac\pi8\ket1 is measured in the XX basis. What is P(+)=∣⟨+,ψ⟩∣2P(+)=\abs{\langle +,\psi\rangle}^2, in percent?

Show the answer

85 %

⟨+,ψ⟩=12(cos⁡π8+sin⁡π8)\langle +,\psi\rangle=\tfrac1{\sqrt2}\big(\cos\tfrac\pi8+\sin\tfrac\pi8\big), so P(+)=12(1+2sin⁡π8cos⁡π8)=12(1+sin⁡π4)≈0.854P(+)=\tfrac12\big(1+2\sin\tfrac\pi8\cos\tfrac\pi8\big)=\tfrac12\big(1+\sin\tfrac\pi4\big)\approx0.854. This number, cos⁡2π8\cos^2\tfrac\pi8, reappears in the CHSH game and in optimal state discrimination.

Operators are matrices

A linear operator AA on Cd\C^d is fixed by what it does to a basis. Its matrix elements are Aij=⟨ei,Aej⟩A_{ij}=\langle e_i,Ae_j\rangle, so column jj holds the coordinates of AejAe_j. The adjoint A†A^\dagger (conjugate transpose, (A†)ij=Aji∗(A^\dagger)_{ij}=A_{ji}^*) is the unique operator with ⟨u,Av⟩=⟨A†u,v⟩\langle u,Av\rangle=\langle A^\dagger u,v\rangle for all u,vu,v. Two classes matter most:

  • Hermitian: A†=AA^\dagger=A. These are the observables: energy, spin components, the Pauli matrices.
  • Unitary: U†U=IU^\dagger U=\id, equivalently ⟨Uu,Uv⟩=⟨u,v⟩\langle Uu,Uv\rangle=\langle u,v\rangle for all u,vu,v. Unitaries preserve every overlap and map orthonormal bases to orthonormal bases. Every gate and every closed-system evolution is unitary.
MatrixHermitian?Unitary?Eigenvalues
X=(0110)X=\begin{pmatrix}0&1\\1&0\end{pmatrix}yesyes±1\pm1, eigenvectors ∣±⟩\ket\pm
Z=(100−1)Z=\begin{pmatrix}1&0\\0&-1\end{pmatrix}yesyes±1\pm1, eigenvectors ∣0⟩,∣1⟩\ket0,\ket1
H=12(111−1)H=\tfrac{1}{\sqrt2}\begin{pmatrix}1&1\\1&-1\end{pmatrix}yesyes±1\pm1
S=(100i)S=\begin{pmatrix}1&0\\0&i\end{pmatrix}noyes1, i1,\ i
X+ZX+Zyesno±2\pm\sqrt2
Hermitian ⇒\Rightarrow real eigenvalues. Unitary ⇒\Rightarrow eigenvalues on the unit circle. Both ⇒\Rightarrow eigenvalues ±1\pm1.
Check your understanding

Which matrix is unitary but not Hermitian?

  1. XX
  2. X+ZX+Z
  3. S=diag⁡(1,i)S=\diag(1,i)
  4. (1101)\begin{pmatrix}1&1\\0&1\end{pmatrix}
Show the answer

C. S=diag⁡(1,i)S=\diag(1,i)

S†=diag⁡(1,−i)≠SS^\dagger=\diag(1,-i)\neq S, yet S†S=IS^\dagger S=\id. Its eigenvalues 11 and ii lie on the unit circle, as a unitary's must, but ii is not real, so SS cannot be Hermitian.

Eigenvalues and expectation values

An eigenvector of AA satisfies Av=λvAv=\lambda v. For an observable, the eigenvalues are the possible outcomes and the eigenvectors the states that give them with certainty. Two facts make this consistent, each a three-line proof:

DerivationHermitian ⇒ real eigenvalues, orthogonal eigenvectors
  1. A=A†,Av=λv,Aw=μw,v,w≠0A=A^\dagger,\qquad Av=\lambda v,\qquad Aw=\mu w,\qquad v,w\neq0

    Setup.

  2. λ⟨v,v⟩=⟨v,Av⟩=⟨Av,v⟩=λ∗⟨v,v⟩\lambda\langle v,v\rangle=\langle v,Av\rangle=\langle Av,v\rangle=\lambda^*\langle v,v\rangle

    Move AA across using A†=AA^\dagger=A; the first slot is conjugate-linear. Since ⟨v,v⟩>0\langle v,v\rangle>0, λ=λ∗∈R\lambda=\lambda^*\in\R.

  3. μ⟨v,w⟩=⟨v,Aw⟩=⟨Av,w⟩=λ⟨v,w⟩\mu\langle v,w\rangle=\langle v,Aw\rangle=\langle Av,w\rangle=\lambda\langle v,w\rangle

    Same trick with two eigenvectors (λ\lambda is real).

  4. (μ−λ)⟨v,w⟩=0  ⇒  ⟨v,w⟩=0  if  λ≠μ(\mu-\lambda)\langle v,w\rangle=0\;\Rightarrow\;\langle v,w\rangle=0\ \text{ if }\ \lambda\neq\mu

    Distinct outcomes correspond to orthogonal, hence perfectly distinguishable, states.

In fact every Hermitian matrix has an orthonormal eigenbasis, so A=∑kλk vkvk†A=\sum_k\lambda_k\,v_kv_k^\dagger (the spectral theorem). The average outcome in state ψ\psi is the expectation value

⟨A⟩ψ=∑kλk ∣⟨vk,ψ⟩∣2=⟨ψ,Aψ⟩.\langle A\rangle_\psi=\sum_k\lambda_k\,\abs{\langle v_k,\psi\rangle}^2=\langle\psi,A\psi\rangle.

For ∣ψ⟩=cos⁡θ2∣0⟩+eiφsin⁡θ2∣1⟩\ket\psi=\cos\frac\theta2\ket0+e^{i\varphi}\sin\frac\theta2\ket1 this gives ⟨Z⟩=cos⁡θ\langle Z\rangle=\cos\theta and ⟨X⟩=sin⁡θcos⁡φ\langle X\rangle=\sin\theta\cos\varphi: the Bloch vector's coordinates are expectation values.

Key takeaways

  • Pure states of a dd-level system are unit vectors in Cd\C^d; complex phases are what make interference possible.
  • The inner product ⟨u,v⟩=∑iui∗vi\langle u,v\rangle=\sum_iu_i^*v_i gives lengths and overlaps; Cauchy–Schwarz makes ∣⟨u,v⟩∣2≤1\abs{\langle u,v\rangle}^2\le1 a valid probability.
  • In an orthonormal basis the coefficients are inner products, and their squared moduli are the measurement probabilities in that basis.
  • Hermitian matrices (observables) have real eigenvalues and orthonormal eigenbases; unitaries (gates) preserve every inner product.
  • Expectation values ⟨ψ,Aψ⟩=∑kλk∣⟨vk,ψ⟩∣2\langle\psi,A\psi\rangle=\sum_k\lambda_k\abs{\langle v_k,\psi\rangle}^2 connect matrices to experiments.

Check yourself

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

Question 1

Why does the inner product conjugate its first argument, ⟨u,v⟩=∑iui∗vi\langle u,v\rangle=\sum_iu_i^*v_i?

  1. So that it is linear in both arguments
  2. It is a pure convention with no consequences
  3. So that ⟨v,v⟩=∑i∣vi∣2\langle v,v\rangle=\sum_i\abs{v_i}^2 is real, non-negative, and zero only for v=0v=0
  4. So that unitary matrices have real eigenvalues
Show the answer

C. So that ⟨v,v⟩=∑i∣vi∣2\langle v,v\rangle=\sum_i\abs{v_i}^2 is real, non-negative, and zero only for v=0v=0

Without the conjugate, (1,i)T(1,i)^T would have "squared length" 1+i2=01+i^2=0. Conjugation turns ⟨v,v⟩\langle v,v\rangle into a sum of squared moduli, so it defines a genuine length and overlaps behave like probabilities.

Question 2

What are the coordinates of ∣+⟩\ket+ in the orthonormal basis {∣+⟩,∣−⟩}\{\ket+,\ket-\}?

  1. (12,12)(\tfrac1{\sqrt2},\tfrac1{\sqrt2})
  2. (1,0)(1,0)
  3. (12,−12)(\tfrac1{\sqrt2},-\tfrac1{\sqrt2})
  4. (0,1)(0,1)
Show the answer

B. (1,0)(1,0)

c+=⟨+,+⟩=1c_+=\langle +,+\rangle=1 and c−=⟨−,+⟩=0c_-=\langle -,+\rangle=0. In its own basis a state is a basis vector; (12,12)(\tfrac1{\sqrt2},\tfrac1{\sqrt2}) are its coordinates in the ZZ basis.

Question 3

For a unitary UU and any vectors u,vu,v, which quantity is guaranteed unchanged when u,vu,v are replaced by Uu,UvUu,Uv?

  1. The overlap ⟨u,v⟩\langle u,v\rangle
  2. The coordinates of uu in the computational basis
  3. The probability of outcome 00 in a ZZ measurement of uu
  4. The expectation value ⟨u,Zu⟩\langle u,Zu\rangle
Show the answer

A. The overlap ⟨u,v⟩\langle u,v\rangle

⟨Uu,Uv⟩=⟨u,U†Uv⟩=⟨u,v⟩\langle Uu,Uv\rangle=\langle u,U^\dagger Uv\rangle=\langle u,v\rangle. Unitaries preserve overlaps (hence normalization and orthogonality) but change coordinates and statistics in a fixed basis; that is how gates do anything at all.

Question 4

A Hermitian 3×33\times3 matrix has three distinct eigenvalues. Which statement is guaranteed?

  1. Its eigenvalues are −1-1, 00 and 11
  2. Its eigenvalues are real and its eigenvectors mutually orthogonal
  3. It is unitary
  4. Its eigenvectors are the computational basis vectors
Show the answer

B. Its eigenvalues are real and its eigenvectors mutually orthogonal

Real eigenvalues and orthogonal eigenvectors for distinct eigenvalues are exactly the two facts derived in this lesson.

Question 5

For ∣ψ⟩=cos⁡π6∣0⟩+sin⁡π6∣1⟩\ket\psi=\cos\tfrac\pi6\ket0+\sin\tfrac\pi6\ket1, what is ⟨Z⟩ψ\langle Z\rangle_\psi?

  1. 32\tfrac{\sqrt3}{2}
  2. 34\tfrac34
  3. 14\tfrac14
  4. 12\tfrac12
Show the answer

D. 12\tfrac12

⟨Z⟩=P(0)−P(1)=cos⁡2π6−sin⁡2π6=34−14=12\langle Z\rangle=P(0)-P(1)=\cos^2\tfrac\pi6-\sin^2\tfrac\pi6=\tfrac34-\tfrac14=\tfrac12, matching ⟨Z⟩=cos⁡θ\langle Z\rangle=\cos\theta with θ=π/3\theta=\pi/3.

Go deeper

Further reading

  • M. A. Nielsen & I. L. Chuang, Quantum Computation and Quantum Information, §2.1 (Cambridge, 10th anniv. ed., 2010).
  • S. Axler, Linear Algebra Done Right, chs. 6–7 (Springer, 3rd ed., 2015).
  • R. de Wolf, Quantum Computing: Lecture Notes (arXiv:1907.09415).
  • M.-O. Renou et al., "Quantum theory based on real numbers can be experimentally falsified," Nature (2021).