back to the math tutorial index back to the math tutorial index

The Gram-Schmidt Algorithm

In any inner-product space, we can choose the basis in which to work. It often greatly simplifies calculations to work in an orthogonal basis. For one thing, if S = {v1, v2,¼, vn} is an orthogonal basis for an inner product space V, then it is a simple matter to express any vector w Î V as a linear combination of the vectors in S:

w = áw,v1ñ
|| v1 ||2
v1 + áw,v2ñ
|| v2 ||2
v2 +¼+ áw,vnñ
|| vn ||2
vn.
That is, w has coordinates
é
ê
ë
á w,v1 ñ
||v1||2
v1   á w,v2 ñ
||v2||2
v2  . . . á w,vn ñ
||vn||2
vn   ù
ú
û
T



relative to the basis S.

Given an arbitrary basis {u1, u2, ¼, un} for an n-dimensional inner product space V, the Gram-Schmidt algorithm constructs an orthogonal basis {v1, v2,¼, vn} for V:       

Step 1:   Let v1 = u1
Step 2:   Let v2 = u2 - projW1u2 = u2 - [ áu2,v1ñ / || v1||2 ]v1 where W1 is the space spanned by v1, and projW1u2 is the orthogonal projection of u2 on W1.
Step 3:   Let v3 = u3 -projW2 u3 = u3- [ áu3,v1ñ / || v1 ||2 ]v1 - [ áu3,v2ñ / || v2 ||2 ]v2 where W2 is the space spanned by v1 and v2.
Step 4:   Let v4 = u4 -projW3 u4 = u4- [ áu4,v1ñ / || v1 ||2 ]v1 - [ áu4,v2ñ / || v2 ||2 ]v2 - [ áu4,v3ñ / || v3 ||2 ]v3 where W3 is the space spanned by v1, v2 and v3.
  .
.
.
 

Continue this process up to vn. The resulting orthogonal set {v1,v2,¼,vn} consists of n linearly independent vectors in V and so forms an orthogonal basis for V.

Notes

  • To obtain an orthonormal basis for an inner product space V, use the Gram-Schmidt algorithm to construct an orthogonal basis. Then simply normalize each vector in the basis.

  • For Rn with the Eudlidean inner product (dot product), we of course already know of the orthonormal basis { (1,0,0,¼,0), (0,1,0,¼,0), ¼, (0, ¼,0,1)}. For more abstract spaces, however, the existence of an orthonormal basis is not obvious. The Gram-Schmidt algorithm is powerful in that it not only guarantees the existence of an orthonormal basis for any inner product space, but actually gives the construction of such a basis.

Example

Let V = R3 with the Euclidean inner product. We will apply the Gram-Schmidt algorithm to orthogonalize the basis { (1,-1,1),(1,0,1),(1,1,2)}.

Step 1:     v1 = (1,-1,1)
Step 2:     v2 =
(1,0,1) - (1,0,1) · (1,-1,1)
||(1,-1,1)||2
(1,-1,1)
  =
(1,0,1) - 2
3
(1,-1,1)
  =
æ
ç
è
1
3
, 2
3
, 1
3
ö
÷
ø
.
Step 3:     v3 =
(1,1,2) - (1,1,2) · (1,-1,1)
||(1,-1,1)||2
(1,-1,1) - (1,1,2) · (1/3,2/3,1/3)
||(1/3,2/3,1/3)||2
(1/3,2/3,1/3)
  =
(1,1,2) - 2
3
(1,-1,1) - 5
2
(1/3,2/3,1/3)
  = (-1/2,0,1/2)

You can verify that { (1,-1,1),(1/3,2/3,1/3),(-1/2,0,1/2)} forms an orthogonal basis for R3. Normalizing the vectors in the orthogonal basis, we obtain the orthonormal basis

ì
í
î
æ
ç
è
Ö3
3
, -Ö3
3
, Ö3
3
ö
÷
ø
, æ
ç
è
Ö6
6
, Ö6
3
, Ö6
6
ö
÷
ø
, æ
ç
è
-Ö2
2
, 0, Ö2
2
ö
÷
ø
ü
ý
þ
.


Key Concept

Given an arbitrary basis { u1,u2,¼,un} for an n-dimensional inner product space V, the Gram-Schmidt algorithm constructs an orthogonal basis { v1,v2,¼,vn} for V:

Step 1:     Let v1 = u1.
Step 2:     Let v2 =
u2 - áu2, v1ñ
||v1||2
v1.
Step 3:     Let v3 =
u3 - áu3, v1ñ
||v1||2
v1 - áu3, v2ñ
||v2||2
v2.
                  .
                  .
                  .