Skip to content

Linear algebra problem set, part a: elimination, LU, bases, rank, determinants, eigenvalues, QR

ModuleS-M03a · solve · none · Pass 2 · 6 to 8 h
You buildanswers 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)
Contractnone: a pen and paper set
Testscourse/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
Needsno module. Reading: M03.1 (vectors, matrices, and the matrix product) and the Linear Algebra topic
Used byno 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
MilestoneMS-P2 (the Pass 2 gate runs ol check on every solve part of the pass)
Optional depthStrang, Introduction to Linear Algebra, ch. 2 to 6 (and MIT 18.06 lectures 1 to 21); Hefferon, Linear Algebra (free), ch. 1 to 5
  • Elimination is LU: the multipliers are LL, the result is UU, 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 n+1n + 1 vectors in Rn\mathbb{R}^n 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 AA is governed by its eigenvalues: Akv=λkvA^k v = \lambda^k v, power iteration converges at rate ∣λ2/λ1∣|\lambda_2/\lambda_1|, and a spectral radius below 1 shrinks everything (q41 to q43).
Terminal window
ol start S-M03a # writes solve/S-M03a.toml and the four proof files
ol 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 proof

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.

SymbolMeaningType / shape
A∈Rm×nA \in \mathbb{R}^{m \times n}a matrix with mm rows and nn columnsmatrix
x,bx, bthe unknown and the right-hand side of Ax=bAx = bvectors
P,L,UP, L, Upermutation, unit lower triangular, upper triangular: PA=LUPA = LUn×nn \times n
span⁡{vi}\operatorname{span}\{v_i\}all linear combinations ∑civi\sum c_i v_isubspace
dim⁡V\dim Vthe number of vectors in any basis of VVinteger
rank⁡A\operatorname{rank} Athe dimension of the column space (equal to that of the row space)integer
N(A)N(A)the null space {x:Ax=0}\{x : Ax = 0\}; its dimension is the nullitysubspace
det⁡A\det Athe determinant of a square matrixreal
λ,v\lambda, van eigenvalue and an eigenvector: Av=λvAv = \lambda v, v≠0v \ne 0scalar, vector
ρ(A)\rho(A)the spectral radius, $\max\lambda
Q,RQ, Rorthonormal columns and upper triangular: A=QRA = QRmatrices

Gaussian elimination subtracts multiples of a pivot row from the rows below it until the matrix is upper triangular, UU. Recording each multiplier ℓij\ell_{ij} (the amount of row jj subtracted from row ii) in a unit lower triangular LL gives A=LUA = LU, so solving Ax=bAx = b 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 ∣aij∣|a_{ij}| in the current column into the pivot position, giving PA=LUPA = LU with every ∣ℓij∣≤1|\ell_{ij}| \le 1. 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).

Vectors are linearly independent when ∑civi=0\sum c_i v_i = 0 forces every ci=0c_i = 0. A basis of a subspace is an independent spanning set, and every basis has the same size, the dimension. The pivot columns of AA 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 cc with ∑civi=x\sum c_i v_i = x: solve a linear system.

A map TT is linear when T(x+y)=T(x)+T(y)T(x + y) = T(x) + T(y) and T(cx)=cT(x)T(cx) = cT(x); then T(x)=AxT(x) = Ax where column jj of AA is T(ej)T(e_j). Composition is multiplication: S∘TS \circ T has matrix S TS\,T (apply TT first, so it is on the right). For AA with nn columns, rank-nullity says rank⁡A+dim⁡N(A)=n\operatorname{rank} A + \dim N(A) = n.

The determinant is the signed volume scale factor of x↦Axx \mapsto Ax: ∣det⁡[u v]∣|\det [u\ v]| is the area of the parallelogram spanned by uu and vv. It is multiplicative, det⁡(AB)=det⁡Adet⁡B\det(AB) = \det A \det B, so det⁡(A−1)=1/det⁡A\det(A^{-1}) = 1/\det A; it scales as det⁡(cA)=cndet⁡A\det(cA) = c^n \det A for n×nn \times n AA; a triangular matrix’s determinant is the product of its diagonal; and det⁡A=0\det A = 0 exactly when AA is singular.

λ\lambda is an eigenvalue when A−λIA - \lambda I is singular, that is, a root of the characteristic polynomial det⁡(tI−A)\det(tI - A); the product of the eigenvalues is det⁡A\det A and their sum is the trace. A real matrix may have complex eigenvalues (a rotation moves every real vector). If vv is an eigenvector, Akv=λkvA^k v = \lambda^k v, so the largest ∣λ∣|\lambda|, the spectral radius ρ(A)\rho(A), decides whether repeated application grows (ρ>1\rho > 1) or shrinks (ρ<1\rho < 1). Power iteration repeats v←Av/∥Av∥v \leftarrow Av / \lVert Av \rVert; the component along the second eigenvector shrinks by ∣λ2/λ1∣|\lambda_2/\lambda_1| per step.

The projection of bb onto the line through uu is u⋅bu⋅uu\frac{u \cdot b}{u \cdot u} u. Gram-Schmidt subtracts from each column its projections onto the previous orthonormal vectors and normalizes the rest, giving A=QRA = QR; requiring a positive diagonal of RR makes the factorization unique. Least squares minimizes ∥Ax−b∥2\lVert Ax - b \rVert^2; its solution satisfies the normal equations A⊤Ax=A⊤bA^\top A x = A^\top b, which QR solves stably as Rx=Q⊤bRx = Q^\top b (M03.5).

This is a sibling of q6, q7, and q36, not one of the graded problems.

LU with partial pivoting. A=(2164)A = \begin{pmatrix} 2 & 1 \\ 6 & 4 \end{pmatrix}. The largest entry in column 1 is 6, in row 2, so swap: P=(0110)P = \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix}, PA=(6421)PA = \begin{pmatrix} 6 & 4 \\ 2 & 1 \end{pmatrix}. The multiplier is ℓ21=2/6=1/3\ell_{21} = 2/6 = 1/3, and row 2 becomes (2,1)−13(6,4)=(0,−1/3)(2, 1) - \frac13 (6, 4) = (0, -1/3). So L=(101/31)L = \begin{pmatrix} 1 & 0 \\ 1/3 & 1 \end{pmatrix}, U=(640−1/3)U = \begin{pmatrix} 6 & 4 \\ 0 & -1/3 \end{pmatrix}. Check: LU=(6424/3−1/3)=PALU = \begin{pmatrix} 6 & 4 \\ 2 & 4/3 - 1/3 \end{pmatrix} = PA. In solve/ the factor LL would be answer = "[[1, 0], [1/3, 1]]".

Eigenvalues and an eigenvector. B=(3102)B = \begin{pmatrix} 3 & 1 \\ 0 & 2 \end{pmatrix} is triangular, so det⁡(tI−B)=(t−3)(t−2)\det(tI - B) = (t - 3)(t - 2) and the eigenvalues are 3 and 2. For λ=2\lambda = 2: (B−2I)v=(1100)v=0(B - 2I)v = \begin{pmatrix} 1 & 1 \\ 0 & 0 \end{pmatrix} v = 0 gives v=(1,−1)v = (1, -1), or any nonzero multiple; the checker accepts [2, -2] too when the key says up_to = "scalar". The product of the eigenvalues is 6=det⁡B6 = \det B.

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.

q1. Solve x+2y=5x + 2y = 5, 3x+4y=63x + 4y = 6. Give (x,y)(x, y). [vector]

q2. Solve x+y+z=6x + y + z = 6, 2x−y+z=32x - y + z = 3, x+2y−z=2x + 2y - z = 2. Give (x,y,z)(x, y, z). [vector]

q3. Give the reduced row echelon form of (123247)\begin{pmatrix} 1 & 2 & 3 \\ 2 & 4 & 7 \end{pmatrix}. [matrix]

q4. A=(2145)=LUA = \begin{pmatrix} 2 & 1 \\ 4 & 5 \end{pmatrix} = LU with LL unit lower triangular and UU upper triangular, no row exchanges. Give LL. [matrix]

q5. Give the UU of q4. [matrix]

q6. Factor A=(1234)A = \begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix} as PA=LUPA = LU with partial pivoting (swap the row with the largest pivot candidate to the top). Give LL. [matrix]

q7. Give the UU of q6. [matrix]

q8. How many solutions has the system x+y=1x + y = 1, x+y=2x + y = 2? [number]

q9. Give the set of kk for which x+ky=1x + k y = 1, kx+y=1k x + y = 1 has infinitely many solutions. [set]

q10. Prove that if the square matrix AA is invertible, then Ax=bAx = b has exactly one solution for every bb. [proof]

Span, linear independence, basis, dimension

Section titled “Span, linear independence, basis, dimension”

q11. Is (1,2,3)(1, 2, 3) in the span of (1,0,1)(1, 0, 1) and (0,1,1)(0, 1, 1)? [bool]

q12. Are (1,2)(1, 2) and (2,4)(2, 4) linearly independent? [bool]

q13. Give the dimension of the span of (1,0,1)(1, 0, 1), (0,1,1)(0, 1, 1), (1,1,2)(1, 1, 2). [number]

q14. Give a basis of the column space of (122436)\begin{pmatrix} 1 & 2 \\ 2 & 4 \\ 3 & 6 \end{pmatrix}. [basis]

q15. Give a basis of the null space of (111)\begin{pmatrix} 1 & 1 & 1 \end{pmatrix} (vectors in R3\mathbb{R}^3). [basis]

q16. Give the coordinates of (3,5)(3, 5) in the basis (1,1)(1, 1), (1,−1)(1, -1). [vector]

q17. Give the dimension of the space of symmetric 2×22 \times 2 real matrices. [number]

q18. Give the set of cc for which (1,c)(1, c) and (c,4)(c, 4) are linearly dependent. [set]

q19. Give the dimension of the null space of (123246)\begin{pmatrix} 1 & 2 & 3 \\ 2 & 4 & 6 \end{pmatrix}. [number]

q20. Prove that any n+1n + 1 vectors in Rn\mathbb{R}^n are linearly dependent. [proof]

q21. Give the matrix of the rotation of R2\mathbb{R}^2 by 90°90° counterclockwise. [matrix]

q22. Give the matrix of T(x,y)=(x+y, 2x, y)T(x, y) = (x + y,\ 2x,\ y) from R2\mathbb{R}^2 to R3\mathbb{R}^3. [matrix]

q23. Give the rank of (123456789)\begin{pmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{pmatrix}. [number]

q24. Give the nullity (dimension of the null space) of the matrix of q23. [number]

q25. A 5×75 \times 7 matrix has rank 4. Give the dimension of its null space. [number]

q26. Is T(x)=x+1T(x) = x + 1, from R\mathbb{R} to R\mathbb{R}, a linear map? [bool]

q27. T(x,y)=(y,x)T(x, y) = (y, x) and S(x,y)=(2x,y)S(x, y) = (2x, y). Give the matrix of S∘TS \circ T (first TT, then SS). [matrix]

q28. Prove that the null space {x:Ax=0}\{x : Ax = 0\} of an m×nm \times n matrix AA is a subspace of Rn\mathbb{R}^n. [proof]

q29. det⁡(2174)\det \begin{pmatrix} 2 & 1 \\ 7 & 4 \end{pmatrix}. [number]

q30. det⁡(123045006)\det \begin{pmatrix} 1 & 2 & 3 \\ 0 & 4 & 5 \\ 0 & 0 & 6 \end{pmatrix}. [number]

q31. det⁡(1234567810)\det \begin{pmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 10 \end{pmatrix}. [number]

q32. AA is 3×33 \times 3 with det⁡A=5\det A = 5. Give det⁡(2A)\det(2A). [number]

q33. det⁡A=4\det A = 4. Give det⁡(A−1)\det(A^{-1}). [number]

q34. Give the area of the parallelogram spanned by (3,1)(3, 1) and (1,2)(1, 2). [number]

q35. Give the eigenvalues of (2003)\begin{pmatrix} 2 & 0 \\ 0 & 3 \end{pmatrix}. [set]

q36. Give the eigenvalues of (2112)\begin{pmatrix} 2 & 1 \\ 1 & 2 \end{pmatrix}. [set]

q37. Give an eigenvector of the matrix of q36 for its largest eigenvalue. [vector]

q38. Give the characteristic polynomial det⁡(tI−A)\det(tI - A) of A=(1234)A = \begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix}. [expr in t]

q39. Give the (complex) eigenvalues of the rotation (0−110)\begin{pmatrix} 0 & -1 \\ 1 & 0 \end{pmatrix}. [set]

q40. Give the product of the eigenvalues of (4123)\begin{pmatrix} 4 & 1 \\ 2 & 3 \end{pmatrix}. [number]

q41. With AA from q36, give A10(1,1)A^{10} (1, 1). [vector]

q42. Give the spectral radius (largest ∣λ∣|\lambda|) of (1/22/52/51/2)\begin{pmatrix} 1/2 & 2/5 \\ 2/5 & 1/2 \end{pmatrix}. [number]

q43. Power iteration on the matrix of q36 from a generic start shrinks its error by the factor ∣λ2/λ1∣|\lambda_2 / \lambda_1| per step. Give that factor. [number]

q44. Prove that eigenvectors v1,v2v_1, v_2 of AA with eigenvalues λ1≠λ2\lambda_1 \ne \lambda_2 are linearly independent. [proof]

q45. Give the orthogonal projection of (1,2,3)(1, 2, 3) onto the line spanned by (1,1,1)(1, 1, 1). [vector]

q46. A=(111001)A = \begin{pmatrix} 1 & 1 \\ 1 & 0 \\ 0 & 1 \end{pmatrix}. Gram-Schmidt on its columns gives A=QRA = QR with QQ having orthonormal columns and RR upper triangular with a positive diagonal. Give QQ. [matrix]

q47. Give the RR of q46. [matrix]

q48. Fit y=c xy = c\,x to the points (1,1)(1, 1), (2,2)(2, 2), (3,2)(3, 2) by least squares. Give cc. [number]

PitfallSymptomCaught by
Storing the reciprocal of the multiplier in LLLU≠ALU \ne Aq4 (canary with 1/2)
Skipping the pivot searchmultipliers larger than 1 and unstable factors; numpy’s PP differs from yoursq6, q7 (canaries)
Calling an echelon form “reduced”entries above the pivots left nonzeroq3 (canary)
Counting vectors instead of independent vectorsdimension and rank too largeq13 (canary 3), q14 (canary)
Confusing rank with nullity, or rows with columns in rank-nullitythe wrong null space dimensionq19, q25 (canaries)
Writing images of basis vectors as rowsthe transpose of the map’s matrixq22 (canary)
Multiplying maps in the order they are appliedTSTS instead of STSTq27 (canary)
det⁡(cA)=cdet⁡A\det(cA) = c \det Avolume scale off by cn−1c^{n-1}q32 (canary 10)
Reading eigenvalues off the diagonal of a non-triangular matrixwrong spectral radius; an RNN diagnosed as stable when it is notq36 (canary {2}), q42 (canary 1/2)
Forgetting to divide by u⋅uu \cdot u in a projectionprojections scaled by ∥u∥2\lVert u \rVert^2q45 (canary)
DirectionModuleHow it uses this
BackM03.1vectors, matrices, row-major layout, and the product you implemented in C
ForwardM03.2lu and lu_solve with partial pivoting, the factors of q4 to q7
ForwardM03.3Householder QR; the uniqueness convention of q46 and q47
ForwardM03.4power iteration and spectral_radius, at the rate of q43
ForwardM03.5least squares through QR, the problem of q48
ForwardS-M03binner products and projections, SVD and low rank, FLOP and byte counts