Gram-Schmidt Orthogonalization Calculator
Convert two linearly independent 2D vectors into an orthonormal basis using the Gram-Schmidt process. Ideal for linear algebra students working on QR decomposition, subspace projections, or eigenvalue problems.
About this calculator
The Gram-Schmidt process builds an orthogonal basis from linearly independent input vectors. For two 2D vectors v₁ and v₂, the first orthogonal vector is u₁ = v₁. The second is u₂ = v₂ − ((v₁·v₂)/(v₁·v₁))·v₁, which removes the component of v₂ along v₁. Here v₁·v₂ = v1_x·v2_x + v1_y·v2_y and v₁·v₁ = v1_x² + v1_y². The magnitude (norm) of u₂, which this calculator computes, is ‖u₂‖ = √(u2_x² + u2_y²). To obtain orthonormal vectors, divide each by its norm: ê₁ = u₁/‖u₁‖ and ê₂ = u₂/‖u₂‖. A zero norm for u₂ indicates that v₁ and v₂ are linearly dependent (parallel), meaning no orthonormal basis can be formed.
How to use
Let v₁ = (1, 2) and v₂ = (3, 4). Enter v1_x = 1, v1_y = 2, v2_x = 3, v2_y = 4. Step 1: v₁·v₂ = 1·3 + 2·4 = 3 + 8 = 11. Step 2: v₁·v₁ = 1² + 2² = 5. Step 3: projection coefficient = 11/5 = 2.2. Step 4: u2_x = 3 − 2.2·1 = 0.8; u2_y = 4 − 2.2·2 = −0.4. Step 5: ‖u₂‖ = √(0.8² + (−0.4)²) = √(0.64 + 0.16) = √0.8 ≈ 0.8944. This is the norm of the second orthogonal basis vector, confirming u₂ is non-zero and the inputs are linearly independent.
Frequently asked questions
What does the Gram-Schmidt calculator output represent and how do I use it?
The calculator outputs the norm (magnitude) of the second orthogonal vector u₂ produced by the Gram-Schmidt process. This value tells you the length of the vector that is perpendicular to v₁ and spans the same 2D subspace as {v₁, v₂}. To get the full orthonormal basis, divide u₁ by ‖u₁‖ and u₂ by this computed norm. A norm close to zero indicates near-linear dependence between the input vectors, which may cause numerical instability.
When would you use Gram-Schmidt orthogonalization in practice?
Gram-Schmidt is used whenever you need a set of perpendicular basis vectors, which arises frequently in numerical linear algebra. The most common application is QR decomposition, where a matrix is factored into an orthogonal matrix Q and upper-triangular matrix R for solving least-squares problems. In signal processing and Fourier analysis, it produces orthonormal function bases. In machine learning, it appears in principal component analysis and feature orthogonalization to remove linear correlations between input features.
Why does the Gram-Schmidt process fail when two vectors are linearly dependent?
When two vectors are linearly dependent, one is a scalar multiple of the other and they point in the same (or opposite) direction. After subtracting the full projection of v₂ onto v₁, the remainder u₂ becomes the zero vector — it has no component perpendicular to v₁. A zero vector cannot be normalized (division by zero), so no second basis vector exists. In this situation the two vectors do not span a 2D subspace; they only span a 1D line, and you need a genuinely independent second vector to form a basis.