Linear Algebra
Projections & Gram–Schmidt
The closest point of a line or a plane to a vector is where the error meets it at a right angle. The same picture fits a line to data, and done one direction at a time it straightens any basis into an orthonormal one.
ba₁, q₁a₂, q₂a₃, q₃p, the projectione = b − p, the errorc, a candidate point
Drag to orbit · scroll to zoom · drag the arrow tips, or the candidate ring inside the subspace
Distance from b—
—
View
Project b onto
Vector b
Starting vectors
a₁
a₂
a₃
Values
x̂ = (AᵀA)⁻¹Aᵀb—
p = Ax̂—
e = b − p—
Aᵀe—
|e|² + |p − c|²—
|b − c|²—
Values
q₁ · q₂—
q₁ · q₃—
q₂ · q₃—
|q₁|, |q₂|, |q₃|—
largest entry of A − QR—
What to observe
- Press Run: the candidate c sweeps through the plane and its distance to b dips to its lowest exactly as it passes p. There b, p, c form a right triangle, so |b − c|² = |e|² + |p − c|².
- Least squares is the same picture. With columns (1, 1, 1) and the times t, the plane holds every straight line, b holds the data, p the fitted values and e the residuals; Aᵀe = 0 are the normal equations. Thelinear models page fits lines this way.
- Run Gram–Schmidt: each vector loses its shadow on the q's already made, and what is left is normalised. Every shadow length and leftover length lands in R, so A = QR.
- Put a₃ in the plane of a₁ and a₂: once its two shadows are taken away nothing is left, r₃₃ = 0, and there is no third direction to find.
Shortcuts:space run/pause · s step · r reset · f fullscreen