9.2: Gram-Schmidt Orthogonalization
( \newcommand{\kernel}{\mathrm{null}\,}\)
Suppose that M is an m-dimensional subspace with basis
{x1,⋯,xm}
We transform this into an orthonormal basis
{q1,⋯,qm}
for M via
1. Set y1=x1 and q1=y1||y1||
2. y2=x2 minus the projection of x2 onto the line spanned by q1.
That is,y2=x2−q1(qT1q1)−1qT1x2=x2−q1qT1x2
Set q2=y2||y2|| and Q2={q1,q2}
3. y3=x3 minus the projection of x3 onto the plane spanned by q1 and q2. That is,
y3=x3−Q2(QT2Q2)−1QT2x3=x3−q1qT1x3
Set q3=y3||y3|| and Q3={q1,q2,q3}. Continue in this fashion through step (m)
- (m) ym=xm minus its projection onto the subspace spanned by the columns of Qm−1
ym=xm−Qm−1(QTm−1Qm−1)−1QTm−1xmxm−m−1∑j=1qjqTjxm
Set qm=ym||ym||. To take a simple example, let us orthogonalize the following basis for R3
x1=(100)x2=(110)x3=(111)
- q1=y1=x1
- y2=x2−q1qT1x2=(010)T and so, q2=y2
- y3=x3−q2qT2x3=(001)T and so, q3=y3
We have arrived at
q1=(100)q2=(010)q3=(001)
Once the idea is grasped the actual calculations are best left to a machine. Matlab accomplishes this via the orth command. Its implementation is a bit more sophisticated than a blind run through our steps (1) through (m). As a result, there is no guarantee that it will return the same basis. For example
>>X=[1 1 1;0 1 1 ;0 0 1]; >>Q=orth(X) Q= 0.7370 -0.5910 0.3280 0.5910 0.3280 -0.7370 0.3280 0.7370 0.5910
This ambiguity does not bother us, for one orthogonal basis is as good as another. Let us put this into practice, via (10.8).