Math & Statistics

Taylor Expansions in Optimization

Approximating complex non-linear loss functions using local polynomial expansions around current parameter weights.

🔴 advanced5 min readcalculusoptimization
Taylor Series Expansion approximates smooth non-linear functions around a local expansion point x_0 using polynomial series of derivatives. First-order Taylor expansion f(x) ≈ f(x_0) + ∇f(x_0)^T (x - x_0) forms the local linear approximation underpinning Gradient Descent. Second-order Taylor expansion f(x) ≈ f(x_0) + ∇f(x_0)^T Δx + (1/2) Δx^T H Δx incorporates curvature (Hessian matrix H), deriving Newton's Method and natural gradient optimizers.

What is a Taylor Series?

A Taylor Series approximates any smooth non-linear function near point $x_0$ using a sum of polynomial terms constructed from derivatives:

$$f(x_0 + \Delta x) = f(x_0) + f'(x_0) \Delta x + \frac{1}{2!} f''(x_0) \Delta x^2 + \frac{1}{3!} f'''(x_0) \Delta x^3 + \dots$$

   Non-linear Loss Function f(x) vs Taylor Approximations
   Loss
    High ┤            /  Actual Non-linear Loss f(x)
         │           /  / 2nd-order Quadratic Approx (Parabola)
         │          /  / /
         │         /  / /  1st-order Linear Approx (Tangent Line)
         │        /  / /  /
     Low ┴───────(  *  )─────────────────► Parameter x
                 x_0 (Expansion Point)

First-Order Approximation (Gradient Descent)

Truncating the series after the first derivative term:

$$f(x_0 + \Delta x) \approx f(x_0) + \nabla f(x_0)^T \Delta x$$

To make loss $f(x_0 + \Delta x) < f(x_0)$, choose displacement $\Delta x = -\alpha \nabla f(x_0)$:

$$f(x_0 - \alpha \nabla f) \approx f(x_0) - \alpha |\nabla f(x_0)|^2 < f(x_0) \quad (\alpha > 0)$$

This proves mathematically why moving in the opposite direction of the gradient guarantees local loss reduction!

Second-Order Approximation (Newton's Method)

Including the second derivative (Hessian matrix $H$):

$$f(x_0 + \Delta x) \approx f(x_0) + \nabla f(x_0)^T \Delta x + \frac{1}{2} \Delta x^T H(x_0) \Delta x$$

To find the step $\Delta x$ that minimizes this quadratic approximation, set derivative wrt $\Delta x$ to 0:

$$\frac{\partial}{\partial \Delta x} \left[ f(x_0) + \nabla f(x_0)^T \Delta x + \frac{1}{2} \Delta x^T H(x_0) \Delta x \right] = \nabla f(x_0) + H(x_0) \Delta x = 0$$

$$\mathbf{\Delta x_{\text{Newton}} = -H(x_0)^{-1} \nabla f(x_0)}$$

Newton's Method uses curvature $H$ to jump directly to the minimum of the quadratic approximation in a single step!

Why Deep Learning Prefers 1st-Order

  1. 1st-Order (SGD / Adam): Requires $O(N)$ memory and compute per step.
  2. 2nd-Order (Newton): Requires storing $O(N^2)$ Hessian matrix and computing $O(N^3)$ inverse $H^{-1}$. For $N = 100\text{M}$ weights, $H^{-1}$ is computationally impossible.

Say this out loud

Taylor series expands complex functions locally using derivatives. 1st-order expansion f(x) ≈ f(x_0) + ∇f^T Δx proves why setting Δx = -α ∇f guarantees local loss reduction in Gradient Descent. 2nd-order expansion adds Hessian curvature (1/2) Δx^T H Δx, deriving Newton's method step Δx = -H^-1 ∇f for single-step quadratic minimization.

Follow-ups to expect

Check yourself

Question 1 of 3

What is the 2nd-order Taylor Series expansion formula for a scalar loss function f(x) around point x_0 with displacement Δx = x - x_0?

More in Math & Statistics

See all →
Bayes’ Theorem4 minCentral Limit Theorem4 minLaw of Large Numbers4 min