Seyed Masoud Hosseini · Overview · Study log · Weekly summaries · Ideas · Search · Transcript · RSS feed

Matrix Methods for Data Analysis & ML · Lecture 11 of 36 · 49:51

Lecture 9: Four Ways to Solve Least Squares Problems

9. Four Ways to Solve Least Squares Problems on YouTube

Study guide

What this lecture covers

This lecture asks how to solve Ax = b when no exact solution exists, the standard situation in data fitting where there are more measurements than unknowns. It sits early in the course's move from pure linear algebra toward the applications, using least squares as the bridge topic before singular value decomposition ideas carry into deeper data problems.

After watching, you should be able to define the pseudo-inverse of a matrix from its SVD, derive the normal equations A^T A x = A^T b from minimizing the squared error, and see why the projection of b onto the column space of A is the geometric picture behind both. The lecture also opens a third method, Gram-Schmidt orthogonalization, which is finished in the next lecture.

Key ideas

  • Pseudo-inverse (A+): for a matrix that isn't invertible, A+ is the best substitute: it inverts A on the row space and column space, and sends anything in the null space to zero.
  • SVD-based formula: writing A = U Sigma V^T, the pseudo-inverse is A+ = V Sigma+ U^T, where Sigma+ replaces each nonzero singular value with its reciprocal and leaves the zero entries as zero.
  • Least squares problem: when Ax = b has no solution (b is not in the column space of A), the best you can do is minimize ‖Ax - b‖^2.
  • Normal equations: minimizing that squared error leads to the linear system A^T A x = A^T b, solvable whenever A has independent columns.
  • Geometric picture: the best Ax is the projection of b onto the column space of A; the leftover b - Ax is the error orthogonal to that space.
  • Equivalence of methods: when A has independent columns (no null space), solving the normal equations gives the same answer as applying the pseudo-inverse, x = A+ b = (A^T A)^{-1} A^T b.
  • One-sided inverse: (A^T A)^{-1} A^T is a left inverse of A (it gives the identity when applied on the left) but not a full two-sided inverse.
  • Gram-Schmidt (introduced): a way to replace the columns of A with orthogonal columns before solving, illustrated on a two-column example by subtracting off the projection onto the first column.

Walkthrough

Course logistics and the plan ahead (0:01)

Strang opens with administrative notes: there's no final exam, homework will be replaced later in the term by a project drawing on the course material, and the class is moving into the chapter on least squares before returning to topics like sparse solutions and the pseudo-inverse in more depth.

Defining the pseudo-inverse with the four subspaces (5:14)

Using the picture of the row space, column space, and their orthogonal null spaces, Strang explains that a matrix A is genuinely invertible only between the row space and column space. The pseudo-inverse mimics this: it undoes A on the row/column space pair and maps everything in the orthogonal null space to zero, since there's no way to recover information that A already destroyed.

Building the SVD formula for A+ (14:32)

Starting from A = U Sigma V^T, Strang works out what the inverse would look like if A were invertible, then generalizes to the case where Sigma is rectangular with some zero entries. The pseudo-inverse Sigma+ inverts the nonzero singular values one by one and leaves the rest as zero, giving A+ = V Sigma+ U^T.

Setting up the least squares problem (22:37)

The lecture turns to fitting a straight line C + Dx through noisy measurement points, the classic example of an unsolvable Ax = b. Because there are more data points than the two unknowns C and D, the system is overdetermined and generally has no exact solution, so the columns of A are the constant term and the measurement locations.

Minimizing the error and deriving the normal equations (28:45)

Following Gauss's approach, Strang minimizes ‖Ax - b‖^2, expands it, and takes the derivative to reach the boxed equation A^T A x = A^T b. He pairs this with the geometric picture: b sits outside the column space of A, and the best Ax is its projection onto that space, leaving an orthogonal error term.

Connecting the normal equations to the pseudo-inverse (37:03)

When A has independent columns, A^T A is invertible even though A itself is not, and Gauss's method works directly. Strang argues (without a full symbolic check) that in this case x = (A^T A)^{-1} A^T b equals A+ b, and notes that (A^T A)^{-1} A^T is a left inverse of A but not a two-sided inverse.

Starting Gram-Schmidt as a third method (46:19)

With time running out, Strang previews the Gram-Schmidt method: replace the columns of A with orthogonal vectors, which makes the least squares system easier to solve. He demonstrates on two columns, keeping the first as is and subtracting off its projection from the second to make it orthogonal, and says the fourth method will be introduced next time.

Before you watch

  • Know the SVD (A = U Sigma V^T), including what singular values and the matrices U and V represent.
  • Be comfortable with the four fundamental subspaces of a matrix: row space, column space, and their orthogonal null spaces.
  • Some familiarity with projections onto a subspace will help with the geometric argument.

Check your understanding

  1. Why does the pseudo-inverse send vectors in the null space of A to zero rather than trying to invert them?
  2. How is Sigma+ constructed from Sigma in the SVD, and why can't you simply take the reciprocal of every entry?
  3. Starting from ‖Ax - b‖^2, sketch how differentiating leads to the normal equations A^T A x = A^T b.
  4. Why does A having independent columns guarantee that A^T A is invertible, even when A itself is not square or invertible?
  5. In what sense is (A^T A)^{-1} A^T an inverse of A, and in what sense is it not?

Vocabulary

pseudo-inverse (noun)
The best possible substitute for an inverse when a matrix cannot be inverted normally.
The pseudo-inverse A+ works even when A is not square.
invertible (adjective)
Able to be undone by another matrix, so multiplying by both gives the identity.
A rectangular matrix is never fully invertible.
row space (noun)
The set of all vectors you can build by combining a matrix's rows.
The pseudo-inverse acts normally on the row space.
column space (noun)
The set of all vectors you can reach by combining a matrix's columns.
The best Ax is the closest point in the column space to b.
null space (noun)
The set of vectors that a matrix sends to zero.
The pseudo-inverse sends the null space to zero.
reciprocal (noun)
The value you get by dividing 1 by a number.
Sigma+ replaces each singular value with its reciprocal.
overdetermined (adjective)
Having more equations than unknowns, so an exact solution usually doesn't exist.
Fitting a line to noisy data gives an overdetermined system.
least squares (noun)
A method that finds the closest possible solution by minimizing the sum of squared errors.
Least squares handles the case where Ax = b has no exact solution.
minimize (verb)
To make something as small as possible.
We minimize the squared error between Ax and b.
normal equations (noun)
The equation A transpose A x equals A transpose b, solved to find the least squares answer.
Differentiating the error leads to the normal equations.
projection (noun)
The closest point in a subspace to a given vector.
The best Ax is the projection of b onto the column space.
orthogonal (adjective)
At a right angle; having zero dot product.
The leftover error is orthogonal to the column space.
left inverse (noun)
A matrix that gives the identity when multiplied on one particular side.
(A^T A)^-1 A^T is a left inverse of A.
Gram-Schmidt (noun)
A method that turns a set of independent vectors into a set of orthogonal ones.
Gram-Schmidt replaces the columns of A with orthogonal columns.
administrative (adjective)
Related to organizing a course, rather than to its content.
Strang opens with a few administrative notes about the class.
independent columns (noun)
A set of columns where none can be built from combining the others.
A with independent columns makes A^T A invertible.
matrix (noun)
A rectangular table of numbers used to represent a linear transformation.
A is the matrix in the equation Ax = b.
substitute (verb)
To replace one expression with an equivalent one.
Substituting the SVD into the formula simplifies it.
symbolic check (noun)
A verification done by manipulating formulas rather than numbers.
Strang skips a full symbolic check of the equivalence.
exact solution (noun)
A solution that satisfies an equation perfectly, with no error.
When b is not in the column space, no exact solution exists.

Chapters

From the YouTube description

MIT 18.065 Matrix Methods in Data Analysis, Signal Processing, and Machine Learning, Spring 2018
Instructor: Gilbert Strang
View the complete course: https://ocw.mit.edu/18-065S18
YouTube Playlist: https://www.youtube.com/playlist?list=PLUl4u3cNGP63oMNUHXqIUcrkS2PivhN3k

In this lecture, Professor Strang details the four ways to solve least-squares problems. Solving least-squares problems comes in to play in the many applications that rely on data fitting.

License: Creative Commons BY-NC-SA
More information at https://ocw.mit.edu/terms
More courses at https://ocw.mit.edu

← Lecture 8: Norms of Vectors and Matrices · Lecture 10: Survey of Difficulties with Ax = b →