---
title: Taylor's Theorem
module: Differentiation
moduleNumber: 5
lessonNumber: 3
order: 503
summary: >
  Taylor's theorem generalizes the mean value theorem: an n-times differentiable
  function is matched near a point by a degree-n polynomial, with a Lagrange
  remainder that names the error exactly through one higher derivative. Iterating
  the mean value theorem proves it; the second-derivative test is the order-one
  case; and a smooth non-analytic bump separates a Taylor series from the function
  it fails to represent.
topics: [Differentiation]
sources:
  - book: Lebl
    ref: "Ch. 4 — The Derivative; §4.3 Taylor's theorem"
  - book: Rosenlicht
    ref: "Ch. 5 — Differentiation"
draft: false
---

The [mean value theorem](/real-analysis/differentiation/mean-value-theorem)
approximates $f$ near $x_0$ by its tangent line and measures the error with one
derivative at an unknown interior point:
$$
f(x) = f(x_0) + f'(c)\,(x - x_0).
$$
Taylor's theorem repeats this to every order. It replaces the tangent line by a
polynomial that matches $f$ and its first $n$ derivatives at $x_0$, and it writes
the error through the $(n{+}1)$st derivative in exactly the same shape. It
underpins quantitative approximation throughout analysis.

## Higher-order derivatives

Differentiating $f$ yields $f'$; if $f'$ is itself differentiable, its derivative
is the **second derivative** $f''$. Iterating gives $f''', f'''', \dots$, and past
the third or fourth order the prime notation becomes unwieldy.

> **Definition (Higher derivatives).** Write $f^{(n)}$ for the $n$th derivative of
> $f$, defined recursively by $f^{(0)} = f$ and $f^{(k)} = \bigl(f^{(k-1)}\bigr)'$.
> If $f^{(n)}$ exists on $I$, then $f$ is **$n$ times differentiable**; if in
> addition $f^{(n)}$ is continuous, $f$ is **$n$ times continuously
> differentiable**, written $f \in C^n(I)$.

Each order requires the previous one to exist on a neighborhood, not just at a
point, so higher differentiability is a genuinely stronger hypothesis than plain
differentiability.

## The Taylor polynomial

The unique polynomial of degree $\leq n$ agreeing with $f$ in value and in its
first $n$ derivatives at $x_0$ is the **Taylor polynomial**.

> **Definition (Taylor polynomial).** For $f$ that is $n$ times differentiable
> near $x_0$, the **$n$th-order Taylor polynomial** of $f$ at $x_0$ is
> $$
> P_n^{x_0}(x) \;=\; \sum_{k=0}^{n} \frac{f^{(k)}(x_0)}{k!}\,(x - x_0)^k
> = f(x_0) + f'(x_0)(x - x_0) + \frac{f''(x_0)}{2}(x - x_0)^2 + \cdots
> + \frac{f^{(n)}(x_0)}{n!}(x - x_0)^n.
> $$

Differentiating the sum term by term and evaluating at $x_0$ collapses every term
but one, giving $\bigl(P_n^{x_0}\bigr)^{(k)}(x_0) = f^{(k)}(x_0)$ for
$0 \leq k \leq n$: the polynomial's derivatives at $x_0$ match those of $f$ up to
order $n$. That matching is the entire reason it approximates well nearby.

```algorithm
caption: constructing the $n$th Taylor polynomial of $f$ at $x_0$
input: a function $f$ that is $n$ times differentiable near $x_0$
$P \gets 0$
for $k = 0$ to $n$ do
  compute the derivative $f^{(k)}(x_0)$
  $P \gets P + \dfrac{f^{(k)}(x_0)}{k!}\,(x - x_0)^k$
return $P$
```

For $f = \sin$ at $x_0 = 0$ the derivatives cycle through
$\sin, \cos, -\sin, -\cos$, so the even-order terms all vanish and only odd powers
remain.

| $k$ | $f^{(k)}(0)$ | contribution to $P_n^{0}$ |
| --- | --- | --- |
| $0$ | $0$ | $0$ |
| $1$ | $1$ | $x$ |
| $2$ | $0$ | $0$ |
| $3$ | $-1$ | $-\dfrac{x^3}{6}$ |
| $4$ | $0$ | $0$ |
| $5$ | $1$ | $\dfrac{x^5}{120}$ |

Successive odd-degree polynomials $P_1, P_3, P_5, \dots$ track $\sin$ over ever
wider intervals around the origin.

A **consistency check** confirms the construction: a polynomial $p$ of degree $d$
is its own $d$th Taylor polynomial at every point. Matching value and first $d$
derivatives at $x_0$ determines a degree-$d$ polynomial uniquely, and $p$ matches
itself, so $P_d^{x_0} = p$. Taylor approximation reproduces polynomials exactly
and only genuinely approximates functions that are not polynomials.[^lebl-poly]

$$
% caption: Taylor polynomials of the sine at the origin. The degree-1 tangent
% $P_1 = x$ leaves the curve almost immediately; the degree-3 polynomial
% $P_3 = x - x^3/6$ peaks just short of the crest, tracks the sine to about
% $x = 2$, then dives through its zero at $\sqrt6 \approx 2.45$. Each higher
% odd degree hugs the curve over a wider range.
\begin{tikzpicture}[scale=1.1,>=stealth,font=\footnotesize]
\definecolor{acc}{HTML}{4A6FA5}
\draw[black,->] (-0.2,0) -- (4.9,0) node[right]{x};
\draw[black,->] (0,-1.6) -- (0,1.9) node[above]{y};
% sine curve (y scaled by 1.4)
\draw[thick,black] plot[domain=0:4.4,samples=70] (\x,{1.4*sin(deg(\x))});
\node[black,anchor=west] at (4.45,-1.3) {sin x};
% P1 = x : tangent line at the origin, leaves the curve immediately
\draw[acc,thick] (0,0) -- (1.2,1.68);
\node[acc,anchor=west] at (1.24,1.66) {$P_1$};
% P3 = x - x^3/6 : peaks below the crest, then dives through sqrt(6)
\draw[acc!80,densely dashed,thick] plot[domain=0:2.78,samples=50] (\x,{1.4*(\x-\x*\x*\x/6)});
\node[acc,anchor=west] at (2.84,-1.05) {$P_3$};
\end{tikzpicture}
$$

## Taylor's theorem with Lagrange remainder

The approximation is exact once the error term is added, and the error has the
same form as the mean value theorem's, one derivative higher.

> **Theorem (Taylor).** Suppose $f : [a, b] \to \mathbb{R}$ has $n$ continuous
> derivatives on $[a, b]$ and $f^{(n+1)}$ exists on $(a, b)$. For distinct points
> $x_0, x \in [a, b]$ there is a point $c$ strictly between them with
> $$
> f(x) = P_n^{x_0}(x) + \underbrace{\frac{f^{(n+1)}(c)}{(n+1)!}\,(x - x_0)^{n+1}}_{R_n^{x_0}(x)}.
> $$
> The term $R_n^{x_0}(x)$ is the **remainder**, written here in **Lagrange
> form**.[^lebl-taylor]

Taking $n = 0$ reduces the statement to $f(x) = f(x_0) + f'(c)(x - x_0)$, which is
the mean value theorem; Taylor's theorem is its exact generalization.

> **Proof.** Fix $x$ and choose the number $M$ so that
> $f(x) = P_n^{x_0}(x) + M(x - x_0)^{n+1}$; the claim is that
> $M = \frac{f^{(n+1)}(c)}{(n+1)!}$ for some interior $c$. Define
> $$
> g(s) = f(s) - P_n^{x_0}(s) - M\,(s - x_0)^{n+1}.
> $$
> Because $P_n^{x_0}$ matches $f$ through order $n$ at $x_0$ and the last term and
> its first $n$ derivatives vanish at $x_0$,
> $$
> g(x_0) = g'(x_0) = \cdots = g^{(n)}(x_0) = 0,
> $$
> and by the choice of $M$ also $g(x) = 0$. Apply Rolle's theorem to $g$ on the
> interval between $x_0$ and $x$: since $g(x_0) = g(x) = 0$ there is an $x_1$ with
> $g'(x_1) = 0$. Now $g'(x_0) = 0 = g'(x_1)$, so Rolle applied to $g'$ gives $x_2$
> with $g''(x_2) = 0$. Repeating $n+1$ times produces a point $c$ with
> $g^{(n+1)}(c) = 0$. Differentiating $g$ exactly $n+1$ times annihilates the
> polynomial $P_n^{x_0}$ and leaves
> $$
> g^{(n+1)}(s) = f^{(n+1)}(s) - (n+1)!\,M,
> $$
> so $0 = g^{(n+1)}(c) = f^{(n+1)}(c) - (n+1)!\,M$ gives the claimed $M$.
> $\blacksquare$

The proof iterates the mean value theorem through the derivatives: each
application of Rolle lowers the order of $g$ by one while producing a new zero.

## Error estimates

The remainder is useful because $f^{(n+1)}$ is often bounded on the interval.
If $|f^{(n+1)}| \leq K$ between $x_0$ and $x$, then
$$
\bigl|f(x) - P_n^{x_0}(x)\bigr| \;\leq\; \frac{K}{(n+1)!}\,|x - x_0|^{n+1}.
$$
Two features drive the bound down: the factorial $(n+1)!$ in the denominator and
the power $|x - x_0|^{n+1}$, which is small when $x$ is close to $x_0$. Together
they mean the error goes to zero faster than $(x - x_0)^n$ as $x \to x_0$, which
is the precise sense in which $P_n^{x_0}$ is a degree-$n$ approximation.

> **Worked example (Bounding $\sin(0.5)$).** Approximate $\sin(0.5)$ by the
> degree-3 polynomial $P_3^0(x) = x - \frac{x^3}{6}$. Every derivative of $\sin$
> is bounded by $1$, so $K = 1$ serves in the remainder bound with $n = 3$:
> $$
> \bigl|\sin(0.5) - P_3^0(0.5)\bigr| \;\leq\; \frac{1}{4!}\,(0.5)^4
> = \frac{0.0625}{24} \approx 2.6 \times 10^{-3}.
> $$
> The polynomial gives $P_3^0(0.5) = 0.5 - \frac{0.125}{6} \approx 0.47917$, and
> the true value is $\sin(0.5) \approx 0.47943$; the actual error
> $2.6 \times 10^{-4}$ is well inside the guaranteed bound. Since the fourth-order
> term of $\sin$ vanishes, $P_3^0$ is also the degree-4 polynomial, and using
> $n = 4$ tightens the bound to $\frac{(0.5)^5}{120} \approx 2.6 \times 10^{-4}$,
> matching the observed error to a single significant figure.

The remainder formula converts a bound on a derivative into a certified numerical
error, with no appeal to the unknown exact value. The exponential shows the same
mechanism where the bounding derivative is not constant.

> **Worked example (A second-order bound for $e^x$).** The exponential is its own
> derivative, so its degree-2 Taylor polynomial at $0$ is
> $P_2^0(x) = 1 + x + \frac{x^2}{2}$ and $f^{(3)} = \exp$. To bound the error at
> $x = 0.5$, use $f^{(3)}(c) = e^c \leq e^{0.5} < 2$ for $c \in (0, 0.5)$, since
> $e < 4$ forces $e^{0.5} < 2$. With $n = 2$ and $K = 2$,
> $$
> \bigl|e^{0.5} - P_2^0(0.5)\bigr| \;\leq\; \frac{2}{3!}\,(0.5)^3
> = \frac{2}{6}\cdot\frac{1}{8} = \frac{1}{24} \approx 4.2 \times 10^{-2}.
> $$
> The polynomial gives $P_2^0(0.5) = 1.625$ and the true value is
> $e^{0.5} \approx 1.6487$, so the actual error $2.4 \times 10^{-2}$ falls inside
> the bound, again certified without knowing $e^{0.5}$ in advance.

$$
% caption: The remainder is the vertical gap between the graph and its Taylor
% polynomial at x; it is controlled by the next derivative and shrinks faster
% than the nth power of the distance from x0.
\begin{tikzpicture}[scale=1.1,>=stealth,font=\footnotesize]
\definecolor{acc}{HTML}{4A6FA5}
\draw[black,->] (-0.2,0) -- (5.2,0) node[right]{x};
\draw[black,->] (0,-0.2) -- (0,3.4) node[above]{y};
% f curve
\draw[thick,black] (0.4,0.6) to[out=25,in=205] (2.4,1.6) to[out=25,in=200] (4.6,3.1);
\node[black] at (4.35,2.55) {f};
% Taylor polynomial, tangent-like, agrees at x0, drifts below
\draw[acc,thick] (0.4,0.6) to[out=22,in=200] (2.4,1.55) to[out=22,in=205] (4.6,2.55);
\node[acc] at (3.9,1.85) {P};
% agreement point x0
\fill[acc] (1.4,1.06) circle (1.6pt);
\node[below] at (1.4,0.95) {x0};
% gap at x
\draw[black,densely dashed] (4.6,0) -- (4.6,3.1);
\draw[acc!80,<->,thick] (4.6,2.6) -- (4.6,3.05);
\node[acc,right] at (4.62,2.85) {remainder};
\node[below] at (4.6,-0.02) {x};
\end{tikzpicture}
$$

**The second-derivative test** falls out of the case $n = 1$. If $f$ is twice
continuously differentiable, $f'(x_0) = 0$, and $f''(x_0) > 0$, then near $x_0$
$$
f(x) = f(x_0) + \frac{f''(c)}{2}(x - x_0)^2,
$$
with $f''(c) > 0$ for $x$ close enough (continuity of $f''$), so
$f(x) > f(x_0)$: the point is a strict relative minimum.[^lebl-2dt] The sign of
$f''(x_0)$ classifies the critical point, and the same idea iterated gives the
$n$th-derivative test.

$$
% caption: At a critical point with positive second derivative the order-2 Taylor
% expansion is an upward parabola, so f sits above f(x0) on both sides and the
% point is a strict minimum.
\begin{tikzpicture}[scale=1.0,>=stealth,font=\footnotesize]
\definecolor{acc}{HTML}{4A6FA5}
\draw[black,->] (-0.2,0) -- (5.4,0) node[right]{x};
\draw[black,->] (0,-0.2) -- (0,3.4) node[above]{y};
\draw[thick,black] (0.55,3.05) to[out=-72,in=168] (2.6,0.75) to[out=-12,in=250] (4.75,2.95);
\draw[acc!80,densely dashed,thick] plot[domain=1.35:3.85,samples=40] (\x,{0.75+0.6*(\x-2.6)*(\x-2.6)});
\draw[black] (1.5,0.75) -- (3.7,0.75);
\fill[acc] (2.6,0.75) circle (1.7pt);
\node[below] at (2.6,-0.02) {x0};
\node[acc,anchor=west] at (3.55,1.9) {parabola};
\node[black,anchor=east] at (1.45,1.35) {strict min};
\node[black] at (2.6,1.25) {slope 0};
\end{tikzpicture}
$$

## Taylor series and analytic functions

When $f$ is infinitely differentiable, the polynomials extend to an infinite
series.

> **Definition (Taylor series).** For $f$ infinitely differentiable at $x_0$, the
> **Taylor series** is $\displaystyle \sum_{k=0}^{\infty}
> \frac{f^{(k)}(x_0)}{k!}(x - x_0)^k$. If this series converges to $f$ on some
> open interval around every $x_0$ in the domain, $f$ is **analytic**.

Two independent failures separate a function from its Taylor series:

- **The series may diverge.** Expanding $\frac{x}{1-x}$ at $0$ gives Taylor
  polynomials $P_n^0(x) = x + x^2 + \cdots + x^n$, the partial sums of a geometric
  [series](/real-analysis/sequences-series/series-convergence). These converge to
  the function only on $(-1, 1)$; for $x \leq -1$ the approximations grow visibly
  worse as the degree rises, no matter that $\frac{x}{1-x}$ is perfectly finite
  there. The Taylor series carries the convergence radius of a power series, a
  restriction the function itself need not respect.
- **The series may converge to the wrong function.** Even where the Taylor series
  converges, its sum need not be $f$.

The second failure is the sharper one. The Taylor series can converge everywhere
and still equal $f$ at only one point.

$$
% caption: The smooth bump e^{-1/x^2} is zero at the origin together with every
% derivative, so its Taylor series at 0 is identically zero and never recovers
% the function away from 0.
\begin{tikzpicture}[scale=1.1,>=stealth,font=\footnotesize]
\definecolor{acc}{HTML}{4A6FA5}
\draw[black,->] (-3.2,0) -- (3.4,0) node[right]{x};
\draw[black,->] (0,-0.3) -- (0,2.1) node[above]{y};
% curve: plateau near 1.6 far out, tangent-flat down to 0 at origin
\draw[thick,acc] (-3.0,1.7) to[out=-8,in=150] (-1.4,1.05) to[out=-30,in=180] (0,0) to[out=0,in=210] (1.4,1.05) to[out=8,in=188] (3.0,1.7);
\fill[acc] (0,0) circle (1.6pt);
\node[align=center,black] at (0,-0.75) {zero to all orders at 0};
\draw[black,densely dashed] (-2.2,1.65) -- (2.2,1.65);
\node[black,above] at (2.4,1.6) {plateau};
\end{tikzpicture}
$$

The function
$$
f(x) =
\begin{cases}
e^{-1/x^2}, & x \neq 0,\\
0, & x = 0,
\end{cases}
$$
is infinitely differentiable, and every derivative at the origin is zero. Its
Taylor series at $0$ is therefore the zero series, which converges everywhere to
the zero function, yet $f(x) > 0$ for all $x \neq 0$. Smoothness does not imply
analyticity. The
[power-series methods](/real-analysis/function-sequences/power-series-weierstrass)
distinguish the two, and the same non-analytic bump is what makes smooth
partitions of unity possible in the calculus of several variables.

[^lebl-taylor]: **Lebl**, _Basic Analysis I_, §4.3, Definition 4.3.1 and Theorem 4.3.2 — the Taylor polynomial and Taylor's theorem with the Lagrange form of the remainder, proved by iterating the mean value theorem. See also **Rosenlicht**, Ch. 5.
[^lebl-2dt]: **Lebl**, _Basic Analysis I_, §4.3, Proposition 4.3.3 — the second-derivative test as the order-1 case of Taylor's theorem.
[^lebl-poly]: **Lebl**, _Basic Analysis I_, §4.3, Exercise 4.3.2 — a degree-$d$ polynomial equals its own $d$th Taylor polynomial.
