AI-ML interleaved practice
Instructions. Solve each problem on its own. These problems deliberately jump between subtopics — before computing, identify which tool each problem needs. Show all work. Use notation for norms. Total: 50 marks.
1. (5 marks) Let and . (a) Compute . (b) Find the angle between them (in terms of ). (c) Find the scalar projection of onto .
2. (6 marks) For the matrix determine whether is symmetric, and whether is positive definite. Justify using the appropriate criterion.
3. (4 marks) Let . Compute , , and .
4. (6 marks) Let . Compute the gradient , and evaluate it at .
5. (5 marks) Given compute , state whether is invertible, and if so compute .
6. (5 marks) Find all eigenvalues of and give an eigenvector for the largest eigenvalue.
7. (5 marks) Determine the rank of using Gaussian elimination, and state the dimension of its null space.
8. (4 marks) Let . Compute using the appropriate differentiation rule.
9. (5 marks) Given is and is . State the dimensions of and of . If , is defined, and what is its dimension? Also state requirements: for which of or is the trace defined?
10. (5 marks) Let . Compute the Hessian matrix and state whether is convex.
Answer keyMark scheme & solutions
1. (Subtopic 1.1.3 — Dot product / projection / angle) (a) . (b) , . , so . (c) Scalar projection of onto . Why: the phrase "angle / projection" signals the dot-product toolkit, not norms alone.
2. (Subtopics 1.1.6 symmetric + 1.1.17 positive definite) (mirror across diagonal) → symmetric. Positive definite test via leading principal minors: ; ; . . All minors positive → positive definite. Why: symmetric structure is required before applying the Sylvester (minors) criterion — recognizing that ordering is the point.
3. (Subtopic 1.1.4 — norms) . . . Why: three different norm definitions on the same vector — forces recall of each formula.
4. (Subtopic 1.2.4 gradient, using 1.2.3 partials) , . . At : ; . So . Why: gradient = vector of partials; chain rule inside .
5. (Subtopics 1.1.9 determinant + 1.1.8 inverse) → invertible. . Why: nonzero determinant is the invertibility condition; then the 2×2 adjugate formula.
6. (Subtopic 1.1.13 — eigenvalues/eigenvectors) . Eigenvalues . Largest is : . Eigenvector . Why: characteristic polynomial, not decomposition — problem only asks eigenvalues/vectors.
7. (Subtopics 1.1.10 rank/null space + 1.1.12 Gaussian elimination) Row-reduce: ; . Rows: → 2 pivots → rank 2. Nullity . Why: elimination reveals rank; rank–nullity gives null-space dimension.
8. (Subtopic 1.2.2 — product + chain rule) . Why: product rule with a chain-rule factor .
9. (Subtopics 1.1.5 matrix mult dims + 1.1.7 transpose + 1.1.16 trace) . is . : vector — defined. Trace requires a square matrix. is (not square) → trace undefined. is (square) → defined. Why: dimensional-compatibility bookkeeping plus square-only trace rule.
10. (Subtopics 1.2.6 Hessian + 1.1.17 relation to PD/convexity) , . . Minors: , → PD → is convex (strictly). Why: connects second-derivative Hessian to positive-definiteness convexity test.
[
{"claim":"Problem 2: det A = 8 and A positive definite (all leading minors positive)","code":"import sympy as sp\nA=sp.Matrix([[2,1,0],[1,3,1],[0,1,2]])\nm1=A[0,0]; m2=A[:2,:2].det(); m3=A.det()\nresult=(m3==8) and all(x>0 for x in [m1,m2,m3])"},
{"claim":"Problem 6: eigenvalues of B are {2,5}","code":"import sympy as sp\nB=sp.Matrix([[4,1],[2,3]])\nresult=set(B.eigenvals().keys())=={sp.Integer(2),sp.Integer(5)}"},
{"claim":"Problem 10: Hessian is [[6,2],[2,2]] and positive definite","code":"import sympy as sp\nx,y=sp.symbols('x y')\nf=3*x**2+2*x*y+y**2\nH=sp.hessian(f,(x,y))\nmz=H[0,0]>0 and H.det()>0\nresult=(H==sp.Matrix([[6,2],[2,2]])) and mz"}
]