LINEAR-ALGEBRA ยท Unit 15 ยท Video 3 ยท Interactive Practice

One Solution, Two Pictures: Why Your Best-Fit Line Is a Shadow in Disguise

IKey Formulas

Formula Name Description
ATAx^=ATbA^T A \hat{x} = A^T b Normal equations Solves the least-squares problem
p=Ax^\mathbf{p} = A\hat{x} Projection Closest vector in Col(A)\text{Col}(A) to b\mathbf{b}
e=bโˆ’p\mathbf{e} = \mathbf{b} - \mathbf{p} Error vector Must satisfy eโŠฅCol(A)\mathbf{e} \perp \text{Col}(A)
ATe=0A^T \mathbf{e} = \mathbf{0} Orthogonality condition Error perpendicular to every column of AA

IIVisualization 1 โ€” Best Fit in Data Space

No line hits all three points; the best fit is the one that minimizes the total squared residual โˆ‘ei2\sum e_i^2.

IIIVisualization 2 โ€” Projection onto the Column Space

p=Ca1+Da2\mathbf{p}=C\mathbf{a}_1+D\mathbf{a}_2 is b\mathbf{b}'s shadow on the plane Col(A)\text{Col}(A); the error e=bโˆ’p\mathbf{e}=\mathbf{b}-\mathbf{p} is shortest exactly when it meets the plane at a right angle.

IVVisualization 3 โ€” The Error Landscape

SSE(C,D)\text{SSE}(C,D) is a convex bowl, and the normal equations jump straight to its single lowest point.

VQuiz Questions

Question 1

For data points (1,1)(1,1), (2,2)(2,2), (3,2)(3,2) with model y=C+Dty = C + Dt, we write the system as Ax=bA\mathbf{x} = \mathbf{b}. What is the right-hand side vector b\mathbf{b}?

โœ… Correct! The vector b\mathbf{b} collects the yy-values from each data point.

โŒ Not quite. Each equation is C+Dti=yiC + Dt_i = y_i, so b\mathbf{b} is the column of yy-values.

Show solution

Solution:

Substituting each data point (ti,yi)(t_i, y_i) into y=C+Dty = C + Dt:

C+D(1)=1,C+D(2)=2,C+D(3)=2C + D(1) = 1, \quad C + D(2) = 2, \quad C + D(3) = 2

In matrix form:

(111213)โŸA(CD)โŸx=(122)โŸb\underbrace{\begin{pmatrix} 1 & 1 \\ 1 & 2 \\ 1 & 3 \end{pmatrix}}_{A} \underbrace{\begin{pmatrix} C \\ D \end{pmatrix}}_{\mathbf{x}} = \underbrace{\begin{pmatrix} 1 \\ 2 \\ 2 \end{pmatrix}}_{\mathbf{b}}

The right-hand side b=(1,2,2)\mathbf{b} = (1, 2, 2) collects the yy-values.

Common errors:

  • (1,2,3)(1, 2, 3) = the tt-values = second column of AA
  • (1,1,1)(1, 1, 1) = the column of ones = first column of AA
  • (2/3,1/2)(2/3, 1/2) = the solution x^\hat{\mathbf{x}}, not b\mathbf{b}

Question 2

True or False: If pโ‹…e=0\mathbf{p} \cdot \mathbf{e} = 0 (the projection is perpendicular to the error), then we are guaranteed to have the least-squares solution.

โœ… Correct! The condition pโ‹…e=0\mathbf{p} \cdot \mathbf{e} = 0 is necessary but not sufficient. We need ATe=0A^T\mathbf{e} = \mathbf{0}.

โŒ Not quite. Being perpendicular to p\mathbf{p} alone doesn't guarantee perpendicularity to the entire column space plane.

Show solution

Solution: False

Checking pโ‹…e=0\mathbf{p} \cdot \mathbf{e} = 0 only verifies perpendicularity to one vector (p\mathbf{p}).

The least-squares condition requires:

ATe=0A^T\mathbf{e} = \mathbf{0}

This means e\mathbf{e} must be perpendicular to every vector in the column space โ€” both a1\mathbf{a}_1 and a2\mathbf{a}_2, and all their linear combinations.

Many vectors in R3\mathbb{R}^3 can be perpendicular to p\mathbf{p} without being perpendicular to the entire plane. Only the vector perpendicular to the whole column space minimizes โˆฅeโˆฅ\|\mathbf{e}\|.

Question 3

The optimal error vector is e=(โˆ’1/6,โ€…โ€Š1/3,โ€…โ€Šโˆ’1/6)\mathbf{e} = (-1/6, \; 1/3, \; -1/6) and the second column of AA is a2=(1,2,3)\mathbf{a}_2 = (1, 2, 3).

What is eโ‹…a2\mathbf{e} \cdot \mathbf{a}_2?

โœ… Correct! The dot product is zero, confirming eโŠฅa2\mathbf{e} \perp \mathbf{a}_2 as required by ATe=0A^T\mathbf{e} = \mathbf{0}.

โŒ Not quite. Compute carefully: (โˆ’1/6)(1)+(1/3)(2)+(โˆ’1/6)(3)(-1/6)(1) + (1/3)(2) + (-1/6)(3). Try converting all terms to sixths.

Show solution

Solution:

eโ‹…a2=(โˆ’16)(1)+(13)(2)+(โˆ’16)(3)\mathbf{e} \cdot \mathbf{a}_2 = \left(-\frac{1}{6}\right)(1) + \left(\frac{1}{3}\right)(2) + \left(-\frac{1}{6}\right)(3)

Converting to sixths:

=โˆ’16+46โˆ’36=โˆ’1+4โˆ’36=06=0= -\frac{1}{6} + \frac{4}{6} - \frac{3}{6} = \frac{-1 + 4 - 3}{6} = \frac{0}{6} = 0

This confirms eโŠฅa2\mathbf{e} \perp \mathbf{a}_2, which is one of the two conditions in ATe=0A^T\mathbf{e} = \mathbf{0}. (The other condition, eโ‹…a1=0\mathbf{e} \cdot \mathbf{a}_1 = 0, also holds.)

Question 4

In the "two pictures" framework, the column space Col(A)\text{Col}(A) in the vector space picture corresponds to what in the data space picture?

โœ… Correct! Each point in Col(AA) corresponds to the fitted values of a line y=C+Dty = C + Dt. The whole column space represents all possible linear fits.

โŒ Not quite. Think about what AxA\mathbf{x} produces as you vary CC and DD โ€” each choice gives a different line and different fitted values.

Show solution

Solution:

The column space Col(A)\text{Col}(A) consists of all vectors Ca1+Da2C\mathbf{a}_1 + D\mathbf{a}_2 as CC and DD vary. Each such vector gives fitted values:

(C+D,โ€…โ€ŠC+2D,โ€…โ€ŠC+3D)(C + D, \; C + 2D, \; C + 3D)

These are the values of the line y=C+Dty = C + Dt evaluated at t=1,2,3t = 1, 2, 3.

So Col(A)\text{Col}(A) = the set of all possible fitted lines y=C+Dty = C + Dt.

The full two-picture correspondence:

Data Space Vector Space
Data points (y1,y2,y3)(y_1, y_2, y_3) Vector b\mathbf{b}
All possible lines y=C+Dty = C + Dt Column space Col(A)\text{Col}(A)
Fitted values on best-fit line Projection p\mathbf{p}
Vertical residuals Error vector e\mathbf{e}
Minimize โˆ‘ei2\sum e_i^2 Minimize โˆฅeโˆฅ2\|\mathbf{e}\|^2

Solved: 0 / 4