core practice · coding problem
Compute a 2D gradient
f(x, y) = x² + 3xy + y². Compute ∇f at (1, 2). In which direction should you step to decrease f fastest, and what is the directional derivative in that direction?
The mechanism
The gradient points uphill steepest. To minimize a loss, walk opposite the gradient. Each partial derivative tells you how sensitive the output is to one input — the chain rule chains these sensitivities through composed functions.
Expected evidence
∇f = [2x+3y, 3x+2y] → [8, 7] at (1,2). Steepest descent: −∇f/||∇f||. Directional derivative along −∇f/||∇f|| is −||∇f|| = −√113.
Try this drill in the practice workspace →
Hints when you need them
- Partial w.r.t. x treats y as constant.
- Steepest descent is opposite the gradient.
Watch for these mistakes
- Confusing gradient with the function value
- Forgetting to zero-center data before interpreting partials
- Using a fixed step size on a badly scaled surface