Unit 4 of 8 · about 4 hours · derive, implement
Inner products, norms, orthogonality and Gram-Schmidt
Orthonormal coordinates separate directions without mixing their lengths. They are the geometric foundation of projections, QR and spectral decompositions.
You'll be able to
- Derive Cauchy-Schwarz and the induced norm, distance and angle from a real inner product.
- Prove that orthonormal coordinates preserve inner products and lengths.
- Implement Gram-Schmidt and check orthogonality, reconstruction and a dependent-column failure.
Covers
Read
In this order, only the parts listed
0 of 2 done
- Orthogonal vectors and Gram-SchmidtMIT 18.06 - Linear Algebra
Video Lecture 14, Orthogonal vectors and subspaces; Lecture 17, Orthogonal matrices and Gram-Schmidt
- Inner-product geometry and its inequalitiesMathematics for Machine Learning
Chapter 3, sections 3.1 to 3.5 (pp. 71 to 79), especially Cauchy-Schwarz, equation (3.17); section 3.8.3, Gram-Schmidt Orthogonalization (pp. 89 to 90)
Use these definitions and the Gram-Schmidt construction to check the lectures. Leave function inner products and rotations.
Focus on
- A real inner product is bilinear, symmetric and positive definite. Its induced norm is ; angles require both vectors to be nonzero.
- For nonzero, expand the nonnegative squared norm of to derive Cauchy-Schwarz. Handle separately.
- Gram-Schmidt subtracts components in previously accepted directions and then normalizes. Independence is what prevents a zero residual in exact arithmetic.
- For tall with , lengths are preserved in the coordinate-to-vector map. need not be the identity.
Common mistakes · 3
- Orthogonal vectors are not necessarily unit vectors. Projection coefficients need division by their squared lengths unless they are normalized.
- Normalizing a zero or numerically tiny Gram-Schmidt residual produces invalid or unreliable columns. A fixed threshold is only appropriate to the stated scale.
- Comparing columns directly with a library QR ignores valid sign changes. Compare spans through projectors and check your own reconstruction.
Try it yourself
Closed-book, before checking anything
A=np.array([[1,-1],[1,2],[1,0]],dtype=np.float64), with no random draws: for each column v, sequentially set R[i,j]=Q[:,i]@v and v-=R[i,j]*Q[:,i], then R[j,j]=norm(v,2) and Q[:,j]=v/R[j,j]. Reject a residual norm on this small scale. Check the Frobenius norms of Q.T@Q-I and A-Q@R; the reference run gives 3.6e-16 and 2.2e-16. Against Qref=np.linalg.qr(A,mode='reduced')[0], the projector difference norm([email protected]@Qref.T,'fro') is 5.1e-16. Require all three below 1e-12. Replacing by must trigger the dependence guard.Quiz yourself
Answer first, then mark it. Missed ones go to Review.
0 got · 0 missed
1.Where does positive definiteness enter Cauchy-Schwarz?Answer
For nonzero it gives , permitting division. The squared residual is nonnegative, yielding . Equality requires the residual to be zero, again by positive definiteness. For both sides are zero.
2.How does Cauchy-Schwarz imply the triangle inequality?Answer
Expand and bound . This is at most . Both sides are nonnegative, so taking square roots preserves the inequality.
3.Why does Gram-Schmidt keep the same span at every step?Answer
The new residual is the current input minus a combination of earlier outputs, so it lies in the enlarged input span. Conversely the input is that residual plus earlier outputs. Independence makes the residual nonzero, so normalization changes neither span. The first nonzero input establishes the base case.
4.For of shape 3 by 2 with orthonormal columns, why is not ?Answer
Its image has dimension two and it annihilates the one-dimensional orthogonal complement. has rank three. still implies for in .
Practice
- 18.06 Problem set 6: Gram-Schmidt in
Problem set 6, Strang 4th ed., section 4.4, Problem 18
Orthogonalize the three difference vectors and prove they span the complement of . Attempt before opening the official solutions. Run your implementation on these columns as a second case.
You're done when
You derive the inequality, reproduce the two-vector orthonormal basis, pass the three norm checks and reject dependent columns before division.
Only when you can do this without notes.
Leads to
Notes
Resources · 2 for this unit, 6 more in the section
- MIT 18.06 - Linear AlgebraMIT OpenCourseWare · primary
Follow lectures 1-10, 14-17, 21-22, 25, 27, 29-31 and 33 with matching problems. This is the ordered first pass.
- Mathematics for Machine LearningDeisenroth, Faisal & Ong · reference
Use Chapters 2-4 and §10.2 to check notation or re-derive a result. Do not treat it as a second course.
Also in this section
- MIT 6.042J - Proof strandMIT OpenCourseWare · required
Study textbook Chapters 1 and 3, §§4.1-4.4 and §§5.1-5.4 with matching Unit 1 problems. Leave the rest of the course.
- MIT 18.065 - Applied matrix bridgeMIT OpenCourseWare · required
Use lectures 3-10 after 18.06 for SVD, PCA, low-rank approximation, matrix norms and solver difficulty.
- Introduction to Applied Linear AlgebraBoyd & Vandenberghe · support
Sample Chapters 1-13 and the extra exercises for computational practice in fitting, least squares and pseudoinverses.
- Essence of Linear Algebra3Blue1Brown · optional
Open only when a geometric picture is missing; it does not replace derivation or problem solving.
- NumPy broadcasting and matmul shape rulesNumPy Developers · reference
Read General broadcasting rules and Broadcastable arrays, then
matmulNotes for stacked matrices and one-dimensional promotion. These close the pool's array-semantics gap. - Fundamentals of Numerical Computation: conditioning and operation countsDriscoll & Braun · reference
Python edition, section 2.8 through Residual and backward error for the fixed-matrix perturbation bound; section 2.5.3 for triangular-solve and LU flop counts. Use Exercise 2.8.7 for a condition-number proof, not the unseeded Hilbert experiment.