Taylor Series and Local Approximation
Replace a complicated function near one point with a simple polynomial that matches it there — the trick behind every optimisation step you have ever taken.
Why Does This Exist?
Gradient descent takes a step in the direction of the negative gradient. Why should that work? The loss surface is not a straight line, and the gradient only describes one point on it.
Taylor's answer: near any point, a curved function behaves like a straight one. The gradient step is the minimiser of the first-order Taylor approximation, restricted to a small neighbourhood. That is the entire justification, and it also explains the failure mode — take too large a step and you have left the region where the approximation holds, which is exactly what a too-high learning rate does.
Keep one more term and you get Newton's method, which uses curvature and converges dramatically faster. Understanding why nobody uses it on a 7-billion-parameter model, and what Adam approximates instead, both start here. This is the missing rung between derivatives and curvature.
Think of It Like This
Describing a hill to someone by radio
You are standing on a hillside describing the terrain to someone who cannot see it.
The cheapest useful sentence is "it slopes down to the east at about one in five." They can now predict the ground a few metres away quite well. Further out they will be wrong, because you told them about a slope and the hill is curved.
Add a second sentence: "and it is getting steeper as you go." Now they can predict much further, because you have given them the rate at which the slope itself changes. Their mental picture bends the right way.
Keep going — "and the steepening eases off" — and the description gets more accurate over a wider range, at the cost of more to say.
That progression is a Taylor series. Each extra term buys accuracy further from where you are standing. And the crucial point is that the first sentence is enough if you only intend to take a small step, which is why one derivative is usually all training needs.
How It Actually Works
The Taylor series of around a point is:
In plain words: the value at , plus the slope times how far you moved, plus a curvature correction, plus progressively finer corrections. Each term uses one more derivative at the single point — so the whole infinite series is built from local information.
Truncating gives approximations of increasing quality. Writing for the step:
- Zeroth order: . Error grows like .
- First order: . This is the tangent line, and its error grows like .
- Second order: adds . Error like .
The pattern matters more than the formulas: halving the step size cuts a first-order error by four and a second-order error by eight. Small steps make crude approximations excellent, which is the whole reason a learning rate exists.
The multivariable form is where ML lives
With a parameter vector and a step :
Three terms, and each is a familiar object. is your current loss. is the gradient. is the Hessian, holding the curvature.
Every optimiser is a choice about which terms to keep.
Keep only the first two and the approximation is linear, so it has no minimum — it decreases forever in the direction . You must therefore limit the step size, and that limit is the learning rate:
Gradient descent is the minimiser of the first-order model inside a small trust region. The learning rate is the trust region.
Keep the curvature term and the quadratic model has a genuine minimum. Differentiating with respect to and setting to zero gives , so:
That is Newton's method. No learning rate is needed — the curvature sets the step length automatically, taking long steps in flat directions and short ones in steep directions. It converges quadratically near a minimum, meaning the number of correct digits roughly doubles each iteration.
Why nobody uses Newton's method on a large model
Three reasons, and they compound:
- Memory. is . At 7 billion parameters that is entries.
- Cost. Inverting it, or solving the linear system, is .
- Correctness. Newton's step is only a descent direction when is positive definite. At a saddle — which dominates high-dimensional landscapes — it can step confidently uphill.
So practical optimisers approximate the curvature cheaply. Adam and RMSProp keep a per-parameter second-moment estimate, which acts as a diagonal approximation to — one number per parameter instead of . L-BFGS keeps a low-rank approximation from recent gradients. Both are Taylor's second term, made affordable.
Worked example
Expand around . Every derivative of is , and , so all coefficients are 1:
Evaluate at , where the true value is :
- Order 0: — error
- Order 1: — error
- Order 2: — error
- Order 3: — error
Each term cuts the error by roughly a factor of six. That is the diagram: the tangent line drifts off almost immediately while the quadratic tracks the curve much further.
Now watch the step size do its work. At the true value is , and the first-order estimate is — an error of , about 29 times smaller than at . The step shrank by 5 and the first-order error shrank by roughly , as the rule predicts.
That is the quantitative version of "small learning rates are safer": the crude linear model is genuinely accurate when the step is small, and genuinely wrong when it is not.
Show Me the Code
import math
def taylor_exp(x: float, order: int) -> float: # Every derivative of e^x at 0 equals 1, so the coefficients are 1/k!. return sum(x**k / math.factorial(k) for k in range(order + 1))
true = math.exp(0.5)print(round(true, 5)) # -> 1.64872for order in range(4): est = taylor_exp(0.5, order) print(order, round(est, 5), round(abs(true - est), 5))# -> 0 1.0 0.64872 | 1 1.5 0.14872 | 2 1.625 0.02372 | 3 1.64583 0.00289
# Halving the step should quarter the first-order error (it grows like h^2).for h in (0.5, 0.25, 0.125): err = abs(math.exp(h) - taylor_exp(h, 1)) print(h, round(err, 6)) # -> 0.148721, 0.034025, 0.008130The errors match the hand calculation. The last block is the law: 0.1487 → 0.0340 → 0.0081, each roughly a quarter of the last, which is why step size controls approximation quality so directly.
Watch Out For
Assuming the local model holds over a large step
The Taylor approximation is only valid near the expansion point, and "near" depends on how curved the function is — a quantity you generally do not know.
This is the real content of a learning rate being too high. Your optimiser computed a descent direction from a linear model of the loss, then walked far enough that the model no longer described the terrain. The loss goes up, and repeated overshooting produces the oscillating or diverging loss curve everyone recognises. The gradient was correct; the extrapolation was not.
Adaptive methods are attempts to infer the safe step size. Line search evaluates the loss at candidate step lengths and backtracks until it actually decreases — reliable but expensive per step, since each trial is a forward pass. Trust-region methods maintain an explicit radius and shrink it when a step underperforms its prediction. Learning-rate warmup does something similar for a different reason: early in training the curvature is large and poorly estimated, so small steps are safer until the estimates settle.
The diagnostic worth internalising: if the loss rises from the very first step and lowering the learning rate makes it rise more slowly rather than falling, suspect a sign error instead. A too-large step diverges; a wrong sign climbs steadily.
Adding a curvature term without checking it is positive
Newton's step minimises the quadratic model — and only minimises it when is positive definite. At a saddle point, where the Hessian has both positive and negative eigenvalues, the quadratic model has no minimum at all, and the Newton step can point uphill with complete confidence.
This is not an edge case in deep learning. Saddles vastly outnumber local minima in high dimensions, because being a minimum requires every one of millions of eigenvalues to be positive. So a naive second-order method spends much of its time at points where its own model is invalid.
The standard repairs all amount to forcing positive definiteness. Damping solves , shifting every eigenvalue up by — the same trick as ridge regression, and it smoothly interpolates between Newton at and gradient descent at large . Trust-region Newton limits the step so the model stays trustworthy. And saddle-free Newton uses the absolute values of the eigenvalues, so negative-curvature directions become descent directions instead of ascent ones.
Adam sidesteps the issue by using squared gradients rather than true second derivatives — always positive by construction, so it cannot produce an ascent direction this way. That is a real advantage of a crude approximation over a precise one.
The Quick Version
- Taylor expands a function near a point into a polynomial built from its derivatives at that point.
- Truncating at first order gives the tangent line, with error growing like ; second order gives error like .
- Halving the step quarters the first-order error. That is why small steps make crude models accurate.
- Multivariable form: .
- Gradient descent minimises the first-order model inside a trust region — and the learning rate is that trust region.
- Keeping the curvature term gives Newton's method, , which needs no learning rate and converges quadratically.
- Newton is impractical at scale: memory, solve, and it is only a descent direction when is positive definite.
- Adam and RMSProp are diagonal curvature approximations; L-BFGS is a low-rank one.
- A too-large step means you left the region where your model was valid. Loss rising from step one is more likely a sign error.
- Never trust a Newton step at a saddle. Damping, trust regions, or saddle-free variants fix it.
What to Read Next
- Jacobian and Hessian is the curvature object the second-order term needs.
- Derivatives and Partial Derivatives supplies every coefficient in the series.
- Gradients is the first-order term, and the direction the step follows.
- Convexity and Loss Landscapes is why the saddle problem in the second pitfall dominates.
- Positive Definite Matrices is the condition Newton's method quietly assumes.
- Definitions worth a look: Derivative, Hessian Matrix, Stationary Point, and Convex Function.
- Related interview question: What is a gradient, and why does training subtract it?