Skip to content
MoneyDeck

Gram-Schmidt Calculator

Turn a set of vectors into an orthonormal basis, with exact fractions

Updated · Free, no signup

Separate components with spaces or commas. Fractions like 1/2 are allowed. Up to 8 vectors of up to 8 components.

Orthonormal basis e₁, e₂, …

e₁ = (0.707107, 0.707107, 0)
e₂ = (0.408248, -0.408248, 0.816497)
e₃ = (-0.57735, 0.57735, 0.57735)

Orthonormal basis (exact form)

e₁ = (1, 1, 0)/√2
e₂ = (1, -1, 2)/√6
e₃ = (-1, 1, 1)/√3

Orthogonal vectors u₁, u₂, …

u₁ = (1, 1, 0)
u₂ = (1/2, -1/2, 1)
u₃ = (-2/3, 2/3, 2/3)

Lengths ‖uₖ‖

‖u₁‖ = 1.414214, ‖u₂‖ = 1.224745, ‖u₃‖ = 1.154701

Basis size (rank)

3

Dependent vectors dropped

0

Largest |eᵢ · eⱼ| (i ≠ j)

0

Should be 0 — confirms the result is orthogonal.

  • The 3 input vectors span a 3-dimensional subspace of ℝ³ — the whole space.

Gram-Schmidt steps

VectorSubtract projectionsResult
v₁v₁u₁ = (1, 1, 0)
v₂v₂ − (1/2·u₁)u₂ = (1/2, -1/2, 1)
v₃v₃ − (1/2·u₁ + 1/3·u₂)u₃ = (-2/3, 2/3, 2/3)

About the Gram-Schmidt Calculator

This Gram-Schmidt calculator converts a list of vectors into an orthonormal basis for the space they span. Enter one vector per line — for example (1, 1, 0), (1, 0, 1), (0, 1, 1) — and it returns the orthogonal vectors u₁, u₂, … in exact fractions, the normalized vectors e₁, e₂, … as decimals and in exact form such as (1, −1, 2)/√6, and the length of each u.

It is built for linear algebra students working through Gram-Schmidt by hand, and for anyone preparing a QR decomposition, least-squares fit or projection onto a subspace. Because the arithmetic is done with exact rational numbers, the orthogonal vectors are the same fractions you would get on paper, and linearly dependent vectors are detected exactly rather than by a rounding threshold.

Vectors may have up to 8 components and you can enter up to 8 of them; entries can be integers, decimals or fractions like 1/2. Any vector that is a combination of the earlier ones produces a zero vector and is dropped, so the number of basis vectors equals the rank of the set. The standard dot product is used.

How to use the gram-schmidt calculator

  1. 1Type each vector on its own line, separating components with spaces or commas.
  2. 2Order matters: the first vector fixes the direction of e₁.
  3. 3Read the orthonormal basis in decimals and exact √ form.
  4. 4Check the orthogonal vectors and the steps table to follow each projection.
  5. 5Look at the rank to see whether any vectors were dependent.

Formula and method

u₁ = v₁, uₖ = vₖ − Σⱼ₌₁ᵏ⁻¹ (vₖ · uⱼ / uⱼ · uⱼ) uⱼ, eₖ = uₖ / ‖uₖ‖

The Gram-Schmidt process builds orthogonal vectors one at a time. The first is kept as it is. Each later vector has its projection onto every previous orthogonal vector subtracted, leaving only the part that points in a new direction. Dividing each orthogonal vector by its length ‖u‖ = √(u · u) makes it a unit vector, giving an orthonormal basis for the same span.

This calculator performs the projections with exact rational arithmetic, so the u vectors are exact fractions and a dependent input produces an exactly zero vector, which is dropped. The exact orthonormal form scales each u to the smallest whole-number vector w and writes e = w/√(w · w). The decimal basis is rounded to 6 places.

vₖ
The k-th input vector
uₖ
The k-th orthogonal vector
eₖ
The k-th orthonormal (unit) vector
v · u
Dot product

Worked examples

Three vectors in ℝ³

u₂ = v₂ − ½u₁ = (½, −½, 1) and u₃ = v₃ − ½u₁ − ⅓u₂ = (−⅔, ⅔, ⅔). Normalizing gives (1, 1, 0)/√2, (1, −1, 2)/√6 and (−1, 1, 1)/√3.

Two vectors in the plane

v₂ · u₁ = 8 and u₁ · u₁ = 10, so u₂ = (2, 2) − 0.8(3, 1) = (−0.4, 1.2). Dividing by the lengths √10 and √1.6 gives the rotated unit vectors shown.

A dependent set

(2, 4, 6) = 2 × (1, 2, 3), so subtracting its projection leaves the zero vector and it is dropped. The third vector gives u₂ = (1, 0, 1) − (4/14)(1, 2, 3) = (5/7, −4/7, 1/7).

Vectors in ℝ⁴

u₁ = (1, 1, 1, 1) has length 2. u₂ = (1, 2, 3, 4) − 2.5u₁ = (−1.5, −0.5, 0.5, 1.5) with length √5, and u₃ = (½, −½, −½, ½) with length 1.

Frequently asked questions

What does the Gram-Schmidt process do?+

It takes a set of linearly independent vectors and produces orthogonal (or orthonormal) vectors spanning the same subspace. Each new vector is the old one minus its projections onto the vectors already found.

What is the difference between orthogonal and orthonormal?+

Orthogonal vectors are mutually perpendicular: every pair has dot product 0. Orthonormal vectors are orthogonal and also have length 1. Gram-Schmidt gives orthogonal vectors u first; dividing each by its length gives the orthonormal e.

Does the order of the vectors matter?+

Yes. The span is the same, but the resulting basis changes with the order because e₁ always points along the first vector, e₂ lies in the plane of the first two, and so on. Reordering gives a different but equally valid orthonormal basis.

What happens if the vectors are linearly dependent?+

A vector that is a combination of earlier ones has nothing left after the projections are removed, so it becomes the zero vector. This calculator drops it and reports it, so the basis size equals the rank of the original set.

How is Gram-Schmidt related to QR decomposition?+

Applying Gram-Schmidt to the columns of a matrix A gives the orthonormal columns of Q, and the projection coefficients and lengths form the upper-triangular R, so that A = QR. QR is used for least-squares problems and eigenvalue algorithms.

Related tools