Orthogonal matrices and inner product spaces, visually

One dot product gives you length, angle, and right angles. If your base arrows are at right angles and have length 1, you read any coordinate with a single dot product, and the matrix made from those arrows never changes lengths. Turn the base and drag the vector.

Short answer. An orthogonal matrix is a square matrix whose columns are at right angles to each other and all have length 1. As a formula, QᵀQ = I. So undoing it only takes a transpose (Q⁻¹ = Qᵀ), and it never changes lengths or angles (it turns or flips). An inner product space is a vector space with a dot product rule chosen, so that lengths and angles make sense in it.

v = (, )

Use the angle slider to turn q₁ and q₂ together, and drag the tip of the black arrow v or type its numbers. The gray dashed lines are dropped from v straight onto the two axes. The thick colored bands are the shadows, which are the coordinates c₁ and c₂. "Flip" points q₂ the other way.

Definitions

The text below uses arrows in the plane, but the definitions are the same in n dimensions. V is a real vector space.

inner product, inner product space
Suppose a rule gives a real number ⟨u, v⟩ for any two vectors u, v in V. If the rule satisfies the three conditions below for all u, v, w ∈ V and all real numbers a, b, it is called an inner product on V, and V with an inner product is called an inner product space. The dot product u·v = u₁v₁ + … + uₙvₙ on ℝⁿ also satisfies them.

⟨𝐮,𝐯⟩=⟨𝐯,𝐮⟩

⟨a𝐮+b𝐰,𝐯⟩=a⟨𝐮,𝐯⟩+b⟨𝐰,𝐯⟩

𝐯≠0⟹⟨𝐯,𝐯⟩>0

norm, orthogonal
In an inner product space, the norm (length) of a vector v is given by the left formula below. If the inner product of two vectors u, v is 0, u and v are called orthogonal.

‖𝐯‖=⟨𝐯,𝐯⟩,𝐮⟂𝐯⟺⟨𝐮,𝐯⟩=0

orthonormal set
A set of vectors {q₁, …, qₖ} is called an orthogonal set if every two different vectors in it are orthogonal. An orthogonal set in which every vector has norm 1 is called an orthonormal set.

⟨𝐪i,𝐪j⟩=0(i≠j),‖𝐪i‖=1(i=1,…,k)

orthonormal basis
A basis of V that is an orthogonal set is called an orthogonal basis, and a basis that is an orthonormal set is called an orthonormal basis. If q₁, …, qₙ is an orthonormal basis, every vector v in V can be written as below. So the i-th coordinate is ⟨v, qᵢ⟩.

𝐯=⟨𝐯,𝐪1⟩𝐪1+⟨𝐯,𝐪2⟩𝐪2+⋯+⟨𝐯,𝐪n⟩𝐪n

orthogonal matrix
A real n×n matrix Q that satisfies the equation below is called an orthogonal matrix. Q is an orthogonal matrix exactly when its columns form an orthonormal basis of ℝⁿ. Then Q has an inverse, and Q⁻¹ = Qᵀ.

Q𝖳Q=I

1. Three things a dot product gives you: length, angle, right angle

The dot product of two vectors multiplies matching entries and adds them up: u·v = u₁v₁ + u₂v₂. The dot product page covers it. Here we only need the fact that one dot product measures three things.

What it measuresFormulaExample: u = (0.6, 0.8), v = (1, 3)
Length‖v‖ = √(v·v)‖v‖ = √(1 + 9) = √10 ≈ 3.16
Anglecos θ = u·v ÷ (‖u‖ ‖v‖)u·v = 0.6 + 2.4 = 3 and ‖u‖ = 1, so cos θ = 3 ÷ 3.16 ≈ 0.95
Right angleu·v = 0(0.6, 0.8)·(−0.8, 0.6) = −0.48 + 0.48 = 0

2. Inner product space: a vector space with a dot product chosen

Length and angle are not only for arrows. In a real vector space, any rule that takes two things and gives one number is called an inner product if it follows the three rules below. A vector space with such a rule chosen is an inner product space. Then length, angle, and right angle work there with the same formulas as above.

Functions are vectors too. For continuous functions f and g on an interval, define ⟨f, g⟩ = ∫ f(x) g(x) dx (multiply them and add up over the whole interval). Now functions can be at right angles. For example, on −π to π the inner product of sin x and cos x is 0.

3. Orthonormal basis: read coordinates with dot products

A basis is a set of base arrows that lets you write every vector as "how many of each to add up" (basis). If the base arrows are at right angles to each other, it is an orthogonal basis. If they also all have length 1, it is an orthonormal basis. The q₁ and q₂ in the lab are an orthonormal basis.

With an ordinary basis you have to solve a system of equations to get the coordinates. With an orthonormal basis one dot product is enough: cᵢ = v·qᵢ

Why: take v = c₁q₁ + c₂q₂ and dot both sides with q₁. You get v·q₁ = c₁(q₁·q₁) + c₂(q₂·q₁) = c₁×1 + c₂×0 = c₁. Length 1 keeps the first term as c₁, and the right angle wipes out the second. In the picture, c₁ is the length of the shadow v casts on the q₁ axis.

Work it by hand

  1. q₁ = (0.6, 0.8), q₂ = (−0.8, 0.6), v = (1, 3). This is the starting screen of the lab.
  2. c₁ = v·q₁ = 1×0.6 + 3×0.8 = 0.6 + 2.4 = 3
  3. c₂ = v·q₂ = 1×(−0.8) + 3×0.6 = −0.8 + 1.8 = 1
  4. Add back: 3×(0.6, 0.8) + 1×(−0.8, 0.6) = (1.8 − 0.8, 2.4 + 0.6) = (1, 3) = v
  5. The length matches too: 3² + 1² = 10 and 1² + 3² = 10

Written as equations, the same calculation looks like this.

c1=𝐯·𝐪1=1×0.6+3×0.8=3,c2=𝐯·𝐪2=1×(−0.8)+3×0.6=1

c1𝐪1+c2𝐪2=3[0.60.8]+1[−0.80.6]=[1.8−0.82.4+0.6]=[13]=𝐯

In equations, (0.6, 0.8) is written standing up, as a column. It is the same arrow.

c12+c22=32+12=10=12+32=‖𝐯‖2

For a basis uᵢ that is orthogonal but not length 1, divide by the squared length: cᵢ = v·uᵢ ÷ (uᵢ·uᵢ). The steps that turn any basis into an orthonormal one are in Gram-Schmidt.

Try this. ① On the starting screen, c₁ = 3 and c₂ = 1. ② Set the angle to 0° and q₁, q₂ line up with the x and y axes, so the coordinates are just v itself, (1, 3). ③ On the starting screen, press "Flip". q₂ becomes (0.8, −0.6) and only c₂ changes, to −1. In every case √(c₁² + c₂²) stays at ‖v‖ = 3.16.

4. Orthogonal matrix: QᵀQ = I

Stand the orthonormal basis q₁, q₂ up as the columns of a square matrix Q, and Q is an orthogonal matrix. On the starting screen of the lab, Q = 0.6 −0.8 / 0.8 0.6 (top row / bottom row).

Multiply Q by the coordinates c and you get Qc = c₁q₁ + c₂q₂ = v. Going the other way, multiply Qᵀ by v: each row is a dot product with a q, so Qᵀv = (v·q₁, v·q₂) = c. In the lab, dropping the shadows is Qᵀ and adding them back is Q. Each undoes the other, so QᵀQ = I, which means Q⁻¹ = Qᵀ. You never compute an inverse. You just transpose.

PropertyFormulaMeaning
Columns are orthonormalQᵀQ = IThe definition. Q is square, so its rows are orthonormal too (QQᵀ = I)
Inverse = transposeQ⁻¹ = QᵀUndoing it is one transpose
Keeps lengths‖Qx‖ = ‖x‖Nothing is stretched or shrunk
Keeps angles(Qx)·(Qy) = x·yRight angles stay right angles
Determinantdet Q = +1 or −1Areas stay the same (determinant). In 2D, +1 is a turn and −1 is a flip
Products stay orthogonal(Q₁Q₂)ᵀ(Q₁Q₂) = IA turn after a turn is still a turn

Why ±1. det(QᵀQ) = det(Qᵀ) × det(Q) = (det Q)², and QᵀQ = I makes this 1. Its square is 1, so det Q is +1 or −1. A 2D turn is cos θ −sin θ / sin θ cos θ (determinant +1). Mix in a mirror flip and you get cos θ sin θ / sin θ −cos θ (determinant −1). The "Flip" button in the lab gives the second one.

5. How the formula is built: from QᵀQ = I to ‖Qx‖ = ‖x‖

Four steps show how "length 1, at right angles" turns into QᵀQ = I, and why that keeps lengths the same. The numbers come from the starting screen of the lab (q₁ = (0.6, 0.8), q₂ = (−0.8, 0.6)).

Press "Next" to go one step at a time. In the formula above, the piece with the orange background is the one added in this step. In the last step the purple arrow is x, the black arrow is Qx, and the gray dashed circle is their length.

Written only as equations, the steps above look like this.

Q=[𝐪1𝐪2]=[0.6−0.80.80.6]

Q𝖳Q=[𝐪1𝖳𝐪2𝖳][𝐪1𝐪2]=[𝐪1·𝐪1𝐪1·𝐪2𝐪2·𝐪1𝐪2·𝐪2]

𝐪1·𝐪1=0.62+0.82=1,𝐪2·𝐪2=(−0.8)2+0.62=1,𝐪1·𝐪2=0.6×(−0.8)+0.8×0.6=0

Q𝖳Q=[1001]=I,Q−1=Q𝖳

‖Q𝐱‖2=(Q𝐱)𝖳(Q𝐱)=𝐱𝖳Q𝖳Q𝐱=𝐱𝖳𝐱=‖𝐱‖2

𝐱=[31]:Q𝐱=[13],‖Q𝐱‖2=12+32=10=32+12=‖𝐱‖2

Angles are kept the same way: (Qx)·(Qy) = xᵀQᵀQy = xᵀy = x·y. The dot product does not change, so nothing measured with it changes either: length, angle, and right angles all stay.

Where it is used

Common questions

What is an orthogonal matrix?

A square matrix whose columns are at right angles to each other and all have length 1. It satisfies QᵀQ = I, so its inverse is just its transpose Qᵀ.

Is a matrix orthogonal if its columns are only at right angles?

No. Every column must also have length 1. If the columns are only at right angles, QᵀQ is not I but a matrix with the squared lengths on its diagonal. The name says orthogonal, but the columns must be orthonormal.

Why is the determinant of an orthogonal matrix 1 or −1?

Because det(QᵀQ) = (det Q)², and QᵀQ = I makes this 1. In 2D, +1 means a turn and −1 means a mirror flip.

Words

Plain words used hereTextbook term
At right anglesOrthogonal. The dot product is 0
Base arrows of length 1 at right anglesOrthonormal basis
LengthNorm, ‖v‖
ShadowOrthogonal projection
Laying a matrix on its sideTranspose, Qᵀ
The do-nothing matrixIdentity matrix, I
A space with a dot product chosenInner product space
Turn / flipRotation / reflection

Sources

← Eigenvalues and eigenvectorsProjection and least squares →