4.5.41 · D1Linear Algebra (Full)

Foundations — Least squares — normal equations, QR approach

2,534 words12 min readBack to topic

Before you can read a single boxed formula in the parent note, you need every letter to mean something you can picture. This page builds each symbol from nothing, in an order where each one leans only on the ones before it. Nothing below uses a symbol that an earlier section has not already defined.


1. Numbers stacked up — a vector

The picture. A vector with 2 components is an arrow on a flat sheet of paper (2D). With 3 components it's an arrow in a room (3D). With components it's an arrow in a space we can't draw but can still reason about, called — "all lists of real numbers".

Why the topic needs it. Your data (the measurements you want to fit) becomes a vector, and the answer you're solving for becomes another vector. Everything is arrows — so this is the first brick.

Figure — Least squares — normal equations, QR approach

2. How long is an arrow — the norm

The picture. In 2D, an arrow with components is the hypotenuse of a right triangle with legs and , so its length is . In higher dimensions we do the same thing — square every component, add, square-root.

Why the topic needs it. "Closest" means "shortest distance". The distance between two arrow-tips is the length of the arrow joining them. Least squares minimises this length. The little "" in just labels which kind of length (the ordinary Euclidean one).


3. Direction agreement — the dot product

The picture. The dot product measures how much two arrows point the same way.

  • Same direction → big positive number.
  • Perpendicular (at ) → exactly zero.
  • Opposite → negative.
Figure — Least squares — normal equations, QR approach

Why the topic needs it. The whole geometric heart of least squares is "the miss-arrow is perpendicular to the menu of reachable points". Perpendicular is detected by the dot product being zero — and zero dot products are exactly what will turn geometry into equations two sections from now.


4. A grid of numbers acting on arrows — the matrix

The picture. Think of the columns as a set of "ingredient" arrows. The numbers inside are the amounts of each ingredient. is the arrow you build by mixing them.

Why "tall"? In our problem : more rows (equations / data points) than columns (unknowns). This is an overdetermined system — too many demands, usually impossible to satisfy all at once.


5. When ingredients aren't wasteful — independent columns and rank

The picture. Two arrows pointing in genuinely different directions sweep out a whole plane. But if a third arrow lies flat inside that same plane, it adds nothing new — it's "dependent". Full column rank means every ingredient arrow points somewhere the others cannot reach.

Why the topic needs it. This is the make-or-break condition. If the columns are independent, the best-fit answer will be unique — there is exactly one recipe that lands on the closest point. If some column is redundant, infinitely many recipes give the same closest point, and the answer is no longer unique (you then reach for the Pseudoinverse (Moore-Penrose)). Keep this flag in mind; in Section 8 it is exactly what makes the key matrix invertible. More in Column Space and Rank.


6. Every reachable point — the column space

The picture. With two independent column arrows in 3D, all their mixes sweep out a flat plane through the origin. That plane is the "menu" of reachable points. The target usually floats above the plane — not on the menu.

Figure — Least squares — normal equations, QR approach

Why the topic needs it. "There is no exact solution" means precisely " is not in ". The best we can do is find the point on the plane nearest to .


7. The nearest point on the plane — orthogonal projection

The picture. Hold a pencil (that's ) above a table (the plane). The shadow cast by a light directly overhead is the projection . The little arrow from the shadow up to the pencil tip is the residual , and it stands straight up, perpendicular to the table.

Why straight up is best. Any other point on the table is farther away — its connecting arrow would be a slanted hypotenuse, and a hypotenuse is always longer than the vertical leg. That is why the minimum-distance point is the perpendicular one. Full detail lives in Orthogonal Projection.


8. From "perpendicular" to the normal equations

Now every symbol is defined, so we can watch geometry turn into algebra — this is the step the parent note boxes, built here from scratch.

Step 1 — write "perpendicular" as dot products. The residual stands straight up off the plane. Standing perpendicular to the plane means being perpendicular to every ingredient arrow that builds the plane. Using the dot product from Section 3, "perpendicular" is "dot product zero":

Step 2 — stack the separate equations into one. We have statements, one per column. Stacking the rows on top of each other rebuilds exactly the transpose (transpose turns columns into rows — Section 3). So the whole batch of dot-product-zero conditions is a single matrix equation:

Step 3 — multiply out. Distribute across the bracket and move the term to the other side:

These are the normal equations. The word "normal" is just an old synonym for "perpendicular" — the whole thing is born from that one right angle.


9. An ideal coordinate grid — orthonormal columns and

The picture. Orthonormal columns are like the clean // axes of graph paper: unit length, meeting at right angles. Projecting onto such a grid is effortless — no stretching or shearing to untangle.


10. A staircase of numbers — upper-triangular

The picture. Because the bottom-left is empty, the last equation involves only the last unknown. Solve it, feed the answer upward, solve the next — this bottom-to-top zigzag is called back-substitution.

Why the topic needs it. The QR route reduces least squares to . Because is triangular, this solves instantly by back-substitution, dodging the error-amplifying step of forming (a danger measured by the Condition Number).


11. How the foundations connect

The map below reads top-to-bottom as a dependency chain: each box is a tool you must own before the box it points to makes sense. The two paths (normal equations and QR) reunite at the same answer.

Vector and norm - what closest means

Dot product - detects right angles

Projection - drop straight onto the plane

Matrix Ax - mixes column ingredients

Column space - the reachable menu

Full column rank - independent columns

Unique invertible answer

Normal equations from zero dot products

Least squares solution xhat

Orthonormal columns Q

QR route Rxhat equals QT b

Upper triangular R


Full symbol glossary (quick reference)

Symbol Plain meaning Picture
column of numbers (vector) an arrow
all lists of reals -dimensional space
length of arrow Pythagoras hypotenuse
dot product (one number) how much they align; perpendicular
grid of numbers () machine turning into a tall arrow
the -th column of one ingredient arrow
full column rank columns independent no redundant ingredient
all mixes flat plane through origin
chosen best answer / shadow projection point on plane
residual the straight-up miss arrow
orthonormal columns clean unit right-angle grid
upper triangular staircase for back-substitution
identity matrix do-nothing grid

Equipment checklist

Self-test your readiness. Each line below is written as prompt ::: answer — a reveal format used across this vault: read only the left side, say your answer out loud, then uncover the right side to check. If any answer doesn't come easily, reread its section before moving to the parent note.

I can compute the length of
.
I know what a zero dot product means geometrically
the two arrows are perpendicular (at ).
I can read as a combination of columns
, a mix of the column arrows.
I know what full column rank means
every column is independent — no column is a mix of the others.
I know why full column rank matters
it makes invertible, so the best-fit answer is unique.
I can describe in words
the set of all reachable points — a flat subspace through the origin.
I know what the hat in signals
the best/chosen answer, not a given input.
I can say what "overdetermined" means
more rows (equations/data) than columns (unknowns), , usually no exact solution.
I can turn "residual perpendicular to Col(A)" into an equation
, i.e. the normal equations .
I know what tells me
columns of are orthonormal — unit length and mutually perpendicular.
I know why triangular is convenient
it solves by back-substitution, from the last equation upward.

Once every line comes easily, the boxed formulas in the parent note will read as plain sentences. Related deep applications: Linear Regression, Pseudoinverse (Moore-Penrose).