Calculus and optimisation interview questions
15 questions interviewers ask on calculus and optimisation, from first principles to the follow-ups. The first 3 model answers are free to read; Pro opens the rest.
- What is a derivative, in one sentence, and how would you compute one numerically?
The rate at which a function's output changes per unit change in its input at a point: the slope of the tangent, the limit of
Δy/Δx. Numerically, a central difference(f(x + h) − f(x − h))/(2h)withharound10⁻⁶; forx³at 2 it gives12. - Why not make the finite-difference step as small as possible?
Because of floating point. The formula's error shrinks with
h, butf(x + h)andf(x)agree in most of their sixteen significant digits, so the difference keeps few correct ones, and dividing byhmagnifies the rounding, roughlyε/h. For a forward difference ofx²at 1, the best step is10⁻⁸and at10⁻¹⁶the estimate is exactly0. - State the chain rule and use it on the sigmoid.
d/dx f(g(x)) = f′(g(x)) · g′(x). Forσ(z) = 1/(1 + e⁻ᶻ)it givese⁻ᶻ/(1 + e⁻ᶻ)² = σ(1 − σ), at most0.25, atz = 0, and small in both tails:0.0177atz = 4. - You set the derivative to zero and found a point. What else do you need to check?
- Which single number minimises squared error, and which minimises absolute error?
- What is the gradient, and why does gradient descent step against it?
- What are the gradients of
aᵀx,xᵀxandxᵀAx? - How do you choose a learning rate for gradient descent on a quadratic loss?
- What is Newton's method, and why is it not used to train neural networks?
- What does the AUC measure?
- Why does convexity matter, and is logistic regression's loss convex?
- What is a saddle point, and why do they matter in deep learning?
- Explain backpropagation.
- Derive the gradient of logistic regression's log loss.
- What does a Lagrange multiplier mean, and how does it relate to ridge and lasso?