projections
projections
projections
by Dan Klain
October 16, 2018
Corrections and comments are welcome.
Orthogonal Projections
A = X1 X2 · · · Xk .
Note that each vector Xi ∈ Rn has n coordinates, so that A is an n × k matrix. The set
of conditions listed in (2) can now be re-written:
A T (Y − Ŷ ) = 0,
which is equivalent to
(3) A T Y = A T Ŷ.
X1
Ŷ
X2
W o
words,
c1
c2
Ŷ = c1 X1 + c2 X2 + · · · + ck Xk = A
... = AC.
ck
where C is a k-dimensional column vector. On combining this with the matrix equa-
tion (3) we have
A T Y = A T AC.
If we knew what C was then we would also know Ŷ, since we were given the columns
Xi of A, and Ŷ = AC. To solve for C just invert the k × k matrix A T A to get
(4) ( A T A)−1 A T Y = C.
How do we know that ( A T A)−1 exists? Let’s assume it does for now, and then address
this question later on.
Now finally we can find our projected vector Ŷ. Since Ŷ = AC, multiply both sides
of (4) to obtain
A( A T A)−1 A T Y = AC = Ŷ.
The matrix
Q = A ( A T A ) −1 A T
is called the projection matrix for the subspace W. According to our derivation above, the
projection matrix Q maps a vector Y ∈ Rn to its orthogonal projection (i.e. its shadow)
QY = Ŷ in the subspace W.
It is easy to check that Q has the following nice properties:
(1) Q T = Q.
(2) Q2 = Q.
One can show that any matrix satisfying these two properties is in fact a projection
matrix for its own column space. You can prove this using the hints given in the
exercises.
3
There remains one problem. At a crucial step in the derivation above we took the
inverse of the k × k matrix A T A. But how do we know this matrix is invertible? It
is invertible, because the columns of A, the vectors X1 , . . . , Xk , were assumed to be
linearly independent. But this claim of invertibility needs a proof.
Lemma 1. Suppose A is an n × k matrix, where k ≤ n, such that the columns of A are
linearly independent. Then the k × k matrix A T A is invertible.
Proof of Lemma 1: Suppose that A T A is not invertible. In this case, there exists a vector
X 6= 0 such that A T AX = 0. It then follows that
( AX ) · ( AX ) = ( AX )T AX = X T A T AX = X T 0 = 0,
p
so that the length k AX k = ( AX ) · ( AX ) = 0. In other words, the length of AX is
zero, so that AX = 0. Since X 6= 0, this implies that the columns of A are linearly
dependent. Therefore, if the columns of A are linearly independent, then A T A must
be invertible.
We can now compute the orthogonal projection of the vector (0, 2, 5, −1) onto W. This
is
−1
10 3 7
11 11 0 11 0 11
3 2 0 3 2 1
11 11 11 = 11
0 0 0 0 5 0
−1 3 10 −1 −4
11 11 0 11 11
4
v̂
X1
u
X2
W o
Refl(v)
Reflections
We have seen earlier in the course that reflections of space across (i.e. through)
a plane is linear transformation. Like rotations, a reflection preserves lengths and
angles, although, unlike rotations, a reflection reverses orientation (“handedness").
Once we have projection matrices it is easy to compute the matrix of a reflection.
Let W denote a plane passing through the origin, and suppose we want to reflect a
vector v across this plane, as in Figure 2.
Let u denote a unit vector along W ⊥ , that is, let u be a normal to the plane W. We
will think of u and v as column vectors. The projection of v along the line through u
is then given by:
v̂ = Proju (v) = u(u T u)−1 u T v.
But since we chose u to be a unit vector, u T u = u · u = 1, so that
v̂ = Proju (v) = uu T v.
Let Qu denote the matrix uu T , so that v̂ = Qu v.
What is the reflection of v across W? It is the vector ReflW (v) that lies on the other
side of W from v, exactly the same distance from W as is v, and having the same
projection into W as v. See Figure 2. The distance between v and its reflection is
exactly twice the distance of v to W, and the difference between v and its reflection
is perpendicular to W. That is, the difference between v and its reflection is exactly
twice the projection of v along the unit normal u to W. This observation yields the
equation:
v − ReflW (v) = 2Qu v,
so that
ReflW (v) = v − 2Qu v = Iv − 2Qu v = ( I − 2uu T )v.
The matrix HW = I − 2uu T is called the reflection matrix for the plane W, and is also
sometimes called a Householder matrix.
5
Example: Compute the reflection of the vector v = (−1, 3, −4) across the plane
2x − y + 7z = 0.
Solution: The vector w = (2, −1, 7) is normal to the plane, and w T w = 22 + (−1)2 +
72 = 54, so a unit normal will be
w 1
u= = √ (2, −1, 7).
|w| 54
The reflection matrix is then given by
2
2 1
H = I − 2uu T = I − ww T = I −
−1 2 −1 7 = · · ·
54 27 7
1 0 0 4 −2 14
1
··· = 0 1 0 − −2 1 −7 ,
0 0 1 27 14 −7 49
so that
23/27 2/27 −14/27
H= 2/27 26/27 7/27
−14/27 7/27 −22/27
The reflection of v across W is then given by
23/27 2/27 −14/27 −1 39/27
Hv = 2/27 26/27 7/27 3 = 48/27
−14/27 7/27 −22/27 −4 123/27
Notice in Figure 2 that the projection of v into W is the midpoint of the vector v and
its reflection Hv = ReflW (v); that is,
1
Qv = (v + Hv) or, equivalently Hv = 2Qv − v,
2
where Q = QW denotes the projection onto W. (This is not the same as Qu in the
previous section, which was projection onto the normal of W.)
Let I denote the identity matrix, so that v = Iv for all vectors v ∈ Rn . The identities
above can now be expressed as matrix identities:
1
Q = ( I + H ) and H = 2Q − I,
2
So once you have computed the either the projection or reflection matrix for a sub-
space of Rn , the other is quite easy to obtain.
6
Exercises
Solution 2: First, project v onto the normal vector n = (1, 1, −1) to the plane:
v·n
y = Projn (v) = n = (2/3, 2/3, −2/3).
n·n
Since y is the component of v orthogonal to the plane, the vector v − y is the or-
thogonal projection of v onto the plane. The solution (given in row vector notation)
is
v − y = (1, 1, 0) − (2/3, 2/3, −2/3) = (1/3, 1/3, 2/3),
as in the previous solution.
Note: Which method is better? The second way is shorter for hyperplanes (sub-
spaces of Rn having dimension n − 1), but finding the projection matrix Q is needed
if you are projecting from Rn to some intermediate dimension k, where you no longer
have a single normal vector to work with. For example, a 2-subspace in R4 has a
2-dimensional orthogonal complement as well, so one must compute a projection ma-
trix in order to project to either component of R4 , as in the next problem.
3. Set
1 1
2 0 T 5 1
A=
0
so that A A =
1 1 3
0 1
8
5. Here is a hint: Use the fact that H = I − 2uu T , where I is the identity matrix and u
is a unit column vector. What is H T =? What is H T H =?
6. The vector v = (1, 1, −1) is normal to the plane x + y − z = 0, so the vector
u = √1 (1, 1, −1) = √1 v is a unit normal. Expressing u and v as column vectors we
3 3
find that
1
2
I − 2uu T = I − (2/3)vv T = I − 1 1 1 −1
3 −1
1 2 2
3 −3 3
1 0 0 1 1 −1
2
= 0 1 0 − 1 1 −1 = − 23 1 2
3 −1 −1 3 3
0 0 1 1 2 2 1
3 3 3