Orthogonality
Two vectors are orthogonal when their inner product is zero. Orthogonal sets are the most convenient bases there are: coordinates come from inner products instead of solving a system, and they never interfere with each other.
Orthogonal and orthonormal sets
In an inner product space, and are orthogonal, written , if . A set is
| Term | Condition |
|---|---|
| orthogonal | whenever |
| orthonormal | orthogonal, and every |
Any orthogonal set of nonzero vectors can be made orthonormal by dividing each vector by its length.
Pythagoras. If then . The same works for any number of mutually orthogonal vectors.
Orthogonal sets are independent
Theorem. An orthogonal set of nonzero vectors is linearly independent.
Proof. Suppose . Take the inner product of both sides with . Every term with vanishes, leaving . Since , , so . This holds for every .
So mutually orthogonal nonzero vectors in an -dimensional space automatically form a basis.
Coordinates for free
If is an orthogonal basis and , the same trick (inner product with ) gives each coefficient directly:
No row reduction needed. Compare with an arbitrary basis, where finding coordinates means solving a linear system.
import numpy as np
v1 = np.array([1.0, 1.0, 1.0])
v2 = np.array([1.0, -1.0, 0.0])
v3 = np.array([1.0, 1.0, -2.0])
B = [v1, v2, v3]
print("pairwise inner products:", [float(B[i] @ B[j]) for i in range(3) for j in range(i + 1, 3)])
w = np.array([4.0, 2.0, -3.0])
c = [float(w @ v) / float(v @ v) for v in B]
print("coefficients:", [round(x, 4) for x in c])
print("rebuilt w:", c[0] * v1 + c[1] * v2 + c[2] * v3)
print("same as solve():", np.round(np.linalg.solve(np.column_stack(B), w), 4))pairwise inner products: [0.0, 0.0, 0.0]
coefficients: [1.0, 1.0, 2.0]
rebuilt w: [ 4. 2. -3.]
same as solve(): [1. 1. 2.]
Orthogonal complements
For a subspace of , the orthogonal complement is
It is always a subspace, , and in a finite-dimensional space . To test it is enough to check against a spanning set of .
For matrices this gives the clean picture behind the four fundamental subspaces: says is orthogonal to every row of , so
SymPy can compute a complement exactly: put a basis of in the rows of a matrix and take its null space.
from sympy import Matrix
W = Matrix([[1, 2, 0, -1],
[0, 1, 1, 1]]) # rows span W in R^4
perp = W.nullspace()
for v in perp:
print("basis vector of W⊥:", list(v), " check:", list(W * v))
print("dim W + dim W⊥ =", W.rank(), "+", len(perp), "=", W.rank() + len(perp))basis vector of W⊥: [2, -1, 1, 0] check: [0, 0]
basis vector of W⊥: [3, -1, 0, 1] check: [0, 0]
dim W + dim W⊥ = 2 + 2 = 4
Note: The two basis vectors of returned here are not orthogonal to each other. They only have to be orthogonal to . Making them orthogonal to each other is the job of Gram-Schmidt.
In software
- Graphics. A camera's right, up and forward vectors form an orthonormal basis; converting a world point into camera coordinates is just three dot products (see Look Rotation).
- Collision. The separating axis test projects shapes onto edge normals, vectors orthogonal to the edges (SAT).
- Signal processing and ML. Orthogonal features carry non-overlapping information; PCA picks orthogonal directions on purpose (PCA).
- Error correction. A codeword is valid exactly when it is orthogonal (mod 2) to every row of the parity-check matrix (Error Correcting Codes).
Exercises
Exercise 1: Is the set orthogonal?
Are , and mutually orthogonal? Make them orthonormal.
Answer
Yes. Each has length 3, so dividing by 3 gives an orthonormal basis of .
Solution
Exercise 2: Coordinates without solving
Using the orthonormal basis from Exercise 1, find the coordinates of .
Answer
, where are the basis vectors divided by 3.
Solution
:
Check: .
Exercise 3: A complement in
Find when is the plane spanned by and .
Answer
is the line spanned by .
Solution
must satisfy and , so . Taking gives . Alternatively, the cross product points the same way.
Exercise 4: Pythagoras check (code)
Verify numerically that for the three vectors of Exercise 1.
Answer
Both sides equal 27.
Solution
, and .
import numpy as np
u, v, w = np.array([1, 2, 2]), np.array([2, 1, -2]), np.array([2, -2, 1])
s = u + v + w
print(int(s @ s), int(u @ u + v @ v + w @ w))27 27
Exercise 5: Orthogonal functions
On with , show that every odd function is orthogonal to every even function.
Answer
The product of an odd and an even function is odd, and the integral of an odd function over is 0.
Solution
If and , then satisfies . Splitting the integral and substituting on gives , so the total is 0. For example .
Test yourself
Why is an orthogonal set of nonzero vectors linearly independent?
- Because it has at most vectors
- Taking the inner product of a dependence relation with forces
- Because orthogonal vectors have length 1
- It is not always independent
In an orthonormal basis , the coordinate of along is…
- the -th entry of for some matrix you must invert
The null space of a matrix is the orthogonal complement of…
- its column space
- its row space
- the null space of