Gram–Schmidt Process Explained with Worked Examples

The Gram–Schmidt process turns independent vectors into perpendicular vectors by subtracting projections: , , and so on. Divide each by its length for an orthonormal set.

Write 2x or 2*x to multiply, ^ for powers, and ; between simultaneous equations. You can also type factor, expand, derivative of, integrate … from a to b, limit … as x->0 or 15% of 80.

Try an example

Before you start

This page is easier if you are comfortable with:

What Gram–Schmidt process means

Each new vector has its components along the earlier ones removed, using the orthogonal projection. What is left is perpendicular to everything before it, which you can confirm with dot products.

Dividing by the magnitude gives unit vectors. Placing them as columns gives an orthogonal matrix , and recording the projections gives the triangular matrix in QR factorisation.

The process builds a convenient basis for any subspace, useful for changing basis and for least-squares problems.

What is it used for?

The Gram–Schmidt process builds a set of perpendicular vectors that span the same space as a given set. It is a standard route to orthonormal bases.

How to use gram–schmidt process

  1. Keep .
  2. Subtract from its projection onto .
  3. For further vectors subtract the projections onto all earlier ’s.
  4. Normalise if an orthonormal basis is required.

Graph

Gram–Schmidt on (3, 4) and (1, 2)u₁ = v₁v₂u₂ (perpendicular)-2-1012345-1012345Gram–Schmidt on (3, 4) and (1, 2)xyGraph with x from -2 to 5 and y from -1 to 5. Shows point u₁ = v₁ at (3, 4); point v₂ at (1, 2); point u₂ (perpendicular) at (-0.32, 0.24).

Removing the part of v₂ along u₁ leaves a vector perpendicular to u₁.

Worked examples

These examples are worked by hand, step by step, so you can compare your own working.

Example 1: two vectors in 3D

Apply Gram–Schmidt to , .

Worked example Answer checked
Answer
u2=(12,−12,1)\mathbf{u}_{2}=\left(\tfrac12,-\tfrac12,1\right)
  1. u₁
  2. Projection coefficient
  3. u₂
  4. Check u₁ · u₂

Example 2: two vectors in 2D

Apply Gram–Schmidt to , .

Worked example Answer checked
Answer
u2=225(−4,3)\mathbf{u}_{2}=\tfrac{2}{25}(-4,3)
  1. Coefficient
  2. u₂
  3. Check

Example 3: normalising

Normalise .

Worked example
Answer
12(1,1,0)\tfrac1{\sqrt2}(1,1,0)
  1. Length

Special cases

A few situations come up again and again. Knowing them saves time and helps you spot answers that cannot be right.

v₁ = (1, 1), v₂ = (1, 0)

coefficient v₂·u₁/u₁·u₁

0.5.

same

u₂ = (1, 0) − 0.5(1, 1) x

0.5.

same

u₂ y

−0.5.

v₁ = (1, 0, 1), v₂ = (1, 1, 0)

|u₂|

1.2247.

Word problems

u₁ = v₁, u₂ = v₂ − ((v₂·u₁)/(u₁·u₁))u₁, and so on. The uᵢ are mutually perpendicular; divide by lengths to get an orthonormal set.

Coefficient

v₂·u₁ = 1, u₁·u₁ = 2.

  1. 1/2
  2. Check: ✓0.5

u₂ x

1 − 0.5.

  1. 0.5
  2. Check: ✓0.5

u₂ y Higher

0 − 0.5.

  1. −0.5
  2. Check: u₁·u₂ = 0 ✓-0.5

3D Higher

u₂ = (0.5, 1, −0.5).

  1. √1.5
  2. Check: ✓1.2247

Common mistakes

Subtracting v₁ not u₁

v₁ ✗

u₁ ✓

Use the orthogonalised vector.

Forgetting the coefficient

v₂ − u₁ ✗

v₂ − (coef)u₁ ✓

Projection.

Orthogonal means orthonormal

same ✗

divide by length for unit ✓

Normalise.

Dependent vectors

ignored ✗

u becomes 0 ✓

Needs independence.

Exam tips

  1. u₁ = v₁.
  2. Subtract projections onto earlier u’s.
  3. Check dot products are 0.
  4. Normalise at the end.
  5. Order matters.

Practice questions

Try each one on paper, then open the answer. Use the solver above to see the full working.

1. Coefficient: v₁ = (1, 0), v₂ = (2, 3) Foundation

2

2. u₂ y: v₁ = (1, 0), v₂ = (2, 3) Foundation

3

3. Coefficient: v₁ = (1, 2), v₂ = (3, 1) Foundation

1

4. u₂ x: v₁ = (1, 2), v₂ = (3, 1) Higher

2

5. u₂ y: v₁ = (1, 2), v₂ = (3, 1) Higher

-1

6. |u₁| for v₁ = (3, 4) Higher

5

Practice generator

Unlimited fresh questions with instant marking. Choose a level, work it out on paper, then type your answer.

Solve: …

Key terms

Gram–Schmidt
Orthogonalisation.
Orthogonal set
Mutually perpendicular.
Orthonormal
Unit length too.
Projection
Component along earlier vectors.
Independent vectors
Needed.
QR factorisation
Result in matrix form.

Frequently asked questions

What does Gram–Schmidt do?

Turns independent vectors into orthogonal vectors.

What is the formula for u₂?

v₂ − ((v₂·u₁)/(u₁·u₁))u₁.

How do I make them orthonormal?

Divide each by its length.

Does the order matter?

Yes, results differ.

Which page covers projection?

orthogonal projection.

Which page covers QR?

QR and Cholesky factorisations.

More in Vectors and matrices and the formula sheets.