Skip to content
AI.info

Mathematical foundations

Taylor Expansions, Remainders, and Curvature

Use first- and second-order Taylor expansions to reason about local change, curvature, approximation error, and trust regions in machine learning.

By the end you can

Example

A local approximation to the logistic function

Near zero, the logistic function can be approximated without evaluating the full exponential expression.

  • Reference point: σ(0) = 0.5.
  • First derivative: σ′(0) = 0.25, so the local line is 0.5 + 0.25x.
  • Use: For x = 0.1, the approximation predicts 0.525, close to the exact value.
  • Failure: For large |x|, the linear model can leave the interval [0,1].
  • Lesson: Local accuracy does not imply global validity or preserved constraints.

Taylor expansion turns local derivatives into a model

A derivative describes the first-order effect of a small change. Taylor expansion organizes higher-order effects and states how the approximation error behaves near a reference point. For a scalar function of one variable, the first-order model is a tangent line. Adding the second derivative produces a local parabola that can represent curvature. In several dimensions, the gradient supplies the linear term and the Hessian supplies the quadratic term. This is the mathematical bridge from calculus to local optimization.

The name is younger than the mathematics, and by a checkable margin. Brook Taylor stated the theorem that carries his name in Methodus Incrementorum Directa & Inversa, published in 1715. James Gregory had written to John Collins on 15 February 1671 — forty-four years earlier. That letter carries power series, each of five or six terms, for seven functions: arctan x, tan x, sec x, log sec x, log tan(x/2 + π/4), arcsec(√2 e^x) and 2 arctan(tanh(x/2)). J J O'Connor and E F Robertson, who wrote the MacTutor biography of Gregory, state it without hedging: “In February 1671 he discovered Taylor series (not published by Taylor until 1715), and the theorem is contained in a letter sent to Collins on 15 February 1671.” The same biography records that “he discovered Taylor series more than 40 years before Taylor”, and the archive's transcription page for the Gregory–Collins correspondence notes that the letter “contains six examples of functions expanded using Taylor series many years before Brook Taylor was born”.

One distinction survives all of that, and it is the one that matters for everything below. Gregory possessed a method for finding the Taylor expansion of any particular function. What the surviving material does not establish is that he had Taylor's general formula for an unspecified function. That is Dehn and Hellinger's conclusion. Expanding the function in front of you is one act; owning a statement that covers functions you have not seen is another. A truncated expansion is always the first kind of object. The rest of this lesson is about not treating it as the second.

A Taylor approximation is useful only inside a neighborhood where its remainder is controlled.

The remainder is part of the claim

Writing “approximately equal” without a remainder condition hides the radius of trust. Taylor's theorem relates the error to higher derivatives and the distance from the expansion point. A smoothness assumption converts that relation into an inequality you can compute with.

Here is the worked case. Assume the Hessian is Lipschitz continuous with constant L. Then for every step s, f(x_k+s) <= f(x_k) + s'g(x_k) + (1/2)s'H(x_k)s + (L/6)||s||^3. The first three terms are the ordinary second-order Taylor model. The fourth is the remainder — bounded, not dropped. The inequality holds for all s rather than only for small s, so the whole expression is an upper bound on the function everywhere, and a step that decreases the model cannot increase f. Nesterov and Polyak published this cubic regularization of Newton's method in 2006. A 2017 paper building a stochastic version describes the mechanism in one line: “In each iteration, it first forms a local upper bound on the function using a third-order Taylor expansion around the current iterate”.

The payoff is a number, not a sentiment. Minimising the cubic upper model drives the gradient norm below eps in at most O(eps^-3/2) iterations. Steepest-descent-like methods carry an O(eps^-2) bound. Cartis and two co-authors, working on adaptive cubic regularisation, state the same overestimation property under a globally Lipschitz Hessian and the iteration count that follows from it. Tripuraneni and co-authors give the same count independently: “The work of Nesterov and Polyak [2006] first proposed the cubic-regularized Newton method, which requires O(eps^-1.5) gradient and Hessian oracle calls to find an eps-second-order stationary point”.

That gap is what remainder control buys. The habit of bounding the error is not bookkeeping added after the derivation; it is the thing that changes the convergence rate. Optimization line searches and trust-region methods rely on exactly this ability to tell a local model apart from the true objective.

Analogy

A local terrain map records slope and curvature at one point

On a hillside, a map records the current slope and nearby curvature. A first-order map tells you which way the ground descends; a second-order map predicts whether the descent steepens or flattens. The map is reliable only near the survey point. A valley, cliff, or ridge beyond that region may invalidate the extrapolation.

High-dimensional curvature runs in many directions at once and mixes them, which no paper map could draw. It has been measured anyway, and it turns out to have a countable structure. The Hessian spectrum of a trained deep classifier is a main bulk, then a mini-bulk of C(C-1) outliers, then C-1 secondary outliers, then a single isolated outlier larger still. That is roughly C large outliers in total, where C is the number of classes — so about ten on CIFAR-10. Vardan Papyan set the pattern out in 2020, and credits the count to earlier work: “Crucially, Sagun et al. (2016, 2017) observed that the number of outliers in the spectrum of the Hessian is often equal to the number of classes C.”

An independent group saw the same shape at ImageNet scale in 2019: a bulk holding over 99.99% of the eigenvalues close to zero, and “we observe the rapid appearance of large isolated eigenvalues in the spectrum, along with a surprising concentration of the gradient in the corresponding eigenspaces”. Ghorbani and colleagues also report that the picture is highly dependent on batch normalisation, which “pushes these outliers back into the bulk”. The terrain you survey depends on how the network was built, not only on where you stood.

So the landscape is nearly flat in almost every direction and steep in about as many directions as the problem has classes. That does not extend the map's range. It tells you which few directions the range is short in. The trust-region idea survives the move to many dimensions anyway.

The farther you step, the more evidence you need that the local model still applies.

Key idea

A Hessian describes local curvature, not the whole landscape

A positive-definite Hessian at a stationary point gives evidence for a strict local minimum, but it does not prove that the point is globally optimal in a nonconvex problem. A Hessian can also change rapidly: a direction that curves upward at one point may behave differently after a large step. Two published results show how little actually travels with a curvature measurement.

First, curvature at the end of training varies enormously with how you got there. Keskar and four co-authors measured, in 2017, the curvature at the minimisers reached by small batches of 256 points and by large batches of 10% of the training set, across six networks. On network F2, their full-space sharpness metric at eps=1e-3 came out at 1.39 ± 0.02 after small-batch training and 310.64 ± 38.46 after large-batch training. They report that “Both tables show a 1-2 order-of-magnitude difference between the values of our metric for the SB and LB regimes”. Testing accuracy fell from 63.08% to 57.81% on C4, and they note that “In our experiments, we have found the drop in generalization (also called generalization gap) to be as high as 5% even for smaller networks”.

Second, the number is not even a property of the function. The symmetries of a ReLU network let you reparameterise a model into an equivalent one — the same function, the same predictions — that is arbitrarily sharper. Dinh and three co-authors showed that in 2017. Their abstract: “This paper argues that most notions of flatness are problematic for deep models and can not be directly applied to explain generalization.” A Hessian is a statement about a point in a coordinate system. Always connect second-order conclusions to the location, the neighborhood, the regularity assumptions, and the parameterisation you happen to be using.

Curvature is local unless convexity supplies a global argument.

Visual

Three layers of local approximation

Each added derivative captures another kind of local behavior: the value at the point, the slope through it, the bending around it, and then everything the truncation left out. The fourth layer is not decorative. Under a Lipschitz Hessian with constant L it is exactly the (L/6)||s||^3 term that Nesterov and Polyak add to turn the quadratic model into an upper bound on the function. That is the difference between a picture of the neighborhood and a guarantee about it.

FigureLayers · 4 layers
  1. 01

    Zeroth order

    Use only the current function value f(x₀).

  2. 02

    First order

    Add the gradient term to model local slope.

  3. 03

    Second order

    Add the Hessian quadratic term to model curvature.

  4. 04

    Remainder

    Account for everything the truncated expansion omits.

Steps

Use a Taylor model responsibly

Apply these checks when a derivation replaces a nonlinear function with a local approximation: name the expansion point, choose the lowest order that answers the question, check that the required derivatives exist in a relevant neighborhood, bound the remainder, confirm the approximation does not leave the valid domain, and build a new model once the iterate has left the trusted region.

Two of those steps have a measured quantity behind them. The largest Hessian eigenvalue does not stay where it starts. Under full-batch gradient descent on neural networks it rises until it sits just above the value at which a quadratic Taylor model of the loss stops being a contraction for the chosen step size, and then it stays there. Cohen and four co-authors tracked it and reported that in 2021. Their abstract reads: “In this regime, the maximum eigenvalue of the training loss Hessian hovers just above the numerical value 2 / (step size), and the training loss behaves non-monotonically over short timescales, yet consistently decreases over long timescales.” Arora and two co-authors, a separate group, report the same stabilisation in 2022: “Sharpness stabilizes around 2/LR and loss goes up and down across iterations, yet still with an overall downward trend”.

That converts two pieces of advice into two things to compute. Bounding the remainder has a target to compare against — the top eigenvalue against 2/(step size) — rather than a vague instruction to be careful. Re-evaluating after moving has a reason too. In these runs the curvature is actively drifting toward the boundary of what the step size tolerates, so the bound you established at the old iterate is not the bound at the new one. A loss that rises for a few iterations and falls over many is not automatically a defect. It is what training at that threshold looks like.

FigureProcess · 6 steps
  1. 1. Name the expansion point

    State exactly where derivatives are evaluated.

  2. 2. Choose the order

    Use the lowest order that answers the question.

  3. 3. Check differentiability

    Verify the required derivatives exist in a relevant neighborhood.

  4. 4. Bound the remainder

    Use smoothness, higher derivatives, or empirical trust checks.

  5. 5. Respect constraints

    Confirm that the approximation does not leave the valid domain.

  6. 6. Re-evaluate after moving

    Build a new local model when the iterate leaves the trusted region.

Comparison

First-order and second-order reasoning

The two approximations offer different information at different computational costs. A first-order model uses the function value and the gradient. It captures local direction, is cheap in high dimensions, and supports gradient methods, but on its own it cannot distinguish a flat minimum from a saddle. A second-order model adds the Hessian: it predicts local bending and supports Newton-like steps, at the price of solving a linear system, and it can mislead far from the reference point. A finite-difference fit estimates local behavior from evaluations. That is useful for derivative checks, but it is sensitive to step size and noise, blind to exact symbolic structure, and expensive in many dimensions.

The first-order limitation is the one with measurements behind it. A Newton-based search can locate the critical points of MNIST and CIFAR-10 networks, and at each one you can measure the index — the fraction of the Hessian's eigenvalues that are negative. Dauphin and five co-authors did exactly that in 2014. The index rose tightly and monotonically with the training error at that point. The MNIST critical points are reported at 0.32%, 23.49% and 28.23% training error, with indices spanning roughly 0 to 0.25. Their conclusion states that the experiments “confirmed the main qualitative prediction of theory that the index of a critical point tightly and positively correlates with its error level”. Read backwards, that is a diagnosis. A point where the gradient has vanished and the error is still high has negative curvature in a quarter of its directions, and the gradient by itself reports none of it.

The abstract states the general case: “Here we argue, based on results from statistical physics, random matrix theory, neural network theory, and empirical evidence, that a deeper and more profound difficulty originates from the proliferation of saddle points, not local minima, especially in high dimensional problems of practical interest.” Pennington and Bahri later derived the same relation from random matrix theory: “Our analysis predicts and numerical simulations support that for critical points of small index, the number of negative eigenvalues scales like the 3/2 power of the energy”. The second-order term is what tells the two situations apart, and its cost is the price of the distinction.

FigureComparison · 3 columns

First order

Uses function value and gradient.

  • Captures local direction
  • Cheap in high dimensions
  • Cannot distinguish flat minimum from saddle alone
  • Supports gradient methods

Second order

Adds Hessian curvature.

  • Predicts local bending
  • Supports Newton-like steps
  • Requires solving a linear system
  • Can be misleading far from the reference point

Finite difference fit

Estimates local behavior from evaluations.

  • Useful for derivative checks
  • Sensitive to step size and noise
  • Does not expose exact symbolic structure
  • May be expensive in many dimensions

Key takeaways