Calculus & Optimization Basics
Level 5 Mastery Examination
Time limit: 90 minutes Total marks: 60 Instructions: Answer all three questions. Show full working. You may write pseudocode/Python where requested. Use for inline math.
Question 1 — Backpropagation from first principles (physics-flavoured energy descent) [22 marks]
A single "neuron" models a damped oscillator's steady-state error. Given input , parameters , define
where is a target. This is one node of a computational graph.
(a) Using the multivariate chain rule, derive closed-form expressions for , in terms of . State the intermediate "upstream gradient" explicitly. [6]
(b) Prove that starting from the definition . [4]
(c) For , compute the numerical values of . Give at least 4 significant figures. [6]
(d) One gradient-descent update is applied with learning rate . Compute the new . Then argue physically/analytically whether the loss decreased, and explain what an excessively large would do to convergence, linking it to the curvature (second derivative) of w.r.t. . [6]
Question 2 — Constrained optimization on a manifold [20 marks]
Consider minimizing subject to the constraint .
(a) Set up the Lagrangian and derive the stationarity conditions. Solve for the constrained minimizer and multiplier . [7]
(b) Compute the Hessian of and verify the point found is a minimum along the constraint (use the bordered Hessian OR argue via convexity of restricted to the line). [6]
(c) Give the geometric interpretation: state the relationship between and at and verify it numerically. [4]
(d) Is convex on ? Justify using its Hessian eigenvalues, and state why this guarantees the constrained solution is the global constrained minimum. [3]
Question 3 — Landscape analysis: critical points, saddles, and Taylor [18 marks]
Let (the "monkey saddle").
(a) Find all critical points by solving . [4]
(b) Compute the Hessian and evaluate it at the critical point(s). Classify the point using the eigenvalue / determinant test. Explain why the standard second-derivative test is inconclusive here and what that implies about the local geometry. [6]
(c) Write the second-order Taylor expansion of about . Then, using only the gradient at , give the unit direction of steepest ascent and the directional derivative magnitude along it. [6]
(d) A gradient-descent iterate sits exactly at the critical point of part (a) with zero gradient. Explain in one or two sentences why plain gradient descent stalls there and name one mechanism that escapes it. [2]
Answer keyMark scheme & solutions
Question 1
(a) [6 marks] Chain rule through the graph .
- [1]
- (since ) [1]
- Upstream gradient: [2]
- , hence [2]
(b) [4 marks] Let , , so . Note , . [1] Quotient rule: [3] (Full marks for showing formation.)
(c) [6 marks]
- [1]
- [1]
- ; [1]
- [1]
- [1]
- [1]
(d) [6 marks] Update (): ; . [2] New , , new ; old . Loss decreased. [2] Curvature/large- argument: as a function of has second derivative (local curvature) ; gradient descent is stable when where is the local curvature. Too large overshoots the minimum, causing oscillation or divergence (the step jumps past the valley bottom and climbs the opposite wall). Full marks for linking overshoot to . [2]
Question 2
(a) [7 marks] . [1] Stationarity:
- [1]
- [1]
- constraint: [1] Sub: . [1] So . [2]
(b) [6 marks] , positive definite (eigenvalues ). [3] Restricting to line : , ⇒ minimum; confirms . [3]
(c) [4 marks] At optimum : ; ; indeed . Gradients are parallel (level set of tangent to constraint line). [4]
(d) [3 marks] has eigenvalues ⇒ is (strictly) convex on . [2] A convex objective over an affine (hence convex) constraint set has a unique global minimum, so is the global constrained minimizer. [1]
Question 3
(a) [4 marks] . Set : or .
- If : .
- If : . Unique critical point . [4]
(b) [6 marks] . At : . [3] Determinant , both eigenvalues ⇒ second-derivative test inconclusive. [2] The quadratic term vanishes; behaviour is governed by the cubic terms, giving a degenerate "monkey saddle" (three ascending, three descending sectors) — neither max, min, nor ordinary saddle. [1]
(c) [6 marks] At : . . [2] . Second-order Taylor with : [2] Steepest ascent direction = ; magnitude of directional derivative . [2]
(d) [2 marks] Gradient is exactly zero, so the update leaves unchanged — GD stalls at the flat critical point. Escape mechanisms: stochastic-gradient noise (SGD), momentum, or a random perturbation / second-order (Newton/saddle-free) step. [2]
[
{"claim":"Q1c: delta=(a-y)(1-a^2)=0.31985 for z=1,y=0","code":"z=Rational(1); a=tanh(z); delta=(a-0)*(1-a**2); result = abs(float(delta)-0.31985)<1e-4"},
{"claim":"Q1c: dL/dw = delta*x = 0.63970 with x=2","code":"z=Rational(1); a=tanh(z); delta=a*(1-a**2); dLdw=delta*2; result = abs(float(dLdw)-0.63970)<1e-4"},
{"claim":"Q1d: loss decreased after eta=1 update (L'<L)","code":"a=tanh(1); delta=a*(1-a**2); w=0.5-1.0*float(delta)*2; b=0-1.0*float(delta); import sympy as sp; zp=w*2+b; ap=sp.tanh(zp); Lp=0.5*ap**2; L=0.5*a**2; result = float(Lp)<float(L)"},
{"claim":"Q2a: constrained minimizer x*=2,y*=1,lambda*=4","code":"x,y,lam=symbols('x y lam'); sol=solve([2*x-lam,4*y-lam,x+y-3],[x,y,lam],dict=True)[0]; result = sol[x]==2 and sol[y]==1 and sol[lam]==4"},
{"claim":"Q2c: grad f = lambda* grad g at optimum: (4,4)=4*(1,1)","code":"gf=Matrix([2*2,4*1]); gg=Matrix([1,1]); result = gf==4*gg"},
{"claim":"Q3a: unique critical point (0,0)","code":"x,y=symbols('x y'); f=x**3-3*x*y**2; sol=solve([diff(f,x),diff(f,y)],[x,y],dict=True); result = sol==[{x:0,y:0}]"},
{"claim":"Q3b: Hessian at origin is zero matrix (test inconclusive)","code":"x,y=symbols('x y'); f=x**3-3*x*y**2; H=hessian(f,(x,y)).subs({x:0,y:0}); result = H==zeros(2,2)"},
{"claim":"Q3c: grad f at (1,1) = (0,-6), norm 6","code":"x,y=symbols('x y'); f=x**3-3*x*y**2; g=Matrix([diff(f,x),diff(f,y)]).subs({x:1,y:1}); result = g==Matrix([0,-6]) and g.norm()==6"}
]