Skip to content

Orthonormal bases and Gram–Schmidt

Turn skewed arrows into perpendicular unit arrows by removing shadows, then read any point’s coordinates with dot products alone.

Helps to know firstProjections

Helps to know first
This topic

First, the picture

Skewed axes make coordinates hard; square axes make them two dot products. Watch two skewed arrows straighten up.

Two arrows made perpendicular

Shrink, take away the shadow, shrink again.

Two arrows, a_1 = (2, 1) and a_2 = (1, 2), not at a right angle.

coordinates along q_1, q_2
–
0.00 / 9.10 s
Describe this picture

The plane with two arrows, a1=(2,1)\mathbf{a}_1=(2,1) and a2=(1,2)\mathbf{a}_2=(1,2). First a1\mathbf{a}_1 shrinks to length 1, becoming q1=(0.894,0.447)\mathbf{q}_1=(0.894,0.447). Then the shadow of a2\mathbf{a}_2 on the line of q1\mathbf{q}_1, (1.6,0.8)(1.6,0.8), is drawn and taken away, leaving (−0.6,1.2)(-0.6,1.2), which slides to start at the origin and stands at a right angle to q1\mathbf{q}_1, marked. That leftover shrinks to length 1, becoming q2=(−0.447,0.894)\mathbf{q}_2=(-0.447,0.894). Finally the point (5,4)(5,4) appears, and its two coordinates along q1\mathbf{q}_1 and q2\mathbf{q}_2, 6.261 and 1.342, are drawn as dashed shadows and read out. The picture has no control.

Square axes are easier

Suppose you want the coordinates of the point (5,4)(5,4) along the arrows (2,1)(2,1) and (1,2)(1,2): how many of each make (5,4)(5,4)? You have to solve two equations, as in Two pictures of a linear system. The answer is 2 and 1, but it took a solve.

Along perpendicular arrows of length 1 there is nothing to solve. Each coordinate is the length of a shadow, from Projections, and a shadow on a unit arrow is one dot product. In the picture at the top of the page, the two coordinates of (5,4)(5,4) along q1\mathbf{q}_1 and q2\mathbf{q}_2 are

q1⋅(5,4)=145=6.261,q2⋅(5,4)=35=1.342.\mathbf{q}_1\cdot(5,4)=\tfrac{14}{\sqrt5}=6.261,\qquad \mathbf{q}_2\cdot(5,4)=\tfrac{3}{\sqrt5}=1.342.

Check with lengths: 6.2612+1.3422=39.2+1.8=416.261^2+1.342^2=39.2+1.8=41, which is 52+425^2+4^2. The right-angle rule holds because the axes are square.

Orthonormal

Arrows that are all at right angles to each other and all of length 1 are orthonormal. In symbols,

qp⋅qq=δpq={1p=q,0p≠q.\mathbf{q}_p\cdot\mathbf{q}_q=\delta_{pq}=\begin{cases}1&p=q,\\0&p\neq q.\end{cases}

The symbol δpq\delta_{pq}, with two subscripts, is the Kronecker delta. Signal processing’s impulse δ[n]\delta[n] has square brackets; the two are told apart that way. Put orthonormal arrows side by side as the columns of a matrix Q\mathbf{Q}, and the rule becomes Q⊤Q=I\mathbf{Q}^\top\mathbf{Q}=\mathbf{I}: entry (p,q)(p,q) of Q⊤Q\mathbf{Q}^\top\mathbf{Q} is qp⋅qq\mathbf{q}_p\cdot\mathbf{q}_q. Any vector is then the sum of its shadows:

x=∑k(qk⋅x) qk.\mathbf{x}=\sum_k(\mathbf{q}_k\cdot\mathbf{x})\,\mathbf{q}_k .

“Orthogonal” alone means at right angles; “orthonormal” adds length 1. The difference matters. The arrows (2,1)(2,1) and (−1,2)(-1,2) are at a right angle, but they are not of length 1.

Orthogonal matrices

A square matrix with orthonormal columns is called an orthogonal matrix, an old name that really means orthonormal columns. For it, Q⊤=Q−1\mathbf{Q}^\top=\mathbf{Q}^{-1}, and it keeps every length:

∥Qx∥2=x⊤Q⊤Q x=x⊤x=∥x∥2.\lVert\mathbf{Q}\mathbf{x}\rVert^2=\mathbf{x}^\top\mathbf{Q}^\top\mathbf{Q}\,\mathbf{x}=\mathbf{x}^\top\mathbf{x}=\lVert\mathbf{x}\rVert^2 .

From the top picture, Q=15[2−112]\mathbf{Q}=\tfrac1{\sqrt5}\begin{bmatrix}2&-1\\1&2\end{bmatrix}. It is the rotation by 26.57°, which is 0.4636 radians: its first column points at that angle. It sends (5,4)(5,4) to 15(6,13)\tfrac1{\sqrt5}(6,13), whose squared length is (36+169)/5=41(36+169)/5=41, the same as before.

Rotations and reflections are the orthogonal matrices of the plane. The reflection 15[344−3]\tfrac15\begin{bmatrix}3&4\\4&-3\end{bmatrix} is one too: its columns (3,4)/5(3,4)/5 and (4,−3)/5(4,-3)/5 have length 1 and are at a right angle.

Gram–Schmidt

What if the arrows you have are skewed? The Gram–Schmidt process straightens them one at a time, and the picture at the top of the page shows it in two dimensions:

  1. Shrink the first arrow to length 1: q1=a1/∥a1∥=(2,1)/5\mathbf{q}_1=\mathbf{a}_1/\lVert\mathbf{a}_1\rVert=(2,1)/\sqrt5.
  2. From the second arrow, take away its shadow on q1\mathbf{q}_1. The shadow is (q1⋅a2) q1=(1.6,0.8)(\mathbf{q}_1\cdot\mathbf{a}_2)\,\mathbf{q}_1=(1.6,0.8), and what is left, (−0.6,1.2)(-0.6,1.2), is at a right angle to q1\mathbf{q}_1.
  3. Shrink what is left to length 1. Its length is 1.8=1.342\sqrt{1.8}=1.342, so q2=(−1,2)/5\mathbf{q}_2=(-1,2)/\sqrt5.

For more arrows, each new arrow loses its shadows on all the q\mathbf{q}‘s found so far, then shrinks to length 1:

ak′=ak−∑p<k(qp⋅ak) qp,qk=ak′∥ak′∥.\mathbf{a}_k'=\mathbf{a}_k-\sum_{p<k}(\mathbf{q}_p\cdot\mathbf{a}_k)\,\mathbf{q}_p,\qquad \mathbf{q}_k=\frac{\mathbf{a}_k'}{\lVert\mathbf{a}_k'\rVert}.

Watch it in three dimensions with a1=(1,1,0)\mathbf{a}_1=(1,1,0), a2=(1,0,1)\mathbf{a}_2=(1,0,1) and a3=(0,1,1)\mathbf{a}_3=(0,1,1).

Making arrows perpendicular

Each arrow loses its shadows on the ones already straightened, then shrinks to length 1.

Three skewed arrows: a_1 = (1, 1, 0), a_2 = (1, 0, 1), a_3 = (0, 1, 1).

0.00 / 13.20 s
Describe this picture

A slowly turning view of three skewed arrows from the origin, a1=(1,1,0)\mathbf{a}_1=(1,1,0), a2=(1,0,1)\mathbf{a}_2=(1,0,1) and a3=(0,1,1)\mathbf{a}_3=(0,1,1), each in its own colour, with a faint plane through the first two. First a1\mathbf{a}_1 shrinks to length 1 and is renamed q1\mathbf{q}_1. Then the shadow of a2\mathbf{a}_2 on q1\mathbf{q}_1 is drawn as a dashed arrow, and taken away: a2\mathbf{a}_2 slides to the remainder (0.5,−0.5,1)(0.5,-0.5,1), a dotted ghost marking where it was, and shrinks to length 1 as q2\mathbf{q}_2. Then a3\mathbf{a}_3 casts two dashed shadows, on q1\mathbf{q}_1 and on q2\mathbf{q}_2, both are taken away, and the remainder (−23,23,23)(-\tfrac23,\tfrac23,\tfrac23) shrinks to q3\mathbf{q}_3. At the end three perpendicular unit arrows stand at the origin, with small squares marking the right angles. The plane through the first two arrows stays the same throughout. The step buttons move from stage to stage, forwards and backwards. After the clip, an Order toggle, “a1, a2, a3” or “a2, a1, a3”, swaps the first two arrows and runs the process again; the unit arrows come out different, starting with q1=(1,0,1)/2\mathbf{q}_1=(1,0,1)/\sqrt2.

The numbers are short. First, q1=(1,1,0)/2\mathbf{q}_1=(1,1,0)/\sqrt2. The shadow of a2\mathbf{a}_2 on it is (0.5,0.5,0)(0.5,0.5,0), which leaves (0.5,−0.5,1)(0.5,-0.5,1), of length 1.5=1.2247\sqrt{1.5}=1.2247, so q2=(1,−1,2)/6\mathbf{q}_2=(1,-1,2)/\sqrt6. The shadows of a3\mathbf{a}_3 on q1\mathbf{q}_1 and q2\mathbf{q}_2 are (0.5,0.5,0)(0.5,0.5,0) and 16(1,−1,2)\tfrac16(1,-1,2), which leaves (−23,23,23)(-\tfrac23,\tfrac23,\tfrac23), of length 1.15471.1547, so q3=(−1,1,1)/3\mathbf{q}_3=(-1,1,1)/\sqrt3. Check: q3⋅q1\mathbf{q}_3\cdot\mathbf{q}_1 is proportional to −1+1+0=0-1+1+0=0, and q3⋅q2\mathbf{q}_3\cdot\mathbf{q}_2 to −1−1+2=0-1-1+2=0.

Two things to notice. The order matters: start with a2\mathbf{a}_2 instead, and q1\mathbf{q}_1 becomes (1,0,1)/2(1,0,1)/\sqrt2, so all three results change. In two dimensions, starting with (1,2)(1,2) gives q1=(1,2)/5\mathbf{q}_1=(1,2)/\sqrt5. And the first kk new arrows always span the same line, plane or space as the first kk old ones. Gram–Schmidt changes the axes, never the space they cover.

If an arrow lies in the space of the earlier ones, nothing is left after its shadows are taken away. With (1,2)(1,2) and then (2,4)(2,4), the second leaves 0\mathbf{0}, which cannot be shrunk to length 1. That is how Gram–Schmidt notices dependent arrows.

Worked example

  1. Two arrows. (2,1)(2,1) and (1,2)(1,2) give q1=(0.894,0.447)\mathbf{q}_1=(0.894,0.447) and q2=(−0.447,0.894)\mathbf{q}_2=(-0.447,0.894).
  2. Coordinates. (5,4)(5,4) has coordinates 6.2616.261 and 1.3421.342 along them, and 39.2+1.8=4139.2+1.8=41.
  3. A test. Are (3,4)/5(3,4)/5 and (−4,3)/5(-4,3)/5 orthonormal? Yes: lengths 1, dot product (−12+12)/25=0(-12+12)/25=0.
  4. Lengths kept. ∥Qx∥=∥x∥\lVert\mathbf{Q}\mathbf{x}\rVert=\lVert\mathbf{x}\rVert for every orthogonal Q\mathbf{Q}.
  5. Three arrows. (1,1,0)(1,1,0), (1,0,1)(1,0,1), (0,1,1)(0,1,1) give (1,1,0)/2(1,1,0)/\sqrt2, (1,−1,2)/6(1,-1,2)/\sqrt6 and (−1,1,1)/3(-1,1,1)/\sqrt3.
  6. A Fourier basis. The four arrows (1,1,1,1)(1,1,1,1), (1,0,−1,0)(1,0,-1,0), (0,1,0,−1)(0,1,0,-1) and (1,−1,1,−1)(1,-1,1,-1) are at right angles, with squared lengths 4, 2, 2 and 4. So the coordinates of (4,0,0,0)(4,0,0,0) along them are 4/44/4, 4/24/2, 00 and 4/44/4: that is (1,2,0,1)(1,2,0,1). Scaled to length 1, the coordinates become (2, 2.828, 0, 2)(2,\ 2.828,\ 0,\ 2), and their squares add up to 16, the squared length of (4,0,0,0)(4,0,0,0).

Where you’ll meet this

The discrete Fourier transform and the discrete cosine transform are orthonormal bases, up to a scale. A JPEG image is cut into blocks of 64 pixels, and each block’s 64 coefficients are 64 dot products with the cosine basis; their squares add up to the block’s energy. A phone that turns its motion sensor’s readings into the screen’s directions uses an orthogonal matrix, so no length is distorted.

In signal processing · orthonormal bases

The discrete cosine transform is an orthonormal basis of eight cosines, and keeping its first few coefficients is a projection. In Fourier series coefficients, the coefficients are shadows on harmonics that are at right angles to each other, and Parseval’s relation is item 6 above: the squares of the coordinates add up to the squared length. Signal entries there count from 0, so the arrow (1,0,−1,0)(1,0,-1,0) is the samples x[0]x[0] to x[3]x[3].

Recording the shadows and lengths of Gram–Schmidt gives a factorisation of the matrix of arrows, the subject of QR factorisation.

Reference card

QuantityFormulaNotes
Orthonormalqp⋅qq=δpq\mathbf{q}_p\cdot\mathbf{q}_q=\delta_{pq}right angles, length 1
As a matrixQ⊤Q=I\mathbf{Q}^\top\mathbf{Q}=\mathbf{I}columns are the qk\mathbf{q}_k
Coordinatesx=∑k(qk⋅x) qk\mathbf{x}=\sum_k(\mathbf{q}_k\cdot\mathbf{x})\,\mathbf{q}_kone dot product each
Orthogonal matrixsquare Q\mathbf{Q} with Q⊤=Q−1\mathbf{Q}^\top=\mathbf{Q}^{-1}rotations, reflections
Lengths kept∥Qx∥=∥x∥\lVert\mathbf{Q}\mathbf{x}\rVert=\lVert\mathbf{x}\rVertand angles
Gram–Schmidtak′=ak−∑p<k(qp⋅ak)qp\mathbf{a}_k'=\mathbf{a}_k-\sum_{p<k}(\mathbf{q}_p\cdot\mathbf{a}_k)\mathbf{q}_p, qk=ak′/∥ak′∥\mathbf{q}_k=\mathbf{a}_k'/\lVert\mathbf{a}_k'\rVertorder matters
Dependent arrowak′=0\mathbf{a}_k'=\mathbf{0}no new direction

Keep reading with a free account.

By creating an account you accept the terms of use.

Sign in

Already have an account? Use the service you signed up with.

Or keep reading: get new lessons by email

Are you 13 or over?

Accounts and email updates are for people aged 13 or over. We keep only your answer, never your date of birth.

End of the lesson

Where to go next.

Phasorium

Account

Sign inKeep your place on any device

Subjects

Site

Look