Taylor approximation

Step 11 of 18 in Foundations · Theorem · Medium

Near a point, any smooth function looks like a polynomial: value + slope·Δ + curvature·Δ²/2. Gradient descent trusts the first-order term; Newton's method uses the second.

The lesson

Close to a point, a smooth function behaves like a polynomial: f(x + Δ) ≈ f(x) + f′(x)·Δ + ½·f″(x)·Δ². The first two terms are the tangent line. The third adds curvature. More terms hold over a wider range, but the fit is always best near the point you expanded around.

Worked example: sin x ≈ x − x³/6 around 0
  1. At x = 0.5: order 1 gives 0.5; order 3 gives 0.5 − 0.0208 = 0.4792. The true value is 0.4794.
  2. At x = 3: order 3 gives 3 − 4.5 = −1.5. The true value is 0.141.
  3. Near 0 it is excellent. Far from 0 it is useless.

Gradient descent rests on the first-order version: a step of −η∇f should lower f by about η|∇f|². That only holds while the step is small enough for the tangent to still describe the function. Step too far and the curvature you ignored takes over, which is why a large learning rate diverges. Newton's method uses the second-order term to choose its step.

Common mistake. A Taylor approximation is local. Trusting it far from the expansion point is the same mistake as extrapolating a trend line years past the data.

Check yourself

  1. Using eˣ ≈ 1 + x + x²/2, estimate e^0.2.

    Show the answer

    1.22. 1 + 0.2 + 0.04/2 = 1.22. The true value is 1.2214.

  2. A learning rate that is too large makes gradient descent fail because:

    • the gradient is computed wrongly
    • the first-order approximation only holds near the current point
    • Taylor series need more data
    Show the answer

    the first-order approximation only holds near the current point. The gradient is right, but it describes the function only nearby. A long step lands where the tangent no longer matches, and the loss can go up.

  3. f(2) = 5 and f′(2) = 3. What is the first-order estimate of f(2.1)?

    Show the answer

    5.3. f(2) + f′(2)·0.1 = 5 + 0.3 = 5.3.

Build it

  1. Approximate sin

    Plot sin x with its Taylor polynomials of order 1, 3, 5 around 0 on [−π, π].

    Done when: You can show where each approximation breaks down.

Resources

Earn this star

On the map, your answers are marked and you log what you built. Finish the step and its star lights.

Open this step on the map