A725 of 56
0 XP
  1. Hook
  2. Play
  3. Predict
  4. Name it
  5. Check
  6. Explain

A7 · Lesson 25 · Projections

The closest point in a subspace

A sensor signal carries 60 Hz hum from the mains. You know the hum lives in a two-dimensional space, combinations of cos⁡(2π⋅60t) and sin⁡(2π⋅60t), but you don't know its size or phase. Remove the part of the signal that lies in that space and the hum is gone, whatever its amplitude. Subtracting a signal's average to remove its DC offset is the same operation in one dimension. Both are projections: finding the closest point in a subspace, and the leftover is perpendicular to it.

  • The dashed line is the direction of 𝐚. The vector 𝐛=(1,3) is fixed.
  • The green arrow is the projection 𝐩 of 𝐛 onto the line, the closest point on it. The red arrow is the error 𝐞=𝐛−𝐩.
  • Turn the line. The error always meets the line at a right angle, and the readout of 𝐞⋅𝐚 stays at zero.

Predict

You project 𝐛=(1,2,6) onto the line through (1,1,1). What is the projection?

Name it

Onto a line

The projection of 𝐛 onto the line through 𝐚 is

𝐩=𝐚T𝐛𝐚T𝐚𝐚

The error 𝐞=𝐛−𝐩 is perpendicular to 𝐚, which is what makes 𝐩 the closest point. The projection matrix P=𝐚𝐚T𝐚T𝐚 does it in one multiplication: 𝐩=P𝐛.

Onto a subspace

To project onto the column space of A (independent columns), require the error to be perpendicular to every column: AT(𝐛−A𝐱^)=𝟎. That gives the normal equations

ATA𝐱^=AT𝐛𝐩=A𝐱^P=A(ATA)−1AT

If the columns are orthonormal (A=Q), QTQ=I and everything simplifies: P=QQT, and each coordinate is a dot product.

Properties

  • P2=P: projecting twice changes nothing.
  • PT=P: projection matrices are symmetric.
  • I−P projects onto the orthogonal complement, giving the error directly.
  • Pythagoras: |𝐛|2=|𝐩|2+|𝐞|2.

Hum removal

Sample a signal at N times, making a vector 𝐛. Put the samples of cos⁡2πf0t and sin⁡2πf0t in the two columns of A. Then (I−P)𝐛 is the signal with every trace of f0 removed, at any amplitude and phase. Over a whole number of cycles the two columns are orthogonal (A6, lesson 2), so the projection is just two dot products.

Worked example

Project 𝐛=(1,2,2) onto 𝐚=(1,1,1), and check the error.

Show the solution
  1. The two dot products. 𝐚T𝐛=5 and 𝐚T𝐚=3.
  2. The projection. 𝐩=53(1,1,1) the mean in every slot.
  3. The error. 𝐞=(1,2,2)−53(1,1,1)=(−23,13,13)
  4. Check. 𝐞⋅𝐚=0.

Answer 𝐩=53(1,1,1), and the error (−23,13,13) is perpendicular to 𝐚.

Worked example

Find the projection matrix onto the line through (1,2), and check P2=P.

Show the solution
  1. The projection matrix. P=15[1224]
  2. Square it. P2=125[1+42+82+84+16]=15[1224]=P

Answer P=15[1224], and P2=P.

Worked example

Project 𝐛=(1,0,0) onto the plane x+y+z=0.

Show the solution
  1. Part along the normal. It's easiest to remove the part along the normal 𝐧=(1,1,1): 𝐛⋅𝐧𝐧⋅𝐧𝐧=13(1,1,1)
  2. What's left is the projection. 𝐩=(1,0,0)−13(1,1,1)=(23,−13,−13) Its entries sum to zero, so it's in the plane.
  3. Distance to the plane. |13(1,1,1)|=13=0.577
  4. Where this shows up. Removing the average from a signal is exactly this projection.

Answer 𝐩=(23,−13,−13), and 𝐛 is 0.577 from the plane.

Check

Project 𝐛=(4,5) onto the line through 𝐚=(1,2). The projection is t𝐚. What is t?

Check

What is the top-left entry of the matrix that projects onto the line through (1,2)?

Check

The samples (4,1,6) are projected onto (1,1,1) and the projection is subtracted. What is the first entry of what remains?

Check

Project (3,1) onto the line through (1,1). How long is the error vector?

Check

P is a projection matrix. What is P2?

Check

A signal of 100 samples is projected onto a 2-dimensional hum subspace and the projection subtracted. In how many dimensions can what remains still vary?

Check

Project (1,3) onto the line through (1,1).

(a)

What is the projection's x coordinate?

(b)

How far is the point from the line?

Check

Project (x,y,z) onto (1,1,1).

Step 1

What is the coefficient 𝐚⋅𝐛𝐚⋅𝐚?

Type it the way you would write it, like 3sin(2πft) or 3*sin(2*pi*f*t). Angles can be in radians or carry a degree sign, like 45°.

Explain why

Why is the projection the closest point in the subspace, and why is the error perpendicular to it?

Practice

Keep practicing

9 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.