Level 3 — ProductionLinear Algebra (Full)

Linear Algebra (Full)

45 minutes60 marksprintable — key stays hidden on paper

Level: 3 — Production (from-scratch derivations, algorithms from memory, explain-out-loud) Time limit: 45 minutes Total marks: 60

Instructions: Show all working. Where a proof or algorithm is requested, reproduce it from memory with full justification of each step.


Question 1 (Cauchy–Schwarz from scratch). [10 marks]

(a) State the Cauchy–Schwarz inequality for u,vRn\mathbf{u},\mathbf{v}\in\mathbb{R}^n. [2]

(b) Prove it from scratch. Consider f(t)=utv20f(t)=\|\mathbf{u}-t\mathbf{v}\|^2\ge 0 and use the discriminant argument. Justify each step. [6]

(c) State the condition for equality and explain geometrically. [2]


Question 2 (Rank–nullity, derivation). [10 marks]

Let AA be an m×nm\times n matrix representing T:RnRmT:\mathbb{R}^n\to\mathbb{R}^m.

(a) Prove the Rank–Nullity theorem dim(NullA)+rank(A)=n\dim(\operatorname{Null} A)+\operatorname{rank}(A)=n, by extending a basis of the null space to a basis of Rn\mathbb{R}^n and showing the images form a basis of the column space. [7]

(b) For A=(121024311201)A=\begin{pmatrix}1&2&1&0\\2&4&3&1\\-1&-2&0&1\end{pmatrix}, find rank(A)\operatorname{rank}(A) and dim(NullA)\dim(\operatorname{Null} A), verifying the theorem. [3]


Question 3 (Gram–Schmidt / QR, algorithm from memory). [12 marks]

(a) Write out the Gram–Schmidt algorithm (in pseudocode or explicit formulas) that converts an independent set {a1,,ak}\{\mathbf{a}_1,\dots,\mathbf{a}_k\} into an orthonormal set. [4]

(b) Apply it to a1=(1,1,0)T\mathbf{a}_1=(1,1,0)^T, a2=(1,0,1)T\mathbf{a}_2=(1,0,1)^T. Give the orthonormal vectors q1,q2\mathbf{q}_1,\mathbf{q}_2. [5]

(c) Explain how Gram–Schmidt yields the QR decomposition A=QRA=QR and state why RR is upper triangular. [3]


Question 4 (Diagonalization, full procedure). [12 marks]

Let A=(2112)A=\begin{pmatrix}2&1\\1&2\end{pmatrix}.

(a) Find the characteristic polynomial and eigenvalues. [3]

(b) Find a basis for each eigenspace. [4]

(c) Give PP and DD with A=PDP1A=PDP^{-1}, choosing PP orthogonal. [3]

(d) Explain out loud (in words) why a real symmetric matrix is always orthogonally diagonalizable (spectral theorem — sketch the key facts, no full proof needed). [2]


Question 5 (Least squares, normal equations from scratch). [10 marks]

Fit a line y=c0+c1xy=c_0+c_1 x through the points (0,1),(1,3),(2,4)(0,1),(1,3),(2,4).

(a) Set up the overdetermined system Ac=bA\mathbf{c}=\mathbf{b} and derive the normal equations ATAc=ATbA^TA\,\mathbf{c}=A^T\mathbf{b} from minimizing Acb2\|A\mathbf{c}-\mathbf{b}\|^2. [4]

(b) Solve for c0,c1c_0,c_1. [4]

(c) State one advantage of the QR approach over forming ATAA^TA directly. [2]


Question 6 (Determinant & Cramer, explain-out-loud). [6 marks]

(a) Using cofactor expansion, compute det(120031201)\det\begin{pmatrix}1&2&0\\0&3&1\\2&0&1\end{pmatrix}. [3]

(b) Use Cramer's rule to solve for xx only in {x+2y=33x+y=5\begin{cases}x+2y=3\\3x+y=5\end{cases}, and explain in one sentence the geometric meaning of the determinant appearing in the denominator. [3]

Answer keyMark scheme & solutions

Question 1

(a) uvuv|\mathbf{u}\cdot\mathbf{v}|\le\|\mathbf{u}\|\,\|\mathbf{v}\|. [2]

(b) If v=0\mathbf{v}=\mathbf{0} trivial. Else define f(t)=utv2=u22t(uv)+t2v20f(t)=\|\mathbf{u}-t\mathbf{v}\|^2=\|\mathbf{u}\|^2-2t(\mathbf{u}\cdot\mathbf{v})+t^2\|\mathbf{v}\|^2\ge0 for all tt [2] (norm-squared is nonneg). This is a quadratic in tt with positive leading coefficient that is never negative, so its discriminant 0\le0: [2] 4(uv)24v2u20(uv)2u2v24(\mathbf{u}\cdot\mathbf{v})^2-4\|\mathbf{v}\|^2\|\mathbf{u}\|^2\le0 \Rightarrow (\mathbf{u}\cdot\mathbf{v})^2\le\|\mathbf{u}\|^2\|\mathbf{v}\|^2. Taking square roots gives the result. [2]

(c) Equality iff f(t)=0f(t)=0 for some tt, i.e. u=tv\mathbf{u}=t\mathbf{v} — the vectors are linearly dependent (parallel/antiparallel). [2]


Question 2

(a) Let {v1,,vk}\{\mathbf{v}_1,\dots,\mathbf{v}_k\} be a basis of NullA\operatorname{Null} A (k=dimNullAk=\dim\operatorname{Null}A). Extend to a basis {v1,,vk,w1,,wr}\{\mathbf{v}_1,\dots,\mathbf{v}_k,\mathbf{w}_1,\dots,\mathbf{w}_r\} of Rn\mathbb{R}^n, so k+r=nk+r=n. [2] Claim {Aw1,,Awr}\{A\mathbf{w}_1,\dots,A\mathbf{w}_r\} is a basis of ColA\operatorname{Col}A. Spanning: any AxA\mathbf{x} with x=aivi+bjwj\mathbf{x}=\sum a_i\mathbf{v}_i+\sum b_j\mathbf{w}_j gives Ax=bjAwjA\mathbf{x}=\sum b_jA\mathbf{w}_j (since Avi=0A\mathbf{v}_i=0). [2] Independence: if cjAwj=0\sum c_jA\mathbf{w}_j=0 then A(cjwj)=0A(\sum c_j\mathbf{w}_j)=0, so cjwjNullA=span(vi)\sum c_j\mathbf{w}_j\in\operatorname{Null}A=\operatorname{span}(\mathbf{v}_i), giving cjwj=divi\sum c_j\mathbf{w}_j=\sum d_i\mathbf{v}_i. By independence of the full basis all cj=0c_j=0. [2] Hence rankA=r\operatorname{rank}A=r and k+r=nk+r=n. [1]

(b) Row reduce: R22R1R_2-2R_1, R3+R1R_3+R_1: (121000110011)R3R2(121000110000)\begin{pmatrix}1&2&1&0\\0&0&1&1\\0&0&1&1\end{pmatrix}\to R_3-R_2\to\begin{pmatrix}1&2&1&0\\0&0&1&1\\0&0&0&0\end{pmatrix}. Two pivots ⇒ rank=2\operatorname{rank}=2. [2] dimNull=42=2\dim\operatorname{Null}=4-2=2; check 2+2=4=n2+2=4=n. ✓ [1]


Question 3

(a) For i=1,,ki=1,\dots,k: ui=aij<iai,qj1qj\mathbf{u}_i=\mathbf{a}_i-\sum_{j<i}\dfrac{\langle\mathbf{a}_i,\mathbf{q}_j\rangle}{1}\mathbf{q}_j (projections onto already-computed qj\mathbf{q}_j), then qi=ui/ui\mathbf{q}_i=\mathbf{u}_i/\|\mathbf{u}_i\|. [4]

(b) q1=12(1,1,0)T\mathbf{q}_1=\frac{1}{\sqrt2}(1,1,0)^T. [1] a2,q1=12(1)=12\langle\mathbf{a}_2,\mathbf{q}_1\rangle=\frac{1}{\sqrt2}(1)= \frac{1}{\sqrt2}. [1] u2=(1,0,1)1212(1,1,0)=(1,0,1)(12,12,0)=(12,12,1)\mathbf{u}_2=(1,0,1)-\frac{1}{\sqrt2}\cdot\frac{1}{\sqrt2}(1,1,0)=(1,0,1)-(\tfrac12,\tfrac12,0)=(\tfrac12,-\tfrac12,1). [2] u2=14+14+1=3/2\|\mathbf{u}_2\|=\sqrt{\tfrac14+\tfrac14+1}=\sqrt{3/2}, so q2=23(12,12,1)=16(1,1,2)T\mathbf{q}_2=\sqrt{\tfrac23}(\tfrac12,-\tfrac12,1)=\frac{1}{\sqrt6}(1,-1,2)^T. [1]

(c) Rearranging Gram–Schmidt, ai=jirjiqj\mathbf{a}_i=\sum_{j\le i}r_{ji}\mathbf{q}_j with rji=ai,qjr_{ji}=\langle\mathbf{a}_i,\mathbf{q}_j\rangle and rii=uir_{ii}=\|\mathbf{u}_i\|. Since ai\mathbf{a}_i is a combination of only q1..qi\mathbf{q}_1..\mathbf{q}_i, the matrix R=[rji]R=[r_{ji}] has zeros below the diagonal ⇒ upper triangular; A=QRA=QR with QQ orthonormal columns. [3]


Question 4

(a) det(AλI)=(2λ)21=λ24λ+3=(λ1)(λ3)\det(A-\lambda I)=(2-\lambda)^2-1=\lambda^2-4\lambda+3=(\lambda-1)(\lambda-3); eigenvalues λ=1,3\lambda=1,3. [3]

(b) λ=3\lambda=3: (A3I)=(1111)(A-3I)=\begin{pmatrix}-1&1\\1&-1\end{pmatrix} ⇒ eigenvector (1,1)T(1,1)^T. [2] λ=1\lambda=1: (AI)=(1111)(A-I)=\begin{pmatrix}1&1\\1&1\end{pmatrix} ⇒ eigenvector (1,1)T(1,-1)^T. [2]

(c) Normalize: P=12(1111)P=\frac{1}{\sqrt2}\begin{pmatrix}1&1\\1&-1\end{pmatrix}, D=(3001)D=\begin{pmatrix}3&0\\0&1\end{pmatrix}, A=PDP1=PDPTA=PDP^{-1}=PDP^T. [3]

(d) Key facts: symmetric matrices have all real eigenvalues; eigenvectors from distinct eigenvalues are orthogonal (from λx,y=Ax,y=x,Ay=μx,y\lambda\langle x,y\rangle=\langle Ax,y\rangle=\langle x,Ay\rangle=\mu\langle x,y\rangle); repeated eigenvalues still yield orthogonal eigenbases within eigenspaces — combining gives an orthonormal eigenbasis, so A=QΛQTA=Q\Lambda Q^T. [2]


Question 5

(a) A=(101112)A=\begin{pmatrix}1&0\\1&1\\1&2\end{pmatrix}, b=(1,3,4)T\mathbf{b}=(1,3,4)^T. Minimizing E=Acb2E=\|A\mathbf{c}-\mathbf{b}\|^2, E=2AT(Acb)=0ATAc=ATb\nabla E=2A^T(A\mathbf{c}-\mathbf{b})=0\Rightarrow A^TA\mathbf{c}=A^T\mathbf{b}. [4]

(b) ATA=(3335)A^TA=\begin{pmatrix}3&3\\3&5\end{pmatrix}, ATb=(811)A^T\mathbf{b}=\begin{pmatrix}8\\11\end{pmatrix}. Solve: det=159=6\det=15-9=6. c0=583116=40336=76c_0=\frac{5\cdot8-3\cdot11}{6}=\frac{40-33}{6}=\frac{7}{6}, c1=311386=96=32c_1=\frac{3\cdot11-3\cdot8}{6}=\frac{9}{6}=\frac{3}{2}. [4]

(c) QR avoids forming ATAA^TA, which squares the condition number and can lose precision; QR is numerically more stable. [2]


Question 6

(a) Expand along first column: 1(3110)0+2(2103)=13+22=71\cdot(3\cdot1-1\cdot0)-0+2\cdot(2\cdot1-0\cdot3)=1\cdot3+2\cdot2=7. [3]

(b) D=det(1231)=16=5D=\det\begin{pmatrix}1&2\\3&1\end{pmatrix}=1-6=-5. x=det(3251)5=3105=75x=\dfrac{\det\begin{pmatrix}3&2\\5&1\end{pmatrix}}{-5}=\dfrac{3-10}{-5}=\dfrac{7}{5}. [2] Geometric meaning: DD is the signed area of the parallelogram spanned by the coefficient columns; nonzero ⇒ unique solution. [1]


[
{"claim":"Q2 rank of A is 2","code":"A=Matrix([[1,2,1,0],[2,4,3,1],[-1,-2,0,1]]); result=(A.rank()==2)"},
{"claim":"Q2 nullity 2, theorem 2+2=4","code":"A=Matrix([[1,2,1,0],[2,4,3,1],[-1,-2,0,1]]); result=(len(A.nullspace())==2 and A.rank()+len(A.nullspace())==4)"},
{"claim":"Q3 q2 = (1,-1,2)/sqrt6 orthonormal to q1","code":"q1=Matrix([1,1,0])/sqrt(2); q2=Matrix([1,-1,2])/sqrt(6); result=(simplify(q1.dot(q2))==0 and simplify(q2.dot(q2))==1)"},
{"claim":"Q4 eigenvalues 1 and 3","code":"A=Matrix([[2,1],[1,2]]); result=(set(A.eigenvals().keys())=={1,3})"},
{"claim":"Q5 least squares c0=7/6, c1=3/2","code":"A=Matrix([[1,0],[1,1],[1,2]]); b=Matrix([1,3,4]); c=(A.T*A).inv()*A.T*b; result=(c[0]==Rational(7,6) and c[1]==Rational(3,2))"},
{"claim":"Q6 determinant equals 7","code":"M=Matrix([[1,2,0],[0,3,1],[2,0,1]]); result=(M.det()==7)"},
{"claim":"Q6 Cramer x = 7/5","code":"result=(Rational((3*1-2*5),(1*1-2*3))==Rational(7,5))"}
]