Advanced maths

Gram–Schmidt orthogonal basis calculator

Build an exact orthogonal basis of the entered column span and identify redundant vectors.

Your numbers

One row per line or semicolon. Separate entries with spaces or commas. Up to 6 rows and 6 columns; integers, decimals up to 6 places, or fractions such as -2/3. Basis vectors are columns.

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your numbers and select Calculate.

Behind the numbers

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.

THE FORMULAuⱼ = 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.

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.

Find your calculator

Start typing to explore the library.