Transform any set of linearly independent vectors into an orthogonal or orthonormal basis. Compute projections, step‑by‑step, with interactive 2D visualization. Perfect for linear algebra, numerical analysis, and machine learning.
The Gram–Schmidt algorithm is a cornerstone of linear algebra. It takes a finite, linearly independent set of vectors and produces an orthogonal set that spans the same subspace. Further normalization yields an orthonormal basis. Developed by Jørgen Pedersen Gram and Erhard Schmidt in the early 20th century, this method is fundamental to QR decomposition, least‑squares fitting, and signal processing.
Classical Gram–Schmidt recurrence:
u₁ = v₁
u₂ = v₂ - proj_{u₁}(v₂) = v₂ - \frac{v₂·u₁}{u₁·u₁} u₁
u₃ = v₃ - proj_{u₁}(v₃) - proj_{u₂}(v₃), and so on.
Finally, e_i = u_i / ‖u_i‖.
Given a set of vectors {v₁, v₂, ..., vₖ}, the orthogonal set {u₁, u₂, ..., uₖ} is constructed iteratively by subtracting projections onto all previously computed orthogonal vectors. The orthonormal basis is then obtained by scaling each uᵢ to unit length. The procedure requires O(k²·n) operations and is numerically stable when using the modified Gram–Schmidt variant.
When you click "Orthogonalize & Orthonormalize", the calculator applies the classical Gram‑Schmidt process:
For 2D inputs, the canvas visually depicts original vectors (blue), orthogonal vectors (orange) and orthonormal vectors (green) anchored at origin.
In a dataset with two highly correlated features, Gram‑Schmidt orthogonalization can generate uncorrelated synthetic predictors, improving numerical stability of ordinary least squares. Many statistical software packages use modified Gram‑Schmidt behind the scenes.