Calculus & Optimization Basics
Level: 4 (Application — novel problems, no hints) Time limit: 60 minutes Total marks: 60
Question 1 — Gradients, Hessians, and critical points (14 marks)
Consider the function
(a) Compute . (3 marks)
(b) Find all critical points of . (4 marks)
(c) Compute the Hessian and classify the critical point at the origin. (4 marks)
(d) A model uses gradient descent with learning rate starting at . Write the coordinates after one update step in terms of . (3 marks)
Question 2 — Directional derivative and steepest ascent (10 marks)
Let evaluated near the point .
(a) Compute the directional derivative of at in the direction of the vector . (5 marks)
(b) State the unit vector along which increases most rapidly at , and give the maximum rate of increase. (5 marks)
Question 3 — Constrained optimization via Lagrange multipliers (14 marks)
A neural network's regularization forces the weight vector onto the constraint . We wish to optimize the objective
(a) Set up the Lagrangian and derive the stationarity equations. (4 marks)
(b) Solve for all candidate points satisfying the conditions. (6 marks)
(c) Identify which candidates give the maximum and minimum of on the constraint, and state those extreme values. (4 marks)
Question 4 — Taylor approximation & convexity (12 marks)
Let (the softplus function).
(a) Compute and . (4 marks)
(b) Using a second-order Taylor expansion about , write the quadratic approximation . (4 marks)
(c) Prove that is convex on all of . (4 marks)
Question 5 — Chain rule / backprop and learning-rate reasoning (10 marks)
A tiny network computes, for scalar input : where is a fixed target and are parameters.
(a) Using the multivariate chain rule, derive and . (6 marks)
(b) Explain in 2–3 sentences what happens to gradient-descent convergence if the learning rate is (i) far too large, (ii) far too small. (4 marks)
End of paper.
Answer keyMark scheme & solutions
Question 1 (14 marks)
(a) Partial derivatives (3):
- (1.5), (1.5).
(b) Critical points: set both to zero (4). From : . From : , so or .
- If : then . Point . (1)
- If , and :
- : , so . (1.5)
- : (y≠0), , so . (1.5)
Critical points: .
(c) Hessian (4): (2 for correct entries.) At origin — the Hessian is the zero matrix, so the second-derivative test is inconclusive (2). (Higher-order analysis needed; origin is a degenerate critical point.)
(d) GD update: (3). At : . New point .
Question 2 (10 marks)
(a) (5) , . At : , , so (2). Unit vector of : magnitude , (1.5). (1.5).
(b) (5) Steepest ascent is along (unit vector) (2.5). Maximum rate (2.5).
Question 3 (14 marks)
(a) (4) Lagrangian: Stationarity:
- (1.5)
- (1.5)
- constraint: (1)
(b) (6) From eqs: , . If : (2). Then , i.e. (1). Constraint: (1.5). Then . Four candidate points: (1.5) (If then , which violates constraint — rejected.)
(c) (4) .
- Maximum at and (same-sign product). (2)
- Minimum at the opposite-sign pairs. (2)
Question 4 (12 marks)
(a) (4) . (sigmoid) (2). (2).
(b) (4) At : ; ; . (1 each for the three coefficients; 1 for correct factor on quadratic term.)
(c) (4) . For all real , and , so everywhere (3). A twice-differentiable function with strictly positive second derivative is (strictly) convex on (1).
Question 5 (10 marks)
(a) (6) Chain rule. ; ; , .
- (1), (1.5), assembling with the factor (2), (1.5).
(b) (4) (i) Too large: updates overshoot the minimum, loss oscillates or diverges (weights blow up) — no convergence (2). (ii) Too small: steps are tiny, convergence is very slow and may stall / need many iterations; can get stuck near flat regions (2).
[
{"claim":"Gradient of f at (1,0) is (3,0)","code":"x,y=symbols('x y'); f=x**3-3*x*y**2+y**4; g=[diff(f,x),diff(f,y)]; result = [gg.subs({x:1,y:0}) for gg in g]==[3,0]"},
{"claim":"(3/2,3/2) is a critical point of f","code":"x,y=symbols('x y'); f=x**3-3*x*y**2+y**4; result = (diff(f,x).subs({x:Rational(3,2),y:Rational(3,2)})==0) and (diff(f,y).subs({x:Rational(3,2),y:Rational(3,2)})==0)"},
{"claim":"Directional derivative of e^x sin y at (0,pi/2) along (3,4) equals 3/5","code":"x,y=symbols('x y'); g=exp(x)*sin(y); gx=diff(g,x).subs({x:0,y:pi/2}); gy=diff(g,y).subs({x:0,y:pi/2}); dv=gx*Rational(3,5)+gy*Rational(4,5); result = simplify(dv-Rational(3,5))==0"},
{"claim":"Max of xy on x^2+2y^2=6 is 3/sqrt(2)","code":"val = sqrt(3)*sqrt(Rational(3,2)); result = simplify(val - 3/sqrt(2))==0"},
{"claim":"softplus second-order Taylor coeffs are ln2, 1/2, 1/8","code":"x=symbols('x'); h=log(1+exp(x)); s=series(h,x,0,3).removeO(); result = (s.coeff(x,0)==log(2)) and (s.coeff(x,1)==Rational(1,2)) and (s.coeff(x,2)==Rational(1,8))"},
{"claim":"softplus second derivative positive at x=0","code":"x=symbols('x'); h=log(1+exp(x)); result = diff(h,x,2).subs(x,0) > 0"}
]