HomeMath › Gram Schmidt Calculator

Gram Schmidt Calculator

Turn a set of vectors into an orthonormal basis with the Gram-Schmidt process. Enter 2 or 3 vectors as comma-separated components (2D or 3D) to get the orthonormal vectors e1, e2 and e3 plus an orthogonality check.

Example: with Vector 1 1, 1, 0 · Vector 2 1, 0, 1 · Vector 3 (optional) 0, 1, 1 → e1 (normalized): (0.7071, 0.7071, 0).

  • e2 (normalized)(0.4082, -0.4082, 0.8165)
  • e3 (normalized)(-0.5774, 0.5774, 0.5774)
  • Orthogonality checke1·e2=0, e1·e3=0, e2·e3=0 (0 = orthonormal)

Computed by the calculator below using its default values. Change any input to see your own numbers.

e1 (normalized)
e2 (normalized)
e3 (normalized)
Orthogonality check

Each new vector has the projections onto every earlier orthogonal vector subtracted, then is normalized to length 1. The dot product of any two results is 0, which is what orthonormal means.

How the process works

Gram-Schmidt takes vectors that are not perpendicular and rebuilds them into a set that is, without changing the space they span. The first vector is kept and normalized to length 1. Each later vector has its projection onto every earlier orthogonal vector subtracted, which strips out any component already covered; what remains is perpendicular to all of them and is then normalized.

The default vectors show it clearly. v1 = (1, 1, 0) becomes e1. From v2 = (1, 0, 1) the process removes the part along e1, leaving a piece perpendicular to it, and normalizes to e2. v3 loses its components along both e1 and e2, giving e3. The check line confirms every pair has a dot product of 0.

How it’s calculated

Classical Gram-Schmidt. Set u1 = v1. For each later vector, uk = vk − Σ (vk·uj / uj·uj) uj over all earlier uj. Normalize each uk to ek = uk / |uk|. Vectors shorter than the longest are zero-padded to a common dimension. A vector that reduces to length 0 is flagged as dependent (it lies in the span of the earlier ones).

Order matters: e1 always points along v1. Near-dependent inputs can lose precision because a tiny remaining vector is normalized; results are rounded to four decimals.

Default run, step by step

StepVectorResult
Keep v1(1, 1, 0)e1 = (0.707, 0.707, 0)
v2 minus proj on e1(1, 0, 1)e2 = (0.408, -0.408, 0.816)
v3 minus proj on e1, e2(0, 1, 1)e3 = (-0.577, 0.577, 0.577)
Checke_i · e_jall 0

Computed with classical Gram-Schmidt on the default vectors; rounded.

Common mistakes

  • Subtracting the projection onto the raw earlier vector instead of onto the orthogonalized one.
  • Forgetting to normalize, which gives an orthogonal but not orthonormal set.
  • Changing the input order and expecting the same basis — e1 always follows the first vector.
  • Feeding in linearly dependent vectors, which collapse one output to the zero vector.

Frequently asked questions

What does the Gram-Schmidt process do?

It converts a set of linearly independent vectors into an orthonormal set that spans the same subspace. Each output vector has length 1 and is perpendicular to all the others.

What is the Gram-Schmidt formula?

For each vector, uk = vk − Σ (vk·uj / uj·uj) uj summed over the earlier orthogonal vectors uj, then ek = uk / |uk|. The subtraction removes overlap; the division normalizes.

Why did one of my vectors come out as dependent?

Its orthogonal remainder was zero, meaning it lies in the span of the earlier vectors. Only linearly independent inputs produce a full orthonormal set.

Does the order of the vectors matter?

Yes. The first vector sets e1, so different orderings give different orthonormal bases, though each spans the same space.