🧮
🧮 Math & statistics

Gram–Schmidt Calculator (orthonormal basis from a set of vectors)

Results update as you type.

Your numbers

Understanding the Gram–Schmidt calculator — concept and principle

This calculator turns a set of vectors into an orthonormal basis for the same space with the Gram–Schmidt process. It shows the orthogonal vectors before scaling, their lengths, the final unit vectors and which inputs were dependent. Use it for linear algebra homework, QR decomposition and least-squares problems.

Gram–SchmidtRemove the parts along earlier vectorsf₁v₁(1, 1, 0)len 1.41421f₂v₂ − ½ f₁(1/2, −1/2, 1)len 1.22474f₃v₃ − ½ f₁ − ⅓ f₂(−2/3, 2/3, 2/3)len 1.1547divide by lengths → orthonormal, dimension 3(0.707, 0.707, 0) · (0.408, −0.408, 0.816) · …
Each new vector keeps only the part perpendicular to the ones already chosen.

How it is calculated

f₁ = v₁

f_k = v_k − Σ_(j<k) (v_k · f_j ÷ ‖f_j‖²) f_j

q_k = f_k ÷ ‖f_k‖

The principle

Projecting v_k onto f_j finds the part of v_k that points along f_j. Subtracting all such parts leaves only what is new, perpendicular to everything before. Doing this vector by vector builds perpendicular directions spanning the same space, and dividing by their lengths makes them unit vectors. Orthonormal bases are convenient because coordinates become simple dot products and lengths and angles are preserved.

Worked example

Default input: v₁ = (1, 1, 0), v₂ = (1, 0, 1), v₃ = (0, 1, 1).

  1. f₁ = (1, 1, 0), length √2 = 1.41421.
  2. v₂ · f₁ = 1, so f₂ = (1, 0, 1) − ½(1, 1, 0) = (1/2, −1/2, 1), length 1.22474.
  3. v₃ · f₁ = 1 and v₃ · f₂ = 1/2, so f₃ = (0, 1, 1) − ½(1, 1, 0) − (1/3)(1/2, −1/2, 1) = (−2/3, 2/3, 2/3), length 1.1547.
  4. Lengths: 1.41421, 1.22474, 1.1547; none skipped (none); dimension 3.
  5. Orthonormal vectors: (0.707107, 0.707107, 0), (0.408248, −0.408248, 0.816497), (−0.57735, 0.57735, 0.57735).

How to read the result

Check two properties: every q has length 1, and the dot product of any two different q's is 0. For example q₁ · q₂ = 0.288675 − 0.288675 + 0 = 0. Starting from a different order of the input vectors gives a different but equally valid orthonormal basis.

Common mistakes

Keep in mind: Classical Gram–Schmidt can lose orthogonality with nearly dependent vectors; this page repeats each projection, but for large problems use a QR routine from a numerical library.

Frequently asked questions

What does the Gram–Schmidt process do?

It turns independent vectors into orthonormal vectors spanning the same space.

What if the vectors are dependent?

A zero vector appears; that input is skipped and the span has lower dimension.

How is it related to QR decomposition?

The q vectors form Q, and the projection coefficients form R.

Sources: D. Margalit & J. Rabinoff, Interactive Linear Algebra, §6.4 Orthogonal Sets (Gram–Schmidt process)

Checked 9 Nov 2026. Coordinated Linear Algebra (University of Nebraska–Lincoln), §7.6 Extra Topic: QR Factorization — Gram–Schmidt process (f₁ = c₁; each later vector minus its projections onto the earlier f’s; normalise q(k) = f(k)/‖f(k)‖).

🧮 All math & statistics tools →🌍 Calculators by country →