6.11.1. Projections Onto a Line¶
A nice aspect of linear algebra is its geometric interpretation. That is, if we consider linear algebra problems in or , then we can plot the vectors to visually depict the geometric relationships. This is the case with project, which gives us a geometric view of over-determined systems. We will begin with the simplest of examples and later extend the concepts to higher dimensions.
Consider the following over-determined system where the unknown variable is a scalar.
(6.29)¶
Figure Fig. 6.24 is a plot of the vectors and .
Here is a scalar, not a vector, and we can quickly see that satisfies both rows of equation (6.29). But since and are both vectors, we want to use a strategy that will extend to matrices. We can multiply both sides of equation (6.29) by so that the vectors turn to scalar dot products.
(6.30)¶
Now, let’s extend the problem to a more general case as shown in figure Fig. 6.25 where vector is not necessarily in-line with . We will find a geometric reason to multiply both sides of equation (6.29) by .
We wish to project a vector onto vector , such that the error between and the projection is minimized. The projection, , is a scalar multiple of . That is, , where is the scalar value that we want to find. The error is the vector .
The geometry of the problem provides a simple solution for minimizing the error. The length of the error vector is minimized when it is perpendicular to . Recall that two vectors are perpendicular (orthogonal) when their dot product is equal to zero.
Since is a fraction of two dot products, we can think of the projection in terms of the angle, , between and .
The projection is then:
We can also make a projection matrix, , so that any vector may be projected onto by multiplying it by .
Note that is here a matrix and is a scalar. Here is an example.
>> b = [3; 3]; a = [4; 2];
>> P = a*a'/(a'*a) % Projection Matrix to a
P =
0.8000 0.4000
0.4000 0.2000
>> p = P*b % Projection of b onto a
p =
3.6000
1.8000
>> x = a'*b/(a'*a) % length of projection
x =
0.9000
>> e = b - p % error vector
e =
-0.6000
1.2000
>> p'*e % near zero dot product to
ans = % confirm e is perpendicular to p.
-4.4409e-16