# ✅ Checkpoint: first-order derivatives

By Better Wise



## Quiz

1. For f(x, y) = x^2 y + 3y^2, which vector is ∇f(1, 2)?
   - (4, 13)
   - (2, 6)
   - (13, 4)
   - (4, 7)
2. What is the shape of the Jacobian of F: R^n to R^m, and what does row i contain?
   - m x n, and row i is the transposed gradient of output f_i
   - m x m, and row i is the gradient of output f_i
   - m x n, and row i is the gradient of input x_i
   - n x m, and row i is the gradient of input i
3. For f = g ∘ h with h: R^n to R^m and g: R^m to R^k, which expression is the Jacobian J_f(x)?
   - J_g(h(x)) J_h(x)
   - J_h(h(x)) J_g(x)
   - J_g(x) J_h(x)
   - J_h(x) J_g(h(x))
4. Which statements about the gradient ∇f(x) of a scalar function f: R^n to R are correct? Select all that apply.
   - Its norm equals the slope of f along the gradient direction.
   - It has the same shape as x, with one entry per input coordinate.
   - It points in the direction of steepest increase of f at x.
   - A zero gradient at a point proves the point is a local minimum.
   - It is orthogonal to the level set of f through x.
5. Which statements about the chain rule for composed functions are correct? Select all that apply.
   - The shape test (k x m)(m x n) = k x n catches reversed products.
   - The outer Jacobian J_g is evaluated at the input x.
   - For a scalar-valued composition, ∇f(x) = J_h(x)^T ∇g(h(x)).
   - An elementwise map t = φ(a) has a diagonal Jacobian diag(φ'(a_i)).
   - The affine map a = Wx + b has Jacobian W, independent of x.
6. The central-difference estimate of one gradient component is (f(x + h e_i) - f(x - h e_i)) / (2h), and its truncation error is of order ____.
7. For F: R^n to R^m, the Jacobian J_F has shape ____ (write it as m x n with your numbers).
8. For f = g ∘ h with g scalar-valued, the gradient is ∇f(x) = J_h(x)^T ____.
9. Derive by hand the gradient of f(x, y) = (x - 2)^2 + 3(y + 1)^2 + xy, then verify each component with a central difference in Python at the point (1, -1). Describe your derivation, your numeric check, and the relative error you observed.
10. Take h(x1, x2) = (x1 x2, x1 + x2^2) and g(y1, y2) = y1 y2, so f = g ∘ h. Build the Jacobian product by hand, then confirm the resulting gradient numerically. Explain each step of the chain and how you checked it.


---

## Contents

Part of [🧮 Mathematics for Machine Learning 2: Calculus and Optimization for Training Models](https://everwise.study/courses/mathematics-for-machine-learning-2-calculus-and-optimization-for-training.md)

- **📐 First-order derivatives: gradients, Jacobians and the chain rule**
  - [📐 From partial derivatives to the gradient vector](https://everwise.study/courses/mathematics-for-machine-learning-2-calculus-and-optimization-for-training/partial-derivatives-to-gradient-vector.md)
  - [🧮 Jacobians of vector-valued functions](https://everwise.study/courses/mathematics-for-machine-learning-2-calculus-and-optimization-for-training/jacobian-vector-valued-functions.md) (sign-in required)
  - [🔗 Chain rule for composed functions](https://everwise.study/courses/mathematics-for-machine-learning-2-calculus-and-optimization-for-training/chain-rule-composed-functions.md)
  - [✅ Checkpoint: first-order derivatives](https://everwise.study/courses/mathematics-for-machine-learning-2-calculus-and-optimization-for-training/checkpoint-first-order-derivatives.md) — this lesson
- **📉 Second-order behavior and convexity**
  - [🌀 Hessians and second-order behavior](https://everwise.study/courses/mathematics-for-machine-learning-2-calculus-and-optimization-for-training/hessians-second-order-behavior.md)
  - [📈 Taylor expansions, convexity and local minima](https://everwise.study/courses/mathematics-for-machine-learning-2-calculus-and-optimization-for-training/taylor-expansions-convexity-local-minima.md)
  - [✅ Checkpoint: curvature and convexity](https://everwise.study/courses/mathematics-for-machine-learning-2-calculus-and-optimization-for-training/checkpoint-curvature-and-convexity.md)
- **⛰️ Constrained optimization and gradient descent**
  - [⚖️ Lagrange multipliers for constrained problems](https://everwise.study/courses/mathematics-for-machine-learning-2-calculus-and-optimization-for-training/lagrange-multipliers-constrained-problems.md)
  - [🔽 Gradient descent and learning rate behavior](https://everwise.study/courses/mathematics-for-machine-learning-2-calculus-and-optimization-for-training/gradient-descent-learning-rate-behavior.md) (premium content)
  - [✅ Checkpoint: constrained optimization and descent](https://everwise.study/courses/mathematics-for-machine-learning-2-calculus-and-optimization-for-training/checkpoint-constrained-optimization-descent.md) (premium content)
- [Course cheatsheet](https://everwise.study/courses/mathematics-for-machine-learning-2-calculus-and-optimization-for-training/cheatsheet.md) (premium content)
