Linear algebra problem set, part a: elimination, LU, bases, rank, determinants, eigenvalues, QR
Overview
Section titled “Overview”| Module | S-M03a · solve · none · Pass 2 · 6 to 8 h |
| You build | answers in solve/S-M03a.toml (44 checked by SymPy) and 4 proofs in solve/S-M03a/q10.md, q20.md, q28.md, q44.md (self-graded against their rubrics) |
| Contract | none: a pen and paper set |
| Tests | course/solve/S-M03a/key.toml (hidden): typed answers plus reject canaries; the problems are in course/solve/S-M03a/problems.md and in section 4 |
| Needs | no module. Reading: M03.1 (vectors, matrices, and the matrix product) and the Linear Algebra topic |
| Used by | no call site (a solve set). Take it after M03.2 (LU), M03.3 (Householder QR), and M03.4 (power iteration) in Pass 2; S-M03b (SVD, projections, the roofline) follows M03.5 and M03.6 in Pass 3 |
| Milestone | MS-P2 (the Pass 2 gate runs ol check on every solve part of the pass) |
| Optional depth | Strang, Introduction to Linear Algebra, ch. 2 to 6 (and MIT 18.06 lectures 1 to 21); Hefferon, Linear Algebra (free), ch. 1 to 5 |
Key Takeaways
Section titled “Key Takeaways”- Elimination is LU: the multipliers are , the result is , and partial pivoting keeps every multiplier at most 1 in size (q4 to q7).
- A basis is a minimal spanning set; its size, the dimension, is the same for every basis, and any vectors in are dependent (q13, q20).
- Rank plus nullity equals the number of columns: every column either adds a direction to the image or a direction to the null space (q23 to q25).
- The determinant measures how a matrix scales volume; it is the product of the eigenvalues and is 0 exactly when the matrix is singular (q31, q34, q40).
- Repeated multiplication by is governed by its eigenvalues: , power iteration converges at rate , and a spectral radius below 1 shrinks everything (q41 to q43).
How to work this chapter
Section titled “How to work this chapter”ol start S-M03a # writes solve/S-M03a.toml and the four proof filesol check S-M03a # SymPy checks the answers, then asks each proof rubric (y/n)ol check S-M03a --regrade # ask the rubrics again after you change a proof1. Why now
Section titled “1. Why now”Your Pass 2 code factors matrices: M03.2 writes LU with partial pivoting, M03.3 Householder QR and orthogonal initialization, M03.4 power iteration and the spectral radius that L3.1 uses to diagnose exploding gradients. Their tests compare your factors with numpy’s, but a factorization that “matches numpy” is only meaningful if you know what the factors are supposed to be and why they exist: why pivoting is needed, what rank and null space mean for a least-squares fit, why an eigenvalue above 1 makes a recurrent network blow up. This set works those ideas by hand on matrices small enough to check on paper.
2. Principles
Section titled “2. Principles”| Symbol | Meaning | Type / shape |
|---|---|---|
| a matrix with rows and columns | matrix | |
| the unknown and the right-hand side of | vectors | |
| permutation, unit lower triangular, upper triangular: | ||
| all linear combinations | subspace | |
| the number of vectors in any basis of | integer | |
| the dimension of the column space (equal to that of the row space) | integer | |
| the null space ; its dimension is the nullity | subspace | |
| the determinant of a square matrix | real | |
| an eigenvalue and an eigenvector: , | scalar, vector | |
| the spectral radius, $\max | \lambda | |
| orthonormal columns and upper triangular: | matrices |
2.1 Elimination and LU
Section titled “2.1 Elimination and LU”Gaussian elimination subtracts multiples of a pivot row from the rows below it until the matrix is upper triangular, . Recording each multiplier (the amount of row subtracted from row ) in a unit lower triangular gives , so solving becomes two triangular solves. If a pivot is 0 the rows must be exchanged, and if it is merely small, dividing by it amplifies rounding errors; partial pivoting swaps the row with the largest in the current column into the pivot position, giving with every . The reduced row echelon form continues until each pivot is 1 and the only nonzero entry in its column. A system has no solution (inconsistent), exactly one, or infinitely many (a free variable).
2.2 Span, independence, basis, dimension
Section titled “2.2 Span, independence, basis, dimension”Vectors are linearly independent when forces every . A basis of a subspace is an independent spanning set, and every basis has the same size, the dimension. The pivot columns of are a basis of its column space; the special solutions (one per free variable) are a basis of its null space. Coordinates in a basis are the unique coefficients with : solve a linear system.
2.3 Linear maps and rank-nullity
Section titled “2.3 Linear maps and rank-nullity”A map is linear when and ; then where column of is . Composition is multiplication: has matrix (apply first, so it is on the right). For with columns, rank-nullity says .
2.4 Determinants
Section titled “2.4 Determinants”The determinant is the signed volume scale factor of : is the area of the parallelogram spanned by and . It is multiplicative, , so ; it scales as for ; a triangular matrix’s determinant is the product of its diagonal; and exactly when is singular.
2.5 Eigenvalues and eigenvectors
Section titled “2.5 Eigenvalues and eigenvectors”is an eigenvalue when is singular, that is, a root of the characteristic polynomial ; the product of the eigenvalues is and their sum is the trace. A real matrix may have complex eigenvalues (a rotation moves every real vector). If is an eigenvector, , so the largest , the spectral radius , decides whether repeated application grows () or shrinks (). Power iteration repeats ; the component along the second eigenvector shrinks by per step.
2.6 Orthogonality and QR
Section titled “2.6 Orthogonality and QR”The projection of onto the line through is . Gram-Schmidt subtracts from each column its projections onto the previous orthonormal vectors and normalizes the rest, giving ; requiring a positive diagonal of makes the factorization unique. Least squares minimizes ; its solution satisfies the normal equations , which QR solves stably as (M03.5).
3. Worked example by hand
Section titled “3. Worked example by hand”This is a sibling of q6, q7, and q36, not one of the graded problems.
LU with partial pivoting. . The largest entry in column 1 is 6, in row 2, so swap: , . The multiplier is , and row 2 becomes . So , . Check: . In solve/ the factor would be answer = "[[1, 0], [1/3, 1]]".
Eigenvalues and an eigenvector. is triangular, so and the eigenvalues are 3 and 2. For : gives , or any nonzero multiple; the checker accepts [2, -2] too when the key says up_to = "scalar". The product of the eigenvalues is .
4. The problem set
Section titled “4. The problem set”Write each answer in solve/S-M03a.toml:
[q1]answer = "[-4, 9/2]"[q4]answer = "[[1, 0], [2, 1]]"[q15]answer = "[[-1, 1, 0], [-1, 0, 1]]"[q36]answer = "{1, 3}"[q10]proof = "S-M03a/q10.md"A vector is a flat list (one column); a matrix is a list of rows; a basis is a list of vectors, and any basis of the right space passes. Entries are exact: 1/sqrt(2), not 0.7071.
Gaussian elimination and LU
Section titled “Gaussian elimination and LU”q1. Solve , . Give . [vector]
q2. Solve , , . Give . [vector]
q3. Give the reduced row echelon form of . [matrix]
q4. with unit lower triangular and upper triangular, no row exchanges. Give . [matrix]
q5. Give the of q4. [matrix]
q6. Factor as with partial pivoting (swap the row with the largest pivot candidate to the top). Give . [matrix]
q7. Give the of q6. [matrix]
q8. How many solutions has the system , ? [number]
q9. Give the set of for which , has infinitely many solutions. [set]
q10. Prove that if the square matrix is invertible, then has exactly one solution for every . [proof]
Span, linear independence, basis, dimension
Section titled “Span, linear independence, basis, dimension”q11. Is in the span of and ? [bool]
q12. Are and linearly independent? [bool]
q13. Give the dimension of the span of , , . [number]
q14. Give a basis of the column space of . [basis]
q15. Give a basis of the null space of (vectors in ). [basis]
q16. Give the coordinates of in the basis , . [vector]
q17. Give the dimension of the space of symmetric real matrices. [number]
q18. Give the set of for which and are linearly dependent. [set]
q19. Give the dimension of the null space of . [number]
q20. Prove that any vectors in are linearly dependent. [proof]
Linear maps and rank-nullity
Section titled “Linear maps and rank-nullity”q21. Give the matrix of the rotation of by counterclockwise. [matrix]
q22. Give the matrix of from to . [matrix]
q23. Give the rank of . [number]
q24. Give the nullity (dimension of the null space) of the matrix of q23. [number]
q25. A matrix has rank 4. Give the dimension of its null space. [number]
q26. Is , from to , a linear map? [bool]
q27. and . Give the matrix of (first , then ). [matrix]
q28. Prove that the null space of an matrix is a subspace of . [proof]
Determinants
Section titled “Determinants”q29. . [number]
q30. . [number]
q31. . [number]
q32. is with . Give . [number]
q33. . Give . [number]
q34. Give the area of the parallelogram spanned by and . [number]
Eigenvalues and eigenvectors
Section titled “Eigenvalues and eigenvectors”q35. Give the eigenvalues of . [set]
q36. Give the eigenvalues of . [set]
q37. Give an eigenvector of the matrix of q36 for its largest eigenvalue. [vector]
q38. Give the characteristic polynomial of . [expr in t]
q39. Give the (complex) eigenvalues of the rotation . [set]
q40. Give the product of the eigenvalues of . [number]
q41. With from q36, give . [vector]
q42. Give the spectral radius (largest ) of . [number]
q43. Power iteration on the matrix of q36 from a generic start shrinks its error by the factor per step. Give that factor. [number]
q44. Prove that eigenvectors of with eigenvalues are linearly independent. [proof]
Orthogonality and QR
Section titled “Orthogonality and QR”q45. Give the orthogonal projection of onto the line spanned by . [vector]
q46. . Gram-Schmidt on its columns gives with having orthonormal columns and upper triangular with a positive diagonal. Give . [matrix]
q47. Give the of q46. [matrix]
q48. Fit to the points , , by least squares. Give . [number]
5. Pitfalls
Section titled “5. Pitfalls”| Pitfall | Symptom | Caught by |
|---|---|---|
| Storing the reciprocal of the multiplier in | q4 (canary with 1/2) | |
| Skipping the pivot search | multipliers larger than 1 and unstable factors; numpy’s differs from yours | q6, q7 (canaries) |
| Calling an echelon form “reduced” | entries above the pivots left nonzero | q3 (canary) |
| Counting vectors instead of independent vectors | dimension and rank too large | q13 (canary 3), q14 (canary) |
| Confusing rank with nullity, or rows with columns in rank-nullity | the wrong null space dimension | q19, q25 (canaries) |
| Writing images of basis vectors as rows | the transpose of the map’s matrix | q22 (canary) |
| Multiplying maps in the order they are applied | instead of | q27 (canary) |
| volume scale off by | q32 (canary 10) | |
| Reading eigenvalues off the diagonal of a non-triangular matrix | wrong spectral radius; an RNN diagnosed as stable when it is not | q36 (canary {2}), q42 (canary 1/2) |
| Forgetting to divide by in a projection | projections scaled by | q45 (canary) |
6. Where it’s used next
Section titled “6. Where it’s used next”| Direction | Module | How it uses this |
|---|---|---|
| Back | M03.1 | vectors, matrices, row-major layout, and the product you implemented in C |
| Forward | M03.2 | lu and lu_solve with partial pivoting, the factors of q4 to q7 |
| Forward | M03.3 | Householder QR; the uniqueness convention of q46 and q47 |
| Forward | M03.4 | power iteration and spectral_radius, at the rate of q43 |
| Forward | M03.5 | least squares through QR, the problem of q48 |
| Forward | S-M03b | inner products and projections, SVD and low rank, FLOP and byte counts |