The Projection Matrix David Arnold Fall 996 Abstract In this activity you will use Matlab to project a set of vectors onto a single vector. Prerequisites. Inner product (dot product) and orthogonal vectors. The Inner Product We begin with the de nition of the inner product. De nition Let K and L be vectors from 4 n. The inner product (dot product) of vectors K and L is de ned by K L K T L Example If K and L, then Check this result in Matlab. >> u[;] K L K T L 0 u >> v[-4;] v -4
>> u *v ans 0 If K, L and M are vectors from 4 n and c is any real number, then it is not di cult to show that each of the following properties are true: ² K L L K ² K (L + M) K L + K M ² (ck) L K (cl) c(k L) ² K K 0 and K K 0if and only if K. Finally, orthogonal (perpendicular) vectors are de ned as follows. De nition 3 Let K and L be vectors from 4 n. Vectors K and L are orthogonal if and only if K L 0.. The Projection of One Vector Onto Another Figure shows the projection of vector K onto vector L. u proj v L u Figure. The projection of K onto L. In Figure, it is clear that the projection of K onto L is some scalar multiple of L; that is, proj L K cl.
u u-cv cv v Figure. The vector K cl is orthogonal to L. Note that the di erence vector K cl is orthogonal (perpendicular) to L. Consequently, L (K cl) 0 and we can use the previously mentioned properties to arrive at the following result: L K L (cl) 0 L K c(l L) 0 c(l L) L K c L K L L Finally, substitute result () into proj L K cl. () proj L K L K L L L () Example 4 Use formula () to nd the projection of K : onto L proj L K L K L L L 0 0 Check this result in Matlab. 3
>> (v *u)/(v *v)*v ans -. The Projection Matrix Let s rework formula (). First, when you multiply a vector by a scalar, it doesn t matter whether you position the scalar before or after the vector. proj L K L K L L L L L K L L Next, use the transpose de nition of the inner product followed by the associative property of multiplication. Remember, when performing the dot product, a scalar multiplier may be placed anywhere you wish. proj L K L T L L(LT K) L T L (LLT )K LLT L T L K The expression LL T is called an outer product (the transpose operator is outside the product versus its inside position in the inner product). If we de ne P LLT, then the projection formula becomes L T L proj L K P K, where P LLT L T L : The matrix P is called the projection matrix. You can project any vector onto the vector L by multiplying by the matrix P. Example 5 Let K onto L and nd P, the matrix that will project any matrix onto the vector L. Use the result to nd proj L K. First, nd the projection matrix. P LLT L T L T T 4
6 8 8 4 0 : 8 : 4 : 4 : Check this result in Matlab. >> P(v*v )/(v *v) P 0.8000-0.4000-0.4000 0.000 Use this result to nd the projection of K onto L. proj L K P K Check this last result in Matlab. >> P*u : 8 : 4 : 4 : ans - Note that this is identical to the result in Example 4..3 Projecting a Lot of Vectors onto a Single Vector First, use Matlab to generate 00 random vectors and plot them. The following commands will produce an image similar to that in Figure 3. >> U8*rand(,00)-4; >> xu(,:); >> yu(,:); >> plot(x,y, o ) 5
4 0 - -4-4 - 0 4 Figure 3. The image in Figure 3 bears some explanation. Each circle in Figure 3 represents the tip of a vector whose tail begins at the origin. Next, use the projection matrix P to project each of the 00 vectors in matrix U onto the vector L, then plot the results on the graph in the color red. >> PUP*U; >> xpu(,:); >> ypu(,:); >> hold on >> plot(x,y, ro ) 4 0 - -4-4 - 0 4 Figure 4. In Figuure 4, note that each vector in the matrix U is projected onto a line in the direction of the vector L. Homework. Create 00 random vectors in a matrix U with components between and. Plot them. 6
(a) Create a matrix P which will project each of the vectors in matrix U onto the vector L. (b) Use the matrix P to project each vector in matrix U onto the vector L. Plot the results in a second color. (c) Obtain a printout of your result.. The column space of the projection matrix P is a line in the direction of the vector L. (a) What is the dimension of the column space of P? Check your answer with the ATLAST distribution s colbasis command. (b) What is the rank of P? command. Check your answer with Matlab s rank 3. If matrix P projects all vectors onto the vector L, what should the matrix PP do? Can you explain geometrically why the matrices PP and P are equal? Check this in Matlab.