concept / taylor-expansion
Next task →
University/Calculus/Multivariable calculus/Taylor Expansion and Local Approximation
Calculus · Multivariable calculus · Local approximations

Taylor Expansion and Local Approximation

Taylor's theorem replaces a smooth function near a point by a polynomial whose derivatives match at that point, with a remainder that quantifies both the accuracy and the limits of the local model.

39 sectionsintermediate150 minhand-authored · structural 78/100
Take assessment →
Mastery requires: derivation reproduced, from-scratch implementation committed, failure case explained, and assessment score ≥ 80%. Current state: not_started.

1. Concept overview

A Taylor polynomial approximates a differentiable function near a point aa by matching its derivatives there. In one dimension,

f(x)=f(a)+f′(a)(x−a)+f′′(a)2(x−a)2+⋯+f(k)(a)k!(x−a)k⏟Tk(x)+Rk(x),f(x)=\underbrace{f(a)+f'(a)(x-a)+\frac{f''(a)}{2}(x-a)^2+\cdots+\frac{f^{(k)}(a)}{k!}(x-a)^k}_{T_k(x)}+R_k(x),

where the remainder Rk(x)R_k(x) vanishes faster than (x−a)k(x-a)^k as x→ax\to a. In multiple dimensions the linear term becomes ∇f(a)⊤(x−a)\nabla f(a)^\top(x-a) and the quadratic term becomes 12(x−a)⊤∇2f(a)(x−a)\tfrac12(x-a)^\top\nabla^2f(a)(x-a).

This is the workhorse of analysis: it turns a nonlinear function into a local polynomial whose error we can bound. Almost every convergence proof in optimization — including the descent lemma behind gradient descent and the quadratic model behind Newton's method — is Taylor's theorem with an explicit remainder.

2. Why this concept exists

Nonlinear functions are hard to reason about globally but simple locally. Taylor expansion buys us three things:

  1. Approximation with a guarantee: unlike a heuristic fit, the remainder has an explicit form, so we can certify accuracy on a neighborhood.
  2. Derivative-based algorithms: the first-order model yields the gradient step; the second-order model yields Newton's step; the descent lemma uses a quadratic upper bound to pick safe step sizes.
  3. Error propagation: if y=f(x)y=f(x) and xx is uncertain by δ\delta, Taylor gives Δy≈f′(x)δ\Delta y\approx f'(x)\delta — the basis of sensitivity analysis and the delta method in statistics.

Naive alternatives fail: linear interpolation needs two evaluations and gives no derivative information; global polynomial fitting oscillates (Runge's phenomenon); finite differences approximate derivatives but still need a local model to extrapolate. Taylor's theorem is the principled local model, with a rigorous price tag.

3. Historical background

Brook Taylor introduced the series in Methodus Incrementorum Directa et Inversa (1715), presenting it as a finite-difference interpolation result. Colin Maclaurin popularized the special case at a=0a=0 in his Treatise of Fluxions (1742). Euler used series extensively in the 1730s–40s, often formally without convergence proofs. The rigorous remainder came later: Lagrange (1797) gave the derivative form Rk=f(k+1)(ξ)(x−a)k+1/(k+1)!R_k=f^{(k+1)}(\xi)(x-a)^{k+1}/(k+1)!; Cauchy (1821) supplied the mean-value-theorem proof; Peano (1868) formulated the little-oo remainder; Greenhill and others extended to several variables in the late 19th century. The modern geometric picture — Taylor polynomials as jets on manifolds — belongs to 20th-century differential geometry.

4. Fundamental problem

Given a kk-times differentiable f:Rd→Rf:\mathbb R^d\to\mathbb R and a base point aa, find a polynomial TkT_k of degree at most kk that approximates ff near aa, and bound f(x)−Tk(x)f(x)-T_k(x) uniformly on a ball ∥x−a∥≤r\lVert x-a\rVert\le r.

Subtleties: how large can rr be before the error explodes? Does the infinite series converge to ff (analyticity), or only asymptotically? In multiple dimensions, which derivatives are needed — all dkd^k partials of order kk, or just directional ones? And how do we compute these derivatives efficiently when dd is large?

5. First-principles explanation

Fact 1 — the derivative is the best linear approximation. Differentiability at aa means

f(a+s)=f(a)+f′(a)s+o(s),f(a+s)=f(a)+f'(a)s+o(s),

so the tangent line matches both value and slope; the error is small relative to ss.

Fact 2 — match derivatives recursively. Seek Tk(x)=∑j=0kcj(x−a)jT_k(x)=\sum_{j=0}^k c_j(x-a)^j with Tk(j)(a)=f(j)(a)T_k^{(j)}(a)=f^{(j)}(a) for j=0,…,kj=0,\dots,k. Differentiating the ansatz gives Tk(j)(a)=j! cjT_k^{(j)}(a)=j!\,c_j, hence cj=f(j)(a)/j!c_j=f^{(j)}(a)/j!. The factorial is not a convention — it is forced by repeated differentiation.

Fact 3 — the remainder is a derivative at an intermediate point. Repeated integration by parts (or Cauchy's mean value theorem) shows

Rk(x)=f(k+1)(ξ)(k+1)!(x−a)k+1,ξ between a and x.R_k(x)=\frac{f^{(k+1)}(\xi)}{(k+1)!}(x-a)^{k+1},\qquad \xi\text{ between }a\text{ and }x .

All approximation error is governed by the (k+1)(k+1)-th derivative times the (k+1)(k+1)-th power of the step — the two knobs that determine accuracy.

6. Prerequisite concepts

You need: (1) limits, continuity and little-oo/big-OO notation; (2) first and higher derivatives, the chain and product rules; (3) partial derivatives, gradient and Hessian; (4) the mean value theorem and Cauchy's mean value theorem; (5) integration by parts; (6) factorials and the binomial theorem; (7) for the multivariable case, directional derivatives and the identity ddtf(a+tv)=∇f(a+tv)⊤v\frac{d}{dt}f(a+tv)=\nabla f(a+tv)^\top v. See the linked concepts.

7. Complete mathematical formulation

One dimension, Lagrange remainder. If f(k+1)f^{(k+1)} exists on the interval between aa and xx,

f(x)=∑j=0kf(j)(a)j!(x−a)j+f(k+1)(ξ)(k+1)!(x−a)k+1,ξ∈(a,x).f(x)=\sum_{j=0}^{k}\frac{f^{(j)}(a)}{j!}(x-a)^j+\frac{f^{(k+1)}(\xi)}{(k+1)!}(x-a)^{k+1},\qquad \xi\in(a,x).

Integral remainder. Rk(x)=1k!∫axf(k+1)(t)(x−t)k dtR_k(x)=\frac{1}{k!}\int_a^x f^{(k+1)}(t)(x-t)^k\,dt — useful when the derivative is merely integrable.

Peano form. f(x)=Tk(x)+O((x−a)k+1)f(x)=T_k(x)+O((x-a)^{k+1}) as x→ax\to a (requires only k+1k+1 derivatives existing at aa).

Multivariable. With s=x−as=x-a and g(t)=f(a+ts)g(t)=f(a+ts):

f(a+s)=f(a)+∇f(a)⊤s+12s⊤∇2f(a)s+16∑ijk∂ijkf(a+ξs)sisjsk.f(a+s)=f(a)+\nabla f(a)^\top s+\tfrac12 s^\top\nabla^2f(a)s+\tfrac1{6}\sum_{ijk}\partial_{ijk}f(a+\xi s)s_is_js_k .

Compact tensor notation: f(a+s)=∑j=0k1j!∇jf(a)[s,…,s]+Rkf(a+s)=\sum_{j=0}^k\frac{1}{j!}\nabla^j f(a)[s,\dots,s]+R_k.

Smoothness bound. If ∥∇2f∥2≤L\lVert\nabla^2f\rVert_2\le L everywhere (i.e. ff is LL-smooth),

∣f(a+s)−f(a)−∇f(a)⊤s∣≤L2∥s∥2.\bigl|f(a+s)-f(a)-\nabla f(a)^\top s\bigr|\le\tfrac L2\lVert s\rVert^2 .

Series convergence. The infinite series converges on a radius RR determined by lim sup⁡∣cj∣1/j\limsup |c_j|^{1/j}; within ∣x−a∣<R|x-a|<R convergence is absolute and uniform on compact subsets.

8. Notation dictionary

| Symbol | Meaning | Type | |---|---|---| | aa | expansion point (base) | scalar/vector | | x=a+sx=a+s | evaluation point and displacement | scalar/vector | | Tk(x)T_k(x) | Taylor polynomial of degree kk | polynomial | | Rk(x)R_k(x) | remainder after degree kk | function | | f(j)(a)f^{(j)}(a) | jj-th derivative at aa | scalar | | ∇f(a)\nabla f(a) | gradient vector | vector | | ∇2f(a)=H\nabla^2 f(a)=H | Hessian matrix | matrix | | ∇jf(a)\nabla^j f(a) | order-jj derivative tensor | tensor | | LL | Lipschitz constant of ∇f\nabla f; curvature bound | scalar | | o(⋅),O(⋅)o(\cdot),O(\cdot) | asymptotic notation | relation | | ξ\xi | intermediate point from the mean value theorem | scalar | | RR | radius of convergence | scalar | | kk | polynomial order | integer | | dd | number of variables | integer |

9. Step-by-step derivation

Step 1 — ansatz. Write Tk(a+s)=c0+c1s+⋯+ckskT_k(a+s)=c_0+c_1s+\cdots+c_ks^k and impose Tk(j)(a)=f(j)(a)T_k^{(j)}(a)=f^{(j)}(a).

Step 2 — solve for coefficients. Since djdsjsm∣s=0=j! δmj\frac{d^j}{ds^j}s^m\big|_{s=0}=j!\,\delta_{mj}, we get cj=f(j)(a)/j!c_j=f^{(j)}(a)/j!.

Step 3 — one-dimensional remainder. Define ϕ(t)=f(x)−f(t)−∑j=1kf(j)(t)j!(x−t)j\phi(t)=f(x)-f(t)-\sum_{j=1}^k\frac{f^{(j)}(t)}{j!}(x-t)^j. Then ϕ(x)=0\phi(x)=0, ϕ(a)=Rk(x)\phi(a)=R_k(x), and differentiating gives ϕ′(t)=−f(k+1)(t)k!(x−t)k\phi'(t)=-\frac{f^{(k+1)}(t)}{k!}(x-t)^k. Cauchy's mean value theorem applied to ϕ\phi and ψ(t)=(x−t)k+1\psi(t)=(x-t)^{k+1} yields ϕ(a)/ψ(a)=ϕ′(ξ)/ψ′(ξ)=f(k+1)(ξ)/(k+1)!\phi(a)/\psi(a)=\phi'(\xi)/\psi'(\xi)=f^{(k+1)}(\xi)/(k+1)!, hence Rk=f(k+1)(ξ)(x−a)k+1/(k+1)!R_k=f^{(k+1)}(\xi)(x-a)^{k+1}/(k+1)!.

Step 4 — multivariable reduction. Set g(t)=f(a+ts)g(t)=f(a+ts) for s∈Rds\in\mathbb R^d. Then g′(t)=∇f(a+ts)⊤sg'(t)=\nabla f(a+ts)^\top s, g′′(t)=s⊤∇2f(a+ts)sg''(t)=s^\top\nabla^2f(a+ts)s, and in general g(j)(t)=∇jf(a+ts)[s,…,s]g^{(j)}(t)=\nabla^jf(a+ts)[s,\dots,s]. Apply the 1D theorem at t=0t=0, t=1t=1.

Step 5 — the descent-lemma special case. With k=1k=1 and the spectral bound ∥∇2f∥2≤L\lVert\nabla^2f\rVert_2\le L, the Lagrange remainder gives ∣R1∣≤L2∥s∥2|R_1|\le\frac L2\lVert s\rVert^2, so

f(a+s)≤f(a)+∇f(a)⊤s+L2∥s∥2.f(a+s)\le f(a)+\nabla f(a)^\top s+\tfrac L2\lVert s\rVert^2 .

Substituting s=−η∇f(a)s=-\eta\nabla f(a) yields the descent inequality η(1−Lη2)∥∇f∥2\eta(1-\tfrac{L\eta}{2})\lVert\nabla f\rVert^2 decrease — the rigorous core of gradient descent.

10. Proofs and proof intuition

Theorem (Taylor with Lagrange remainder). If f∈Ck+1f\in C^{k+1} between aa and xx, then Rk=f(k+1)(ξ)(x−a)k+1/(k+1)!R_k=f^{(k+1)}(\xi)(x-a)^{k+1}/(k+1)! for some ξ\xi between them. Proof. As in Step 3, define ϕ(t)\phi(t) and ψ(t)=(x−t)k+1\psi(t)=(x-t)^{k+1}; both are continuous on [a,x][a,x] and differentiable on (a,x)(a,x) with ψ′(t)≠0\psi'(t)\neq0. Cauchy's MVT gives a ξ\xi with [ϕ(x)−ϕ(a)]ψ′(ξ)=[ψ(x)−ψ(a)]ϕ′(ξ)[\phi(x)-\phi(a)]\psi'(\xi)=[\psi(x)-\psi(a)]\phi'(\xi). Since ϕ(x)=ψ(x)=0\phi(x)=\psi(x)=0, −ϕ(a)(−(k+1)(x−ξ)k)=−(x−ξ)k+1⋅(−f(k+1)(ξ)k!(x−ξ)k)-\phi(a)(-(k+1)(x-\xi)^k)=-(x-\xi)^{k+1}\cdot\big(-\tfrac{f^{(k+1)}(\xi)}{k!}(x-\xi)^k\big), so ϕ(a)=f(k+1)(ξ)(x−a)k+1/(k+1)!\phi(a)=f^{(k+1)}(\xi)(x-a)^{k+1}/(k+1)!. □\square

Theorem (Peano remainder). If f(k)(a)f^{(k)}(a) exists, Rk=o((x−a)k)R_k=o((x-a)^k). Proof (induction). The case k=0k=0 is continuity. Assuming the result at k−1k-1 and applying l'Hôpital to Rk(x)/(x−a)kR_k(x)/(x-a)^k gives the limit 00 because the numerator's derivative is Rk−1R_{k-1} built from f′f', which is o((x−a)k−1)o((x-a)^{k-1}) by the induction hypothesis. □\square

Proposition (convergence of exe^x). For exe^x at a=0a=0, Rk=eξxk+1/(k+1)!R_k=e^{\xi}x^{k+1}/(k+1)! with ξ∈(0,x)\xi\in(0,x); for fixed xx, ∣Rk∣≤e∣x∣∣x∣k+1/(k+1)!→0|R_k|\le e^{|x|}|x|^{k+1}/(k+1)!\to0, so the series converges to exe^x for all xx.

Proof intuition. Taylor's theorem is the mean value theorem applied repeatedly. The factorial in the denominator is exactly what makes the remainder shrink for smooth functions; the radius of convergence is where the (k+1)(k+1)-th derivatives grow too fast for the factorial to tame.

11. Geometric interpretation

The first-order Taylor polynomial is the tangent line (or tangent plane in higher dimensions): it shares the function's value and slope at aa. The second-order polynomial is the osculating parabola — it also matches curvature, so it hugs the curve to second order. Each additional derivative matches a higher-order geometric feature (jerk, snap, ...).

Close to aa, a smooth curve is nearly straight — the essence of differentiability. The remainder tells us how fast the curve peels away from its tangent: proportional to curvature times squared distance. For an elongated quadratic bowl, the Hessian's eigenvalues give the curvature in each direction, explaining why a single gradient step overshoots in steep directions and crawls in flat ones.

12. Visual explanation

Use the interactive Taylor Lab: plot sin⁡x\sin x together with its approximations of degree 1, 3, 5, 7 on [−2π,2π][-2\pi,2\pi]; the higher-order curves hug the sine over a widening interval. Zoom near 0 and watch all curves coincide. A slider for the expansion point aa shows that any center works, but accuracy degrades away from it. A second panel shows the remainder bound ∣Rk∣≤M∣x−a∣k+1/(k+1)!|R_k|\le M|x-a|^{k+1}/(k+1)! as a shaded envelope. In 2D, plot a curved surface with its tangent plane and osculating quadratic, and overlay ellipses whose axes are the Hessian eigenvectors to visualize directional curvature.

13. Numerical worked example

Sine at 0.1. Using terms through x5x^5:

sin⁡(0.1)≈0.1−0.0016+10−5120=0.09983341667.\sin(0.1)\approx0.1-\frac{0.001}{6}+\frac{10^{-5}}{120}=0.09983341667 .

The true value is 0.099833416650.09983341665; error ≈2×10−11\approx2\times10^{-11}, consistent with the bound ≤∣0.1∣7/7!≈2×10−11\le|0.1|^7/7!\approx2\times10^{-11}.

Exponential at 0.1. 1+0.1+0.005+0.00016667+0.00000417=1.105170921+0.1+0.005+0.00016667+0.00000417=1.10517092 versus e0.1=1.105170918e^{0.1}=1.105170918; error ≈1.4×10−9\approx1.4\times10^{-9}.

Square root. 1+x≈1+x2−x28+x316−5x4128\sqrt{1+x}\approx1+\tfrac x2-\tfrac{x^2}{8}+\tfrac{x^3}{16}-\tfrac{5x^4}{128}; at x=0.1x=0.1 this gives 1.048808591.04880859 versus 1.048808851.04880885, error ≈2.6×10−7\approx2.6\times10^{-7}.

Multivariable. f(x,y)=exsin⁡yf(x,y)=e^x\sin y near (0,0)(0,0): ∇f=(exsin⁡y,excos⁡y)=(0,1)\nabla f=(e^x\sin y,e^x\cos y)=(0,1), Hessian at origin =(0110)=\begin{pmatrix}0&1\\1&0\end{pmatrix}, so f(x,y)≈y+xyf(x,y)\approx y+xy. At (0.1,0.2)(0.1,0.2): 0.2+0.02=0.220.2+0.02=0.22 versus e0.1sin⁡0.2≈0.21956e^{0.1}\sin 0.2\approx0.21956, error ≈4.4×10−4\approx4.4\times10^{-4}.

Optimization link. For f(x)=x4f(x)=x^4 at a=1a=1, the exact increment for s=0.1s=0.1 is 1.4641−1=0.46411.4641-1=0.4641; the first-order Taylor prediction is 4(0.1)=0.44(0.1)=0.4 (error 0.06410.0641), while adding 12f′′(1)s2=6(0.01)=0.06\tfrac12 f''(1)s^2=6(0.01)=0.06 gives 0.460.46 — error drops by an order of magnitude.

14. Real-world analogy

A surveyor measures a hill's height and slope at one point. Over a few meters a linear estimate suffices; over a kilometer the curvature matters. Zooming in on any smooth curve with a microscope makes it look straight — that is the first-order Taylor picture. Adding curvature (second derivative) is like fitting the local arc of a circle to the hill; more derivatives are finer adjustments to the fit. The microscope's field of view is the neighborhood where the approximation is valid; walk too far and you need a new expansion point.

15. Algorithm pseudocode

algorithm TaylorPolynomial(f, derivatives, a, k):
    # derivatives[j](a) returns the j-th derivative/tensor at a
    T <- 0
    for j = 0 .. k:
        T <- T + derivatives[j](a) / j! * (x - a)^j
    return T

algorithm TaylorRemainderBound(f, deriv_k_plus_1, a, x, radius):
    M <- sup ||deriv_k_plus_1(z)|| for z in ball(a, radius)
    return M * ||x - a||^(k+1) / (k+1)!

algorithm MultivariableQuadratic(f, grad_fn, hess_fn, a, s):
    g <- grad_fn(a);  H <- hess_fn(a)
    return f(a) + dot(g, s) + 0.5 * dot(s, H @ s)
# For L-smooth f: replace 0.5 H by 0.5 L I for a guaranteed upper bound

16. Implementation from scratch

import math
import numpy as np
import sympy as sp

def taylor_1d(f, derivs, a, x, k):
    """Sum f^(j)(a)/j! * (x-a)^j using provided derivative callables."""
    return sum(derivs[j](a) * (x-a)**j / math.factorial(j) for j in range(k+1))

def sin_taylor(x, a=0.0, k=7):
    # derivatives of sin cycle: sin, cos, -sin, -cos, ...
    vals = [math.sin, math.cos, lambda t:-math.sin(t),
            lambda t:-math.cos(t)]
    return sum(vals[j % 4](a) * (x-a)**j / math.factorial(j)
               for j in range(k+1))

def quadratic_model(f, grad, hess, a, s):
    a = np.asarray(a, float); s = np.asarray(s, float)
    return f(a) + grad(a) @ s + 0.5 * s @ hess(a) @ s

# Symbolic series and exact values
z = sp.symbols("z")
print(sp.series(sp.sin(z), z, 0, 8))                 # z - z^3/6 + z^5/120 - z^7/5040
print(sin_taylor(0.1, k=5), math.sin(0.1))          # 0.09983341667, 0.09983341665

f = lambda w: w[0]**2 * w[1] + math.sin(w[1])
g = lambda w: np.array([2*w[0]*w[1], w[0]**2 + math.cos(w[1])])
H = lambda w: np.array([[2*w[1], 2*w[0]], [2*w[0], -math.sin(w[1])]])
print(quadratic_model(f, g, H, [1, 0], [0.1, 0.2])) # 1.22, true f(1.1,0.2)=1.21956

17. Professional library implementation

import sympy as sp
import torch

x = sp.symbols("x")
expr = sp.exp(x) * sp.sin(x)
print(sp.series(expr, x, 0, 6))                      # exact symbolic Taylor polynomial

# Higher derivatives with torch.autograd (forward-mode / functorch)
w = torch.tensor([1.0, 0.0], requires_grad=True)
y = torch.exp(w[0]) * torch.sin(w[1])
grad = torch.autograd.grad(y, w, create_graph=True)[0]
hess = torch.stack([torch.autograd.grad(grad[i], w, retain_graph=True)[0]
                    for i in range(2)])
print(grad, hess)

# JAX: jvp for directional derivatives, hessian via jacfwd(jacrev(f))
import jax, jax.numpy as jnp
f = lambda w: jnp.exp(w[0]) * jnp.sin(w[1])
print(jax.jacfwd(jax.jacrev(f))(jnp.array([1.0, 0.0])))

Use sympy.series for exact symbolic expressions, torch.autograd/functorch for gradients and Hessians of learned models, and jax.jvp for directional (single-direction) derivatives when the full Hessian would be too expensive.

18. Code walkthrough

Scratch. sin_taylor exploits the four-cycle of sine's derivatives; the general taylor_1d accepts any list of derivative callables. The factorial denominator is applied explicitly — forgetting it is the most common implementation bug.

Quadratic model. grad(a) @ s is the directional derivative ∇f⊤s\nabla f^\top s, and 0.5 * s @ H @ s is the second-order correction. create_graph=True in PyTorch keeps the computational graph so that differentiating the gradient yields the Hessian; without it you get only first derivatives.

Symbolic vs automatic. sp.series performs exact rational arithmetic and is ideal for short series; automatic differentiation scales to millions of parameters but produces numerical derivatives. JAX's jvp computes ∇f⊤s\nabla f^\top s in one pass without materializing the gradient — the right tool when only one directional derivative is needed.

19. Tensor and memory analysis

In dd dimensions, the order-pp derivative tensor has dpd^p entries: for d=1000d=1000 and p=2p=2 the Hessian has 10610^6 entries (4 MB in fp32) — manageable; for p=3p=3 it is 10910^9 entries (4 GB) — not. This is why second-order Taylor models are practical and third-order ones usually are not. Storing a single directional derivative ∇f⊤s\nabla f^\top s needs only O(d)O(d), and Jacobian-vector products compute it without materializing the gradient. For a batch of BB points, the Hessian costs O(Bd2)O(Bd^2); matrix-free Hessian-vector products reduce this to O(Bd)O(Bd).

20. Time complexity

One-dimensional degree-kk expansion: O(k)O(k) derivative evaluations plus O(k)O(k) arithmetic. Multivariable full order pp: O(dp)O(d^p) coefficients, hence exponential in pp — the reason Newton (order 2) is the practical ceiling. Hessian-vector products via automatic differentiation cost O(cost(f))O(\mathrm{cost}(f)) each (about 2–4 forward passes), so approximating the quadratic model along a direction is O(d cost(f))O(d\,\mathrm{cost}(f)) at worst and O(cost(f))O(\mathrm{cost}(f)) for a single direction. Symbolic expansion can grow factorially in expression size for composite functions.

21. Space complexity

One-dimensional: O(k)O(k). Quadratic model in dd dimensions: O(d2)O(d^2) for the dense Hessian, or O(d)O(d) if only Hessian-vector products are stored (as in Newton–CG or L-BFGS). Full order-pp tensor: O(dp)O(d^p). Batch of BB: O(Bd2)O(Bd^2) if Hessians are materialized. These numbers explain the dominance of gradient and Hessian approximations in large-scale optimization.

22. Experimental demonstration

Plot ∣sin⁡(0.1)−Tk(0.1)∣|\sin(0.1)-T_k(0.1)| for k=1,3,5,7k=1,3,5,7 on a log scale: expect roughly 1.7×10−41.7\times10^{-4}, 2×10−112\times10^{-11}, and machine precision respectively. More generally, plot the error versus step size h=∣x−a∣h=|x-a| in log-log coordinates for a fixed kk; the slope should be k+1k+1 until floating-point roundoff dominates (around h∼10−8h\sim10^{-8} for k=5k=5). Test the radius of convergence with f(x)=1/(1+x2)f(x)=1/(1+x^2) at a=0a=0: the series ∑(−1)jx2j\sum(-1)^jx^{2j} diverges for ∣x∣>1|x|>1 even though ff is perfectly smooth — a dramatic demonstration that smoothness alone does not imply a convergent Taylor series. Finally verify the descent-lemma bound numerically on f(x)=x4f(x)=x^4 by checking f(a+s)−f(a)−f′(a)s≤L2s2f(a+s)-f(a)-f'(a)s\le\tfrac L2s^2 with L=12(a+∣s∣)2L=12(a+|s|)^2.

23. Benchmark results

For sin⁡\sin at x=0.1x=0.1, degree 3 already reaches 2×10−112\times10^{-11} absolute error; degree 5 hits double-precision roundoff. For exe^x at x=10x=10, degree 20 is needed for similar accuracy — the required order grows with ∣x−a∣|x-a|, so recenter the expansion near the evaluation point. Numerical differentiation to estimate the needed derivatives costs O(k)O(k) function evaluations per point but suffers O(ϵmach/h)O(\epsilon_{\text{mach}}/h) noise; automatic differentiation gives exact derivatives at a small constant-factor cost. Always report the expansion point, order, and remainder bound — an error number without them is meaningless.

24. Limitations

  • Local only: accuracy degrades as ∣x−a∣|x-a| grows; recenter for distant points.
  • Smoothness required: at nonsmooth points (e.g. ∣x∣|x| at 0) no Taylor expansion exists.
  • Convergence is not guaranteed: a C∞C^\infty function can have a divergent Taylor series (e.g. e−1/x2e^{-1/x^2} at 0 is flat but nonzero away from 0).
  • High-order derivatives are expensive: order pp in dd dimensions needs dpd^p coefficients.
  • Catastrophic cancellation: summing alternating series terms of similar magnitude loses digits in floating point.
  • Remainder bounds can be loose: using a global bound MM on f(k+1)f^{(k+1)} may badly overestimate error near aa.
  • Ill-conditioned evaluation for large ∣x−a∣|x-a| and high kk (powers overflow).

25. Failure scenarios

  1. Outside the radius of convergence: expanding 1/(1−x)1/(1-x) at 0 and evaluating at x=2x=2 gives 1+2+4+⋯1+2+4+\cdots — divergent, though f(2)=−1f(2)=-1 exists.
  2. Non-smooth point: trying to expand ∣x∣|x| at 0; the derivative does not exist, so no linear approximation (subgradients are needed).
  3. Flat but non-analytic function: f(x)=e−1/x2f(x)=e^{-1/x^2} for x≠0x\neq0, f(0)=0f(0)=0 has every derivative zero at 0, so its Taylor series is identically zero and never recovers ff.
  4. Overflow: x20x^{20} for x=1010x=10^{10} overflows fp64; scale the variable or use Horner's method with rescaling.
  5. Wrong factorial: omitting j!j! produces wildly wrong coefficients — a classic coding bug.
  6. Over-trusting low order: using a linear model where curvature dominates; the error grows quadratically and can invalidate a step-size argument.
  7. Noisy derivative estimates: finite differences with too-small hh amplify roundoff, making higher-order terms inaccurate.

26. Common misconceptions

  • "More terms always improve accuracy." Only within the convergence radius and with exact derivatives; outside it, adding terms worsens the approximation.
  • "A smooth function always equals its Taylor series." Analyticity is an extra condition; smooth non-analytic functions exist.
  • "Taylor expansion is the same as interpolation." Interpolation matches function values at several points; Taylor matches derivatives at one point.
  • "The remainder is always small." It is O(hk+1)O(h^{k+1}) as h→0h\to0, but the hidden constant can be huge if f(k+1)f^{(k+1)} is large.
  • "The second-order term requires the full Hessian always." Directional second derivatives suffice for many algorithms.
  • "Taylor series are only for pure math." They underpin every convergence proof in optimization and numerical solvers.

27. Alternative approaches

  • Padé approximants: rational functions often converge far beyond the Taylor radius and handle poles better.
  • Chebyshev approximation: near-minimax polynomial on an interval, more uniform than Taylor.
  • Splines: piecewise low-order polynomials, stable globally.
  • Finite differences: approximate derivatives directly, useful when derivatives are unavailable.
  • Automatic differentiation: compute exact derivatives without symbolic or hand derivation.
  • Asymptotic expansions: valid as a parameter tends to a limit, sometimes divergent but useful.
  • Lagrange interpolation: match values at several points instead of derivatives at one.
  • Fourier series: global basis better for periodic functions.

29. Research applications

  • Optimization: descent lemma, Newton and quasi-Newton methods, cubic regularization, trust regions.
  • Numerical analysis: error analysis of integrators and solvers; Runge–Kutta methods are built on Taylor expansions.
  • Statistics: delta method for asymptotic distributions of estimators; Laplace approximations to integrals.
  • Physics and engineering: linearization of dynamical systems, small-angle approximations, perturbation theory.
  • Machine learning: interpreting loss landscapes, second-order sensitivity, Taylor expansion in influence functions.
  • Uncertainty quantification: propagating input noise through nonlinear models.
  • Computational mathematics: rigorous interval arithmetic using Taylor models.

30. Important research papers

  • Taylor B. (1715), Methodus Incrementorum Directa et Inversa — original series.
  • Maclaurin C. (1742), A Treatise of Fluxions — expansion at zero and early rigor.
  • Lagrange J.-L. (1797), Théorie des fonctions analytiques — remainder form.
  • Cauchy A.-L. (1821), Cours d'Analyse — rigorous mean-value-theorem foundation.
  • Peano G. (1868), Sulla integrazione della equazione di Hamilton-Jacobi — Peano remainder.
  • Higham N. J. (2002), Accuracy and Stability of Numerical Algorithms, 2nd ed. — modern error analysis.

31. Further reading

  • Apostol, Calculus (2nd ed., 1967), chapters 7, 13–14 — rigorous single- and multivariable Taylor theory.
  • Rudin, Principles of Mathematical Analysis (3rd ed., 1976), chapter 5 — theorem and remainder.
  • Marsden & Tromba, Vector Calculus (5th ed., 2003), chapter 2 — multivariable case.
  • Boyer, A History of Mathematics — Taylor, Maclaurin and Lagrange context.
  • SymPy documentation: series and nseries; PyTorch autograd tutorial on higher-order derivatives.

32. Practical exercises

  1. Derive the Taylor polynomial of degree 4 for cos⁡x\cos x at 0 and compute cos⁡(0.2)\cos(0.2); compare with the true value and the Lagrange bound.
  2. Implement sin_taylor from memory and verify the error at x=0.1x=0.1 for k=1,3,5,7k=1,3,5,7.
  3. Prove the integral remainder form 1k!∫axf(k+1)(t)(x−t)kdt\frac{1}{k!}\int_a^x f^{(k+1)}(t)(x-t)^kdt by induction and show it implies the Lagrange form.
  4. For f(x,y)=x2y+sin⁡yf(x,y)=x^2y+\sin y at (1,0)(1,0), compute the gradient and Hessian by hand and verify the quadratic model at (1.1,0.2)(1.1,0.2).
  5. Show that 1/(1+x2)1/(1+x^2) has Taylor series ∑(−1)jx2j\sum(-1)^jx^{2j} with radius 1 and demonstrate divergence at x=1.5x=1.5 numerically.
  6. Numerically verify the descent-lemma bound on f(x)=x4f(x)=x^4 for s∈[−1,1]s\in[-1,1] with L=12(1+∣s∣)2L=12(1+|s|)^2.

33. Debugging challenges

  • Taylor coefficients are wrong by factors of 2, 6, 24. You forgot the j!j! denominator.
  • Series diverges for a function you expect to be smooth. Check the radius of convergence; the function may be non-analytic or you may be outside the disk.
  • PyTorch Hessian is all zeros. You omitted create_graph=True when differentiating the gradient.
  • Higher-order terms make accuracy worse. Floating-point cancellation or evaluation outside the valid neighborhood; recenter or use Horner's method.
  • Remainder bound is absurdly loose. A global MM is used; tighten it on the actual interval between aa and xx.
  • Multivariable quadratic model disagrees with the true function. Check that you used the Hessian (not the Jacobian) and included the factor 12\tfrac12.

34. Advanced exercises

  1. Give a complete proof of the multivariable Taylor theorem with integral remainder using the fundamental theorem of calculus along the segment a+tsa+ts.
  2. Construct a C∞C^\infty non-analytic function and prove its Taylor series converges to zero everywhere despite the function being nonzero.
  3. Derive a Padé approximant of order [2/2][2/2] for exe^x and compare its accuracy with the degree-4 Taylor polynomial on [−3,3][-3,3].
  4. Implement a high-order Taylor integrator for x′=f(x)x'=f(x) and derive its local error order.
  5. Prove the descent lemma from Taylor's theorem with the spectral norm bound ∥H∥2≤L\lVert H\rVert_2\le L, and show the bound is tight for a quadratic.
  6. Use Taylor expansion to derive the delta method: if n(θ^−θ)→N(0,σ2)\sqrt n(\hat\theta-\theta)\to\mathcal N(0,\sigma^2), find the asymptotic variance of g(θ^)g(\hat\theta).

35. Interview questions

  • State Taylor's theorem with the Lagrange remainder and prove it via Cauchy's mean value theorem.
  • Why is the coefficient f(j)(a)/j!f^{(j)}(a)/j!? Derive it by differentiating the ansatz.
  • Write the second-order multivariable expansion and explain the role of the Hessian's eigenvectors.
  • Give an example of a smooth function whose Taylor series does not converge to it.
  • Derive the descent lemma bound L2∥s∥2\tfrac L2\lVert s\rVert^2 from Taylor's theorem.
  • A student expands 1/(1−x)1/(1-x) at 0 and evaluates at x=2x=2, getting divergence. Explain precisely why.
  • How many coefficients does a full order-3 Taylor polynomial in 50 variables have? What does that imply for algorithms?

36. Research questions

  • Can adaptive Taylor models with rigorous remainder bounds make neural-network verification scalable?
  • Which approximation scheme (Taylor, Padé, Chebyshev) is optimal for a given function class and domain?
  • How can high-order derivative tensors be exploited without storing them explicitly?
  • What are the sharpest remainder bounds for functions with structured (e.g. sparse or low-rank) higher derivatives?
  • How do Taylor-based error bounds translate into generalization guarantees for nonlinear models?

37. Mastery assessment

To pass: (1) state and prove Taylor's theorem with remainder without notes; (2) compute the multivariable quadratic model and verify it numerically; (3) implement the 1D series and reproduce the sine/exponential numbers; (4) explain radius of convergence, non-analytic smooth functions and the descent-lemma connection; (5) answer the interview questions. Complete the linked assessment; reading alone is not mastery.`

38. Implementation submission

Push a repository with taylor.py (1D series, multivariable quadratic model, remainder bound), experiments.ipynb (sine/exponential/square-root values, log-log error slopes, divergence of 1/(1+x2)1/(1+x^2), descent-lemma check), a README.md with derivations, and tests asserting sin⁡(0.1)\sin(0.1) error <10−10<10^{-10} at k=5k=5 and the quadratic model for x2y+sin⁡yx^2y+\sin y. Submit the repository URL and exact reproduction command.`

39. Completion criteria

All of: every section read; the Lagrange-remainder proof reproduced on paper; scratch implementation passing tests; numerical experiments with recorded errors and plots; one failure case reproduced and explained; a one-page answer to a research question citing at least one paper. Only then mark the concept mastered.``

Research papers linked to this concept

taylor1715 · citation recorded, library entry pending
maclaurin1742 · citation recorded, library entry pending
lagrange1797 · citation recorded, library entry pending
cauchy1821 · citation recorded, library entry pending
peano1868 · citation recorded, library entry pending