Orthonormal bases

Gram Schmidt calculator

Educational tool; results are estimates for learning, verify with your textbook or instructor.

A calculator and handwritten orthogonal vectors on a wooden desk.
A calculator beside the sort of vector list a first linear algebra course orthonormalizes by hand.

This page is a Gram Schmidt calculator with steps. It takes two, three, or four vectors in dimension 2, 3, or 4 and builds an orthogonal set, then unit vectors, then the QR factors when the vectors are independent. Each entry can be an integer, a decimal, or a fraction such as 3/4. A decimal is an exact fraction of a power of ten, so 0.5 is 1/2. The projections stay exact.

The projection of a vector a onto a nonzero vector u is ((a · u) / (u · u)) u. Subtract that piece and the remainder is orthogonal to u. Do this for each new vector, projecting onto the orthogonal vectors already built, not onto the original list. That is the classical Gram Schmidt process. With exact fractions it agrees with the modified process. Decimal software often prefers the modified order because rounding can tilt the classical vectors off orthogonality. This page does not round.

A zero remainder means the new vector was already in the span of the earlier ones. The set is linearly dependent, that direction has no unit vector, and the page will not invent a QR factorization of the full list. Dividing a nonzero orthogonal vector by its length makes a unit vector. The length is a square root. The page pulls perfect squares out of the root, so a squared length of 2 produces factors of sqrt(2), and a squared length of 25 produces an exact fraction with no radical.

The box opens on (1, 1, 0), (1, 0, 1), and (0, 1, 1). The same arithmetic is written below, so you can read it with scripts turned off. A single dot product, without the whole process, is the vector operations calculator. Dependence of a list by row reduction is the reduced row echelon form calculator. The map of the course is linear algebra.

Vectors, one per row

Integers, decimals, and fractions such as 3/4 or −2/5. The first row is the first vector. Order matters.

What the process is doing

An orthogonal set is a list of nonzero vectors whose pairwise dot products are zero. An orthonormal set is an orthogonal set in which every vector has length 1. The Gram Schmidt process starts with a list that may be neither, and it builds the orthogonal list one vector at a time. The first vector is copied. Each later vector loses its projections onto the directions already accepted. What survives is perpendicular to all of them.

The formula is forced by one demand. The remainder a − c u should have dot product zero with u. Expand (a − c u) · u = 0 and solve for c. You get c = (a · u) / (u · u), provided u is not zero. There is no new idea after that sentence. The rest is bookkeeping: use the new remainder, not the original vector, as the direction for the next projection.

If every remainder is nonzero, stack the unit vectors as the columns of Q. The numbers that rebuild each input from those unit vectors form an upper triangular matrix R, and the matrix A with your vectors as columns satisfies A = Q R. The diagonal entries of R are the lengths of the orthogonal vectors. This page keeps the sign that subtraction produced, so those lengths are positive. A textbook that flips a vector before normalizing will show the opposite sign in that column of Q and in that row of R. The product Q R is the same.

A fully worked example

The vectors already filled in are v₁ = (1, 1, 0), v₂ = (1, 0, 1), and v₃ = (0, 1, 1). The first vector is already orthogonal to nothing, so it stays (1, 1, 0), with squared length 2. Its unit vector is (sqrt(2)/2, sqrt(2)/2, 0). The second vector loses (1/2, 1/2, 0) and becomes (1/2, −1/2, 1). The third loses a projection onto each of those, and the remainder is (−2/3, 2/3, 2/3). All three dot products of distinct orthogonal vectors are zero. The lines below match the calculator.

Input vectors, in the order they will be processed.
v₁ = (1, 1, 0)
v₂ = (1, 0, 1)
v₃ = (0, 1, 1)
The classical Gram Schmidt process subtracts projections onto the orthogonal vectors already built. Exact fractions make the order agree with the modified process. Decimal arithmetic can make those two orders differ, and this page does not use decimals.
Vector 1 starts as (1, 1, 0).
Orthogonal vector 1 is (1, 1, 0).
Squared length 2.
Vector 2 starts as (1, 0, 1).
Projection of v₂ onto orthogonal vector 1.
Dot product 1, squared length 2, coefficient 1/2.
Projection vector (1/2, 1/2, 0).
After subtracting that projection, the running vector is (1/2, −1/2, 1).
Orthogonal vector 2 is (1/2, −1/2, 1).
Squared length 3/2.
Vector 3 starts as (0, 1, 1).
Projection of v₃ onto orthogonal vector 1.
Dot product 1, squared length 2, coefficient 1/2.
Projection vector (1/2, 1/2, 0).
After subtracting that projection, the running vector is (−1/2, 1/2, 1).
Projection of v₃ onto orthogonal vector 2.
Dot product 1/2, squared length 3/2, coefficient 1/3.
Projection vector (1/6, −1/6, 1/3).
After subtracting that projection, the running vector is (−2/3, 2/3, 2/3).
Orthogonal vector 3 is (−2/3, 2/3, 2/3).
Squared length 4/3.
Unit vectors divide each nonzero orthogonal vector by the square root of its squared length. A zero remainder has no direction, so it has no unit vector.
Unit vector 1 is (sqrt(2)/2, sqrt(2)/2, 0).
Unit vector 2 is (sqrt(6)/6, −sqrt(6)/6, sqrt(6)/3).
Unit vector 3 is (−sqrt(3)/3, sqrt(3)/3, sqrt(3)/3).
QR factorization. The columns of Q are the unit vectors. R is upper triangular, and column j of the input is Q times column j of R. The diagonal entries of R are the lengths of the orthogonal vectors.
Q
Row 1: sqrt(2)/2, sqrt(6)/6, −sqrt(3)/3
Row 2: sqrt(2)/2, −sqrt(6)/6, sqrt(3)/3
Row 3: 0, sqrt(6)/3, sqrt(3)/3
R
Row 1: sqrt(2), sqrt(2)/2, sqrt(2)/2
Row 2: 0, sqrt(6)/2, sqrt(6)/6
Row 3: 0, 0, 2 sqrt(3)/3
Check passed: Q times R rebuilds the input matrix whose columns are v₁ through v₃.

Common mistakes

The first mistake is projecting onto the original vectors after the first step. For v₃ you must use the orthogonal remainder of v₂, not v₂ itself. Using v₂ leaves a remainder that is not perpendicular to the second direction.

The second mistake is treating a different order as a wrong answer. Swap v₁ and v₂ and the orthogonal vectors change. The span does not. If a homework key starts with a different vector, reorder the rows before you compare.

The third mistake is normalizing too early and then rounding. The orthogonal vector (1/2, −1/2, 1) has squared length 3/2. Its unit vector is exact: (sqrt(6)/6, −sqrt(6)/6, sqrt(6)/3). A decimal such as 0.408 can fail a later dot product check even though the algebra was right.

The fourth mistake is reading a zero remainder as a broken calculator. Zero means dependence. The linear independence glossary line is the definition that remainder is testing. You can also row reduce the matrix with these vectors as rows on the RREF calculator. A zero row there is the same news.

Pitfall. This page uses the ordinary dot product. If your basis is not orthonormal and the inner product is a different formula, these lengths and angles are the wrong ones. Eigenvectors from the 3x3 eigenvalue calculator are a different basis. They are not the output of Gram Schmidt unless the matrix was symmetric and you were building an orthonormal eigenbasis by hand.

Related reading

The surrounding map is the linear algebra pillar, and the ordered route is the linear algebra first course. Glossary lines for vector, span, basis, and linear independence are the words this arithmetic is about. A dot product you already computed can be checked on the vector operations calculator. That page does not run this process.

Once the columns are orthonormal, a later course multiplies by Q transpose instead of inverting Q, because Q transpose Q is the identity. The factors on the LU decomposition calculator are a different splitting, from elimination rather than from orthogonality. Do not mix the two letters.

Disclaimer. Educational estimate only. This page is not a computer algebra system and not a proof. See the site disclaimer and the FAQ on calculators versus understanding.

Sources

Last reviewed: 26 October 2026.

Common questions

What does a Gram Schmidt calculator with steps show?

It subtracts the projection of each new vector onto the orthogonal vectors already built, writes the coefficient and the projection, and keeps the remainder. Nonzero remainders are then divided by their lengths. When every remainder is nonzero, the unit vectors are the columns of Q and the rebuilding coefficients are an upper triangular R.

What is the difference between an orthogonal set and an orthonormal set?

Orthogonal vectors have pairwise dot products equal to zero. Orthonormal vectors are orthogonal and each has length 1. This page builds the orthogonal vectors with exact fractions, then writes the unit vectors with simplified square roots.

Why does the order of the vectors change the result?

Each new direction is what remains after removing the span of the vectors that came before it. A different order removes a different span first, so the orthogonal vectors change. The span of the whole list does not change.

When does Gram Schmidt say the vectors are linearly dependent?

When a remainder is the zero vector. That input vector was already a combination of the earlier ones, so it adds no new direction and it has no unit vector. The page then refuses a QR factorization of the full list.

How is QR related to the Gram Schmidt process?

Put the input vectors in the columns of A. If they are independent, the unit vectors from this process are the columns of Q, and A = Q R with R upper triangular. The diagonal entries of R are the lengths of the orthogonal vectors, which this page keeps positive.

Why do the unit vectors still contain a square root?

The orthogonal vectors are exact fractions. Their lengths are square roots of those fractions. The page factors squares out of the root, so a factor of 8 under a radical becomes 2 sqrt(2), and it leaves the square free part under the radical. A perfect square length becomes an exact fraction with no radical.

Want a tool that matches a new explainer, or a check that a page and a calculator disagree? Write a short note.

Suggest a topic or tool