Orthogonal Functions and Orthogonal Matrices
A linear map that preserves inner products moves things around without stretching or bending them. In such maps are given by orthogonal matrices, the rotations and reflections; between function spaces they are changes to an orthonormal basis of functions.
Maps that preserve the inner product
Let and be inner product spaces. A linear map is orthogonal (an isometry) if for all . Then also preserves lengths, distances and angles. Conversely, a linear map that preserves all lengths preserves inner products too, because of the polarization identity
Orthogonal functions. In a function space, an orthonormal list like from Fourier series, or the normalized Legendre polynomials from Gram-Schmidt, plays the role of the standard basis. The map that sends a function to its list of coefficients is orthogonal: inner products of functions become dot products of coefficient vectors (Parseval's identity). That is why we can compute with Fourier coefficients instead of integrals.
Orthogonal matrices
A real matrix is orthogonal if . The following are equivalent:
| Condition | Meaning |
|---|---|
| the columns are orthonormal | |
| the rows are orthonormal | |
| inverting is free | |
| for all | lengths are preserved |
| for all | angles are preserved |
The proof of "" is one line: .
Further facts:
- , since . means a rotation, includes a reflection.
- Products and inverses of orthogonal matrices are orthogonal (they form the group ; rotations form ).
- Every real eigenvalue is , and complex eigenvalues have (see Unitary and Hermitian Matrices).
Note: The name is slightly misleading: an "orthogonal matrix" has orthonormal columns. A matrix with merely orthogonal columns satisfies , not .
import numpy as np
th = np.radians(30)
R = np.array([[np.cos(th), -np.sin(th), 0],
[np.sin(th), np.cos(th), 0],
[0, 0, 1]]) # rotate 30° about z
n = np.array([1.0, 2.0, 2.0]) / 3 # unit normal
H = np.eye(3) - 2 * np.outer(n, n) # reflection in the plane n·x = 0
for name, Q in [("rotation", R), ("reflection", H), ("product", R @ H)]:
print(f"{name:10s} Q^T Q = I: {np.allclose(Q.T @ Q, np.eye(3))} det = {np.linalg.det(Q):+.4f}")
x, y = np.array([3.0, -1.0, 2.0]), np.array([0.5, 4.0, 1.0])
print("|x| =", round(float(np.linalg.norm(x)), 4), " |Rx| =", round(float(np.linalg.norm(R @ x)), 4))
print("x.y =", float(x @ y), " (Hx).(Hy) =", round(float((H @ x) @ (H @ y)), 4))rotation Q^T Q = I: True det = +1.0000
reflection Q^T Q = I: True det = -1.0000
product Q^T Q = I: True det = -1.0000
|x| = 3.7417 |Rx| = 3.7417
x.y = -0.5 (Hx).(Hy) = -0.5
Householder reflections
The matrix (with ) used above reflects across the plane orthogonal to . It is symmetric and orthogonal, so . Given any two vectors of the same length, choosing gives . Numerical libraries use this to zero out a whole column below the diagonal in one step; repeating it column by column produces the QR factorization.
import numpy as np
x = np.array([3.0, 4.0, 0.0, 12.0])
y = np.array([np.linalg.norm(x), 0, 0, 0]) # target: same length, along e1
n = (x - y) / np.linalg.norm(x - y)
H = np.eye(4) - 2 * np.outer(n, n)
print("|x| =", float(np.linalg.norm(x)))
print("Hx =", np.round(H @ x, 10) + 0.0)
print("H symmetric:", np.allclose(H, H.T), " H^2 = I:", np.allclose(H @ H, np.eye(4)))|x| = 13.0
Hx = [13. 0. 0. 0.]
H symmetric: True H^2 = I: True
Orthogonal matrices and changes of basis
If the columns of form an orthonormal basis , then the coordinates of a vector in that basis are , and going back is . This is the special case of the matrix of a transformation where the change-of-basis matrix is inverted by transposing, which is what makes orthonormal bases so popular in code.
In software
- 3D engines. The rotation part of a model or view matrix is orthogonal, so its inverse is its transpose: the view matrix is computed as a transpose, not a general inverse (Inverse, Graphics Transforms).
- Normals. Surface normals are transformed by ; when is a pure rotation that is itself.
- Drift. After thousands of multiplications, floating-point rotations stop being orthogonal; engines re-orthonormalize them or switch to quaternions.
- Deep learning. Orthogonal weight initialization keeps signal norms stable through many layers, because .
- Numerics. QR and SVD are built from orthogonal matrices because they never amplify rounding errors ().
Exercises
Exercise 1: Complete the matrix
Find and so that is a rotation matrix.
Answer
, .
Solution
The second column must be a unit vector orthogonal to : either or . The determinant is ; with it is (rotation), with the other it is −1 (reflection).
Exercise 2: Is it orthogonal?
Is orthogonal? If not, fix it.
Answer
No, . is orthogonal (a rotation by ).
Solution
The columns and are orthogonal but have length , so . Dividing by normalizes them; .
Exercise 3: Inverse for free
. Find and .
Answer
(it is symmetric), .
Solution
The rows are the orthonormal vectors from Orthogonality Exercise 1, so , and is symmetric. A symmetric orthogonal matrix satisfies , so it is a reflection-type matrix.
from sympy import Matrix, Rational
Q = Rational(1, 3) * Matrix([[1, 2, 2], [2, 1, -2], [2, -2, 1]])
print(Q.T * Q == Matrix.eye(3), Q.inv() == Q.T, Q.det())True True -1
Exercise 4: A Householder mirror (code)
Build the Householder matrix that sends to and check its determinant.
Answer
, .
Solution
with . Every Householder matrix has (it flips one direction, , and fixes a hyperplane).
import numpy as np
x = np.array([1.0, 1.0]); y = np.array([np.sqrt(2), 0.0])
n = (x - y) / np.linalg.norm(x - y)
H = np.eye(2) - 2 * np.outer(n, n)
print(np.round(H, 4), round(float(np.linalg.det(H)), 4))[[ 0.7071 0.7071]
[ 0.7071 -0.7071]] -1.0
Test yourself
For an orthogonal matrix , equals…
Which number can NOT be the determinant of a real orthogonal matrix?
- 1
- −1
- 2
- All three are possible
Why do numerical algorithms like QR prefer orthogonal transformations?
- They are always diagonal
- They preserve lengths, so they do not amplify rounding errors
- They have integer entries
- They commute with every matrix