Gram-Schmidt Orthogonalization
Convert a set of linearly independent 2D vectors into a mutually orthogonal (or orthonormal) basis using the Gram-Schmidt process. Used in linear algebra, QR decomposition, and numerical methods courses.
About this calculator
The Gram-Schmidt process takes linearly independent vectors and produces a set of orthogonal vectors spanning the same subspace. Starting with vector v₁, the first basis vector is u₁ = v₁. For each subsequent vector vₙ, you subtract its projections onto all previously computed basis vectors: u₂ = v₂ − proj_{u₁}(v₂), where proj_{u₁}(v₂) = ((v₂·u₁)/(u₁·u₁))·u₁. The dot product v₂·u₁ = v2_x·v1_x + v2_y·v1_y, and ‖u₁‖² = v1_x² + v1_y². To normalize, divide each orthogonal vector by its magnitude: ê₁ = u₁/‖u₁‖. The result is an orthonormal basis where every pair of vectors is perpendicular and each vector has unit length. This process underlies QR decomposition and least-squares solutions.
How to use
Let v₁ = (1, 0) and v₂ = (1, 1). Step 1: u₁ = v₁ = (1, 0); ‖u₁‖ = √(1² + 0²) = 1. Step 2: compute the projection scalar = (v₂·u₁)/‖u₁‖² = (1·1 + 1·0)/(1² + 0²) = 1/1 = 1. Step 3: u₂_x = v2_x − 1·v1_x = 1 − 1·1 = 0; u₂_y = v2_y − 1·v1_y = 1 − 1·0 = 1. So u₂ = (0, 1). Step 4: ‖u₂‖ = √(0² + 1²) = 1. The orthonormal basis is ê₁ = (1, 0) and ê₂ = (0, 1), the standard basis — confirming orthogonality since (1,0)·(0,1) = 0.
Frequently asked questions
What is the Gram-Schmidt process used for in linear algebra?
The Gram-Schmidt process is used to convert any set of linearly independent vectors into an orthogonal or orthonormal basis for the same vector space or subspace. It is fundamental to QR matrix decomposition, where a matrix A is factored as A = QR with Q having orthonormal columns. This decomposition is widely used for solving least-squares problems, eigenvalue computations, and numerical stability in scientific computing. In quantum mechanics, orthonormal bases of state vectors are constructed this way.
How do you know if the Gram-Schmidt process will fail for a given set of vectors?
The process fails — producing a zero vector — when the input vectors are linearly dependent, meaning one vector can be expressed as a linear combination of the others. This is detected when the computed u₂ (or any subsequent vector) has zero magnitude. In the calculator, this manifests as a division-by-zero or zero-norm output. Always verify that your input vectors are linearly independent before applying the process; for 2D vectors, this means they must not be parallel.
What is the difference between an orthogonal basis and an orthonormal basis?
An orthogonal basis is a set of vectors that are mutually perpendicular — every pair has a dot product of zero. An orthonormal basis additionally requires each vector to have unit length (magnitude = 1). To go from orthogonal to orthonormal, you divide each basis vector by its own magnitude. Orthonormal bases are especially convenient because the coordinate of any vector along a basis direction equals a simple dot product, without needing to divide by the norm.