linear algebra calculators

Gram-Schmidt Process Calculator

Transform a set of linearly independent vectors into an orthogonal or orthonormal basis using the Gram-Schmidt process. Useful in linear algebra courses, QR decomposition, and signal processing applications.

About this calculator

The Gram-Schmidt process converts a set of linearly independent vectors {v₁, v₂, …, vₙ} into mutually perpendicular vectors {u₁, u₂, …, uₙ}. The first orthogonal vector is simply u₁ = v₁. Each subsequent vector is obtained by subtracting all projections onto previous basis vectors: uₖ = vₖ − Σᵢ₌₁ᵏ⁻¹ (vₖ·uᵢ / ‖uᵢ‖²) uᵢ. If normalization is requested, each result is divided by its own magnitude to produce unit vectors eₖ = uₖ / ‖uₖ‖. The projection of v onto u is given by proj_u(v) = (v·u / ‖u‖²) u. In 2D, after fixing u₁ = v₁, the second orthogonal vector is u₂ = v₂ − (v₂·v₁ / ‖v₁‖²) v₁. Orthonormal bases simplify matrix computations, least-squares solutions, and Fourier analysis.

How to use

Let v₁ = (3, 0) and v₂ = (2, 2). Step 1: u₁ = v₁ = (3, 0); ‖u₁‖ = 3. Step 2: compute projection of v₂ onto u₁: (v₂·u₁) / ‖u₁‖² = (2·3 + 2·0) / 9 = 6/9 = 2/3. Step 3: u₂ = v₂ − (2/3)u₁ = (2 − 2, 2 − 0) = (0, 2). Verify orthogonality: u₁·u₂ = 3·0 + 0·2 = 0 ✓. Step 4 (normalize): e₁ = (1, 0), e₂ = (0, 1). The orthonormal basis is the standard basis, confirming the calculation.

Frequently asked questions

What is the Gram-Schmidt process used for in linear algebra?

The Gram-Schmidt process is used to construct an orthogonal or orthonormal basis from any set of linearly independent vectors in an inner product space. Orthonormal bases simplify many computations: projections reduce to simple dot products, matrix inverses are just transposes for orthogonal matrices, and solving least-squares problems becomes straightforward. It is also the theoretical backbone of QR decomposition, which factors a matrix into an orthogonal matrix Q and an upper-triangular matrix R.

How do I check whether my Gram-Schmidt result is correct?

The key verification is orthogonality: every pair of output vectors must have a dot product of zero. If you requested normalization, each vector should also have a magnitude (Euclidean norm) of exactly 1. A third check is that the span of the output set equals the span of the original input vectors — you can verify this by confirming that each original vector is expressible as a linear combination of the new basis vectors. Numerical computations may introduce small rounding errors, so values very close to zero (e.g., 1×10⁻¹⁵) should be treated as zero.

Why does the Gram-Schmidt process fail for linearly dependent vectors?

If the input vectors are linearly dependent, at some step the projection subtraction produces a zero vector, which cannot be normalized and does not contribute a new basis direction. This signals that the set does not span an additional dimension — the vector was already expressible as a combination of the previous ones. In practice, numerical near-dependence can cause severe cancellation errors, making the output vectors nearly parallel rather than orthogonal. Algorithms like Modified Gram-Schmidt or Householder reflections are numerically more stable alternatives for such cases.