How this calculation works
Process input columns in order. Subtract their projections onto the already retained orthogonal vectors. Keep a nonzero residual as the next direction; skip a zero residual because it adds no direction. The result is an exact orthogonal basis, without unit-length normalization.
uⱼ = vⱼ − Σᵢ<ⱼ [(vⱼ · uᵢ)/(uᵢ · uᵢ)] uᵢA worked example
For columns (1,1) and (1,0), the retained vectors are (1,1) and (1/2,−1/2). Their dot product is zero and their squared norms are 2 and 1/2.
Good to know
Exact rational matrices up to 6 × 6. Entries are bounded to ±1,000,000, integer fraction denominators to 1,000,000 and decimal input to 6 places. Intermediate fractions have a size limit. No complex entries, symbolic expressions, measurement uncertainty or numerical-conditioning analysis. Ordered vectors are entered as matrix columns.
Reference: Harvard University: Gram–Schmidt orthogonalization (opens in a new tab) ↗
Subtract the directions you already have
Gram–Schmidt processes the input columns in order. Keep the first nonzero vector. For each later vector, subtract its projections onto the retained orthogonal vectors. The residual, if nonzero, points in a new direction perpendicular to every earlier retained direction.
For v₁ = (1,1) and v₂ = (1,0), the projection coefficient onto v₁ is 1/2. Subtracting (1/2,1/2) from v₂ gives (1/2,−1/2). Its dot product with (1,1) is zero.
A zero residual means that input was already in the preceding span. The calculator skips it and explains which column was redundant. This allows dependent spanning lists, including zero vectors, while retaining a basis of the original span.
Orthogonal does not automatically mean unit length
The returned basis is orthogonal and unnormalized. Squared norms are shown exactly. Dividing each nonzero vector by its norm would produce an orthonormal basis, but those norms can involve irrational square roots.
Keeping unnormalized rational vectors makes it possible to display exact outputs for rational inputs. For the example, the squared norms are 2 and 1/2, so neither returned vector has unit length. Do not treat this output as an orthonormal Q matrix.
Reordering the inputs can produce a different orthogonal basis of the same span. The method here uses the standard real Euclidean dot product. Weighted inner products, complex conjugation and floating-point stability for measured data need their own treatment.
A few questions, answered
What happens if every input is zero?
The span is the zero subspace, which has an empty basis and dimension zero. Every input column is marked as skipped.
Does this calculate a QR decomposition?
No. It returns an unnormalized orthogonal basis and processing steps, not a normalized Q and triangular R pair.
Can I check the output myself?
Take the dot product of each distinct pair of retained vectors; each should be zero. Their span should match the input column span.