Skip to content

Orthogonal Complement

Given a subspace, the orthogonal complement is everything perpendicular to it. It’s the normal direction of a plane, the “leftover” space a projection discards, and the reason any vector can be split cleanly into a part inside a subspace and a part outside it. That split is the mathematical heart of PCA and least-squares residuals.

A real-life example: a wall and its normal

Stand a flat panel (a 2-D plane) in a room (3-D space). Every direction lying in the panel forms the subspace UU. The single direction sticking straight out of the panel — its normal — is the orthogonal complement UU^\perp. Together they describe the whole room: any arrow in the room is “some slide along the panel” plus “some poke through it.”

Definition

For a DD-dimensional space VV and an MM-dimensional subspace UVU \subseteq V, the orthogonal complement UU^\perp is the set of all vectors orthogonal to every vector in UU:

U={vV:v,u=0 for all uU}.U^\perp = \{\mathbf{v} \in V : \langle \mathbf{v}, \mathbf{u}\rangle = 0 \text{ for all } \mathbf{u} \in U\}.

Key facts:

  • UU^\perp is a subspace of dimension DMD - M.
  • UU={0}U \cap U^\perp = \{\mathbf{0}\} — they share only the origin.
  • Every xV\mathbf{x} \in V decomposes uniquely as x=xU+xU\mathbf{x} = \mathbf{x}_U + \mathbf{x}_{U^\perp} with xUU\mathbf{x}_U \in U and xUU\mathbf{x}_{U^\perp} \in U^\perp.
diagram Diagram mermaid

For a plane UU in 3-D, UU^\perp is one-dimensional — spanned by the plane’s normal vector w\mathbf{w}. This is how a hyperplane is specified in nn dimensions: give its normal.

Splitting a vector, live

In 2-D, take a line UU through the origin. Its orthogonal complement UU^\perp is the perpendicular line. Any vector x\mathbf{x} splits into a piece along UU (green) and a piece along UU^\perp (violet) — and those two pieces add back to x\mathbf{x}. Watch x\mathbf{x} rotate while its two orthogonal components track it:

sketch Decomposing a vector into U and U⊥ p5.js
A line U (green) through the origin and its orthogonal complement U⊥ (violet). The white vector x splits uniquely into a component in U plus a component in U⊥, shown as the two legs of a right angle that always sum back to x.

The two colored components are always at right angles and always sum to x\mathbf{x} — the unique UU/UU^\perp decomposition in action.

NumPy

orthogonal_complement.py
import numpy as np
 
# U is the line spanned by d (a 1-D subspace of R^2)
d = np.array([1.0, 1.0]) / np.sqrt(2)      # unit direction of U
x = np.array([3.0, 1.0])
 
# component of x in U, and the rest (which lies in U-perp)
x_U = (x @ d) * d
x_perp = x - x_U
 
print("x_U      :", np.round(x_U, 4))
print("x_perp   :", np.round(x_perp, 4))
print("sum == x :", np.allclose(x_U + x_perp, x))
print("orthogonal parts:", np.isclose(x_U @ x_perp, 0))
 
# In 3-D, the normal of a plane spans its 1-D orthogonal complement
w = np.array([0.0, 0.0, 1.0])              # normal to the xy-plane
in_plane = np.array([2.0, -3.0, 0.0])
print("normal ⟂ plane vector:", np.isclose(w @ in_plane, 0))
orthogonal_complement.py
import numpy as np
 
# U is the line spanned by d (a 1-D subspace of R^2)
d = np.array([1.0, 1.0]) / np.sqrt(2)      # unit direction of U
x = np.array([3.0, 1.0])
 
# component of x in U, and the rest (which lies in U-perp)
x_U = (x @ d) * d
x_perp = x - x_U
 
print("x_U      :", np.round(x_U, 4))
print("x_perp   :", np.round(x_perp, 4))
print("sum == x :", np.allclose(x_U + x_perp, x))
print("orthogonal parts:", np.isclose(x_U @ x_perp, 0))
 
# In 3-D, the normal of a plane spans its 1-D orthogonal complement
w = np.array([0.0, 0.0, 1.0])              # normal to the xy-plane
in_plane = np.array([2.0, -3.0, 0.0])
print("normal ⟂ plane vector:", np.isclose(w @ in_plane, 0))
text
x_U      : [2. 2.]
x_perp   : [ 1. -1.]
sum == x : True
orthogonal parts: True
normal ⟂ plane vector: True
text
x_U      : [2. 2.]
x_perp   : [ 1. -1.]
sum == x : True
orthogonal parts: True
normal ⟂ plane vector: True

Why this matters for ML

  • PCA keeps a subspace UU of top directions and discards its complement UU^\perp; the discarded part is exactly the reconstruction error.
  • Least-squares residuals live in the orthogonal complement of the column space — the fit is in UU, the error is in UU^\perp.
  • Hyperplane classifiers (SVMs) are specified by their normal vector, a basis of the boundary’s orthogonal complement.

🧪 Try It Yourself

Exercise 1 – Split a vector

Exercise 2 – The parts are orthogonal

Exercise 3 – A plane’s normal

Recap

  • The orthogonal complement UU^\perp is everything perpendicular to a subspace UU; it has dimension DMD - M.
  • Every vector splits uniquely into a UU-part plus a UU^\perp-part.
  • For a plane, UU^\perp is spanned by the normal vector — how hyperplanes are specified.
  • In ML, the complement is the residual/discarded space in PCA and least squares.

Next: the same orthogonality idea, applied to functions.

If this helped you, consider buying me a coffee ☕

Buy me a coffee

Was this page helpful?

Let us know how we did