Linear Algebra Essentials
Difficulty: Level 3 — Production (from-scratch derivations, code-from-memory, explain-out-loud) Time limit: 45 minutes Total marks: 60
Instructions: Show all derivations. Where code is requested, write it from memory in plain Python/NumPy. Explain reasoning where asked.
Q1. (10 marks) — Derivation: dot product, angle, projection
(a) Starting from the law of cosines, derive the relationship . (4)
(b) Given and , compute the scalar projection of onto and the vector projection of onto . (4)
(c) Explain in one or two sentences why the dot product is exactly when vectors are orthogonal. (2)
Q2. (12 marks) — Eigenvalues, eigenvectors, and decomposition
Let .
(a) Derive the eigenvalues from the characteristic polynomial . (4)
(b) Find a unit eigenvector for each eigenvalue. (4)
(c) Write the eigendecomposition explicitly, and state why is orthogonal here. (4)
Q3. (10 marks) — Code from memory
(a) Write a NumPy function power_iteration(A, iters=100) that returns the dominant eigenvalue and its eigenvector via power iteration. Include normalization each step and the Rayleigh quotient for the eigenvalue. (6)
(b) Explain out loud (in prose) why power iteration converges to the eigenvector of largest-magnitude eigenvalue, and one condition under which it fails. (4)
Q4. (10 marks) — Gaussian elimination + rank/null space
Consider the system
(a) Perform Gaussian elimination to row echelon form. (4)
(b) State the rank of the coefficient matrix and give a basis for its null space. (4)
(c) Does a solution exist? If so, give the general solution. (2)
Q5. (10 marks) — Positive definiteness & quadratic forms
Let .
(a) Write as a quadratic form with symmetric. (3)
(b) Determine whether is positive definite using both the eigenvalue test and the leading-principal-minor (Sylvester) test. (5)
(c) State what positive definiteness of the Hessian implies for a critical point in optimization. (2)
Q6. (8 marks) — SVD intuition
(a) State the SVD and describe geometrically what each of , , does to a unit sphere. (4)
(b) Explain the relationship between the singular values of and the eigenvalues of . (4)
Answer keyMark scheme & solutions
Q1.
(a) Consider triangle with sides , and . Law of cosines: Expand LHS: . (2) Equate and cancel : . (2)
(b) ; . (1) Scalar projection . (1) Vector projection . (2)
(c) iff ; since (with nonzero norms), the product is zero exactly when , i.e. vectors are perpendicular. (2)
Q2.
(a) . (2) Roots: . (2)
(b) For : , unit . (2) For : , unit . (2)
(c) , , and . (2) is orthogonal because is symmetric ⇒ eigenvectors of distinct eigenvalues are orthogonal; normalized they form an orthonormal set so . (2)
Q3.
(a) (6)
import numpy as np
def power_iteration(A, iters=100):
n = A.shape[0]
v = np.random.rand(n)
v = v / np.linalg.norm(v)
for _ in range(iters):
w = A @ v
v = w / np.linalg.norm(w) # normalize each step
eigval = v @ (A @ v) / (v @ v) # Rayleigh quotient
return eigval, vMarks: normalization (2), iteration/matvec (2), Rayleigh quotient (2).
(b) Expand the start vector in the eigenbasis . Then . Since for , all other terms vanish, leaving the direction of . (2) Fails if is not strictly dominant (e.g. or complex pair equal magnitude), or if (start vector orthogonal to dominant eigenvector). (2)
Q4.
(a) Rows , : Then : (4)
(b) Rank (two nonzero pivot rows). (2) Null space: from echelon form, (from row 2 homogeneous), . Free variable : null vector . Basis . (2)
(c) Consistent (no nonzero row). Particular: , choose , so . General: . (2)
Q5.
(a) (off-diagonals split the term equally). (3)
(b) Eigenvalue test: from Q2, eigenvalues are and , both ⇒ positive definite. (2.5) Sylvester: leading minors , ⇒ positive definite. (2.5)
(c) A positive-definite Hessian at a critical point means the point is a strict local minimum (locally convex). (2)
Q6.
(a) with orthogonal, diagonal (nonneg singular values). rotates/reflects input basis, scales along axes by singular values (unit sphere → axis-aligned ellipsoid), rotates the ellipsoid into output space. (4)
(b) , an eigendecomposition. Hence eigenvalues of are , so singular values (nonnegative). (4)
[
{"claim":"Q1b vector projection of (3,4) onto (4,0) is (3,0)","code":"a=Matrix([3,4]); b=Matrix([4,0]); proj=(a.dot(b)/b.dot(b))*b; result = proj==Matrix([3,0])"},
{"claim":"Q2 eigenvalues of [[2,1],[1,2]] are 1 and 3","code":"A=Matrix([[2,1],[1,2]]); result = set(A.eigenvals().keys())=={1,3}"},
{"claim":"Q4 rank of coefficient matrix is 2","code":"M=Matrix([[1,2,1],[2,4,3],[3,6,4]]); result = M.rank()==2"},
{"claim":"Q4 null space basis vector (-2,1,0)","code":"M=Matrix([[1,2,1],[2,4,3],[3,6,4]]); ns=M.nullspace(); result = ns[0]== -2*Matrix([1,Rational(-1,2),0]) or ns[0].T*Matrix([1,2,1])==Matrix([0]) and (M*Matrix([-2,1,0])==Matrix([0,0,0]))"},
{"claim":"Q5 M=[[2,1],[1,2]] is positive definite (both leading minors positive)","code":"M=Matrix([[2,1],[1,2]]); result = (M[0,0]>0) and (M.det()>0)"}
]