Chapter 4 · Geometry
Orthogonality and Approximation
When b is out of reach, which output is closest?
Lecture 4
Four ideas behind the fit
Read the geometry first, then follow the same matrix through the code.
- 01Inner product
Use the standard Euclidean inner product to measure length and perpendicularity in this lab.
- 02Polynomial metric
Change the inner product from a dot product to an integral while keeping the same projection logic.
- 03Reduced QR
Orthonormal columns give simple projection coordinates. For is a projection, not .
- 04Least squares
Choose the nearest reachable output. Independent columns make the coefficients unique.
The running example · printed slide 67
A best fit still has a residual
For and , no coefficient gives an exact fit. The nearest reachable output is .
- 01two coefficients
- 02three fitted values
- 03a perpendicular residual
Chapter 4The fitted output lies in Col(A); the residual lies in its orthogonal complement.
Four guided labs
Build the geometry, then fit the data
- 4.1Inner Products, Angles, and ProjectionTurn a dot product into length, angle, and a perpendicular residual. See why is a meaningful projection when Q is rectangular.
dot product → norm → angle → projectionOpen lab - 4.2Polynomial Inner Products and ApproximationTreat polynomials as vectors, compute the integral inner product on [−1,1], and remove the part of already explained by lower-degree terms.
coefficients → integral metric → orthonormal basisOpen lab - 4.3Gram–Schmidt and Reduced QRSubtract projections one column at a time, reconstruct , and distinguish rectangular orthonormal columns from a square orthogonal matrix.
subtract → normalize → reconstruct $A = QR$Open lab - 4.4Least Squares as Orthogonal ProjectionFollow the lecture’s 3 × 2 example from an unreachable target to normal equations, a perpendicular residual, and a unique fitted output.
minimize error → project b → check the residualOpen lab
One notation across the chapter
Keep the object and its coordinates separate
- The stated inner product determines the norm. In 4.1, 4.3, and 4.4 use the Euclidean dot product; in 4.2 use the integral on [−1,1]. The lecture’s |v| is written here.
- denotes an angle. and are candidate and minimizing model coefficients. Polynomial coordinate vectors use c,d instead of the function argument t.
- A stores Euclidean input columns. G is a Gram matrix of inner products: the polynomial metric in 4.2, and in 4.4. The lecture’s local polynomial Gram matrix A is renamed G here.
- Q stores orthonormal columns; R stores reconstruction coefficients; P acts on ambient vectors as a projection. Reduced Q is rectangular. does not imply .