Thursday, February 10, 2011

Strang's Linear Algebra: homework (redux)

Last time (here) we worked out this problem: there is a plane formed by linear combinations of two vectors a (2,2,1) and a* (1,0,0). We can write down a matrix A from a and a*, where the linear combinations of the columns of A form the plane:

A = [ 2  1 ]
[ 2 0 ]
[ 1 0 ]

We then consider a vector b that is not in the plane (3,4,4). Another way of stating this is to say that:

Ax = b

has no solutions. Then we ask, what is the linear projection of b onto the plane? Call that projection p. We want to decompose b into p, the part in the plane, and e, which is perpendicular to the plane (see the figure at the top).

Since e is perpendicular, this e is the shortest e that goes from a point in the plane "up" to the vector b. We solved the problem by deriving an equation for x, which is a vector whose coefficients are the linear combinations of the columns of A to give p:

p = Ax
e = b - p

The insight is that every vector in the plane is perpendicular to e:

a  • e = 0
a* • e = 0

which is exactly the same as:

ATe = 0 = ATb - ATp 
= ATb - ATAx

So then we solved (in succession):

x = (ATA)-1 ATb
p = Ax
e = b - p

But it occurs to me that there is another way to think about the problem.

This plane formed by the combinations of a (2,2,1) and a* (1,0,0) will have a normal vector n, where e is some linear multiple of n. n can be found because its dot product with every vector in the plane is equal to zero. It is easy to show that

n = (0,1,-2)
n • a = (0,1,-2) • (2,2,1) = 0 + 2 - 2 = 0
n • a* = (0,1,-2) • (1,0,0) = 0 + 0 + 0 = 0

Probably the simplest method is to take the cross product a x a*. We write the two vectors as rows in a matrix with the unit vectors i, j, k as the first row (this isn't strictly legal, but it's easy to remember). The answer is the "determinant" of this 3 x 3 matrix:

i  j  k
2 2 1
1 0 0

a x a* = 0i + 1j -2k

Without bothering about normalizing to make n a unit vector, let's turn things around.

Consider the problem as one of projection onto a line (as we did in the simpler first part of the previous post). That is, think of e as the projection of b onto n. We're looking for z (a number) which tells how much of n we take to get e:

p = xa
e = zn

The equation to solve from last time was:

p = xa = (aTb / aTa) a

I just substitute the new symbols into the old equation.

e = zn = (nTb / nTn) n

Now it's easy:

n = [  0 ]     b = [ 3 ]
[ 1 ] [ 4 ]
[ -2 ] [ 4 ]

nT = [ 0 1 -2 ]
nTb / nTn = -4/5

e = zn = -4/5 [ 0 ]
[ 1 ]
[ -2 ]

which is exactly the same as before. And it seems like this might be really useful because as we ascend into n-dimensional space, the previous method will involve inverses and transposes of big matrices, while this method will still be just the projection of one vector onto another one. The only trick will be to find n.