# Mean Value Theorems and Taylor's Theorem: Recovering a Function from Its Derivatives

> From the extreme value theorem we prove the mean value theorems of Rolle, Lagrange and Cauchy, then derive l'Hôpital's rule and Taylor's theorem with explicit error bounds.
> https://rikai.mugen-giken.com/en/mathematics/calculus/mean-value-and-taylor

## 0. Key points

- The derivative carries information about a single point only. The device that translates it into a statement holding on a whole interval is the mean value theorem, and almost every application of calculus passes through it.
- Rolle's theorem follows from the extreme value theorem together with Fermat's lemma, and from Rolle's theorem follow the mean value theorems of Lagrange and Cauchy. The three stand to one another almost as restatements of a single theorem.
- L'Hôpital's rule is derived from Cauchy's mean value theorem. Using it without checking all three of "the expression really is of the form $0/0$", "$g' \ne 0$" and "the limit of $f'/g'$ exists" leads to false conclusions.
- The protagonist of Taylor's theorem is not the polynomial but the remainder. Only once we have the form $R_n(x) = f^{(n+1)}(c)(x-a)^{n+1}/(n+1)!$ does the approximation become a usable tool.
- The functions $e^x$ and $\sin x$ converge to their Maclaurin series for every real number, and $\log(1+x)$ does so for $-1 < x \le 1$. Proving this convergence is nothing other than checking that the remainder tends to $0$.

## 1. Motivation

The derivative $f'(c)$ is a quantity determined by looking only at points arbitrarily close to $c$. What we actually want to use, however, are statements about an entire interval, such as the following.

- If $f'$ is identically $0$ on an interval, then $f$ is constant there.
- If $f'$ is everywhere positive on an interval, then $f$ is increasing there.
- If $|f'| \le 1$, then $f$ satisfies $|f(x) - f(y)| \le |x-y|$.

Each of these feels inevitable, and none of them is obvious. The only thing appearing in the definition of the derivative is the limit as $x \to c$, and nothing in it directly relates the values of $f$ at two separated points $x, y$. We need a bridge from local information to a global conclusion, and that bridge is the mean value theorem.

In everyday language it says this. A car that covers the $500$ km from Tokyo to Osaka in $5$ hours must at some moment along the way have had its speedometer reading exactly $100$ km/h. The average speed (the ratio of a difference of two values) is realized as the instantaneous speed (the derivative) at some single point. That is the assertion of the mean value theorem.

There is a second line of motivation: the demand to compute values of functions in practice. If we want to know $\sin(0.1)$, extracting a number directly from the definition of the sine (arc length on a circle, or a series) is troublesome, whereas a polynomial can be evaluated with the four arithmetic operations alone. So we would like to replace $f$ by a polynomial. But the moment we do so, an error appears. Unless the size of that error can be estimated, the approximation is not a mathematical tool. Taylor's theorem gives this error a definite form. And, remarkably, its proof again comes from the mean value theorem — Cauchy's version, to be precise.

Let us set out the logical flow of this article in advance.

<Figure caption="The logical structure of this article. Everything starts from the continuity of the real numbers and passes through Rolle's theorem.">
<Mermaid code={`flowchart TD
  A["Continuity of the reals (existence of suprema)"] --> B["Extreme value theorem"]
  B --> D["Rolle's theorem"]
  C["Fermat's lemma"] --> D
  D --> E["Lagrange's mean value theorem"]
  D --> F["Cauchy's mean value theorem"]
  E --> G["Monotonicity tests and proofs of inequalities"]
  F --> H["L'Hopital's rule"]
  F --> I["Taylor's theorem (Lagrange remainder)"]
  I --> J["Maclaurin expansions and error bounds"]`} />
</Figure>

## 2. Preliminaries

We use the definition of the derivative and the basic rules of differentiation as treated in [The definition of the derivative and basic differentiation](/en/mathematics/calculus/derivatives). In particular, the fact that differentiability at $c$ implies continuity at $c$ (<Ref to="mathematics/calculus/derivatives#thm-diff-implies-cont" text="differentiable implies continuous" />) will be used repeatedly below.

<Definition id="def-local-extremum" title="Local maxima and minima">
Let $I \subset \mathbb{R}$, let $f: I \to \mathbb{R}$ and let $c \in I$. If there exists $\delta > 0$ such that
$$
f(x) \le f(c)
$$
holds for every $x \in I$ with $|x - c| < \delta$, we say that $f$ has a **local maximum** at $c$. Likewise, if $f(x) \ge f(c)$ holds for all such $x$, we say that $f$ has a **local minimum** at $c$. Having either a local maximum or a local minimum is expressed by saying that $f$ has a local extremum.
</Definition>

Note that "maximum" refers to a comparison with the whole interval, whereas "local maximum" refers to a comparison only with points near $c$. A point at which the maximum is attained is a local maximum point, but not conversely.

<Definition id="def-cn-class" title="n times differentiable functions and functions of class C^n">
For a function $f$ on an open interval $I$, put $f^{(0)} = f$, and whenever $f^{(k-1)}$ is differentiable on $I$ set $f^{(k)} = (f^{(k-1)})'$. If $f^{(n)}$ exists on $I$, we say that $f$ is $n$ times differentiable on $I$; if moreover $f^{(n)}$ is continuous on $I$, we say that $f$ is of **class $C^n$**. If $f$ is of class $C^n$ for every $n$, we say that it is of class $C^\infty$.
</Definition>

If $f$ is $n$ times differentiable, then $f^{(n-1)}$ is differentiable and hence continuous, so $f$ is automatically of class $C^{n-1}$. The difference between being $n$ times differentiable and being of class $C^n$ is precisely whether the last derivative $f^{(n)}$ is continuous.

<Theorem id="thm-evt" title="Extreme value theorem">
Let $a < b$ and let $f: [a,b] \to \mathbb{R}$ be continuous on $[a,b]$. Then there exist $x_M, x_m \in [a,b]$ such that
$$
f(x_m) \le f(x) \le f(x_M)
$$
holds for every $x \in [a,b]$. That is, $f$ attains a maximum and a minimum on $[a,b]$.
</Theorem>

<Remark id="rem-evt" title="Where the proof lives, and why the hypotheses are needed">
The proof of this theorem rests on the continuity of the real numbers (the existence of suprema, or the Bolzano–Weierstrass theorem). Since the proof is given in [Limits and continuity (ε-δ arguments)](/en/mathematics/calculus/limits-and-continuity), we take the theorem as known here.

Neither hypothesis can be dropped. Failure for a non-closed interval is shown by $f(x) = 1/x$ on $(0,1]$, which is continuous but not even bounded above. Failure for an unbounded interval is shown by $f(x) = x$ on $[0,\infty)$. Dropping continuity, the function on $[0,1]$ defined by $f(0) = 0$ and $f(x) = 1 - x$ for $0 < x \le 1$ never reaches its supremum $1$.
</Remark>

<Lemma id="lem-fermat" title="Fermat's lemma">
Let $I$ be an open interval, let $f : I \to \mathbb{R}$ and let $c \in I$. If $f$ has a local extremum at $c$ and is differentiable at $c$, then $f'(c) = 0$.
</Lemma>

<Proof of="lem-fermat">
It suffices to treat the case of a local maximum. For a local minimum, consider $-f$: it has a local maximum at $c$, so by the case already proved $(-f)'(c) = -f'(c) = 0$, whence $f'(c) = 0$.

By <Ref to="def-local-extremum" /> there is $\delta_1 > 0$ such that $f(c+h) \le f(c)$ whenever $|h| < \delta_1$ and $c + h \in I$. Moreover, since $I$ is open, we may take $\delta \le \delta_1$ small enough that $|h| < \delta$ already forces $c + h \in I$. We fix this $\delta$ for the rest of the proof.

For $0 < h < \delta$ the numerator satisfies $f(c+h) - f(c) \le 0$ while the denominator satisfies $h > 0$, so
$$
\frac{f(c+h) - f(c)}{h} \le 0 .
$$
Letting $h \to +0$ and using that limits preserve weak inequalities (a limit of quantities that are $\le 0$ is $\le 0$), we obtain $f'(c) \le 0$ from the right-hand limit.

For $-\delta < h < 0$ the numerator is again $f(c+h) - f(c) \le 0$, but now the denominator satisfies $h < 0$, so
$$
\frac{f(c+h) - f(c)}{h} \ge 0 ,
$$
and letting $h \to -0$ gives $f'(c) \ge 0$.

Since $f$ is differentiable at $c$, the two one-sided limits both exist and are equal to the same value $f'(c)$. Hence $f'(c) \le 0$ and $f'(c) \ge 0$, that is, $f'(c) = 0$.
</Proof>

The hypothesis that $I$ is an open interval is essential. Taking $f(x) = x$ on $[0,1]$, the maximum occurs at $x = 1$, yet $f'(1) = 1 \ne 0$. The reason is that $1$ can be approached only from the left, so only one half of the argument above can be carried out. This circumstance reappears in the next section as conclusions of the form "$c$ may be found inside the open interval $(a,b)$".

## 3. Three mean value theorems

### 3.1. Rolle's theorem

<Theorem id="thm-rolle" title="Rolle's theorem">
Let $a < b$ and suppose $f : [a,b] \to \mathbb{R}$ satisfies the following three conditions.

1. $f$ is continuous on the closed interval $[a,b]$.
2. $f$ is differentiable at every point of the open interval $(a,b)$.
3. $f(a) = f(b)$.

Then there exists $c \in (a,b)$ with $f'(c) = 0$.
</Theorem>

<Proof of="thm-rolle">
By hypothesis 1 and <Ref to="thm-evt" />, $f$ attains a maximum $M = f(x_M)$ and a minimum $m = f(x_m)$ on $[a,b]$.

Case $M = m$. Then $m \le f(x) \le M = m$ for every $x \in [a,b]$, so $f$ is constant. Since $a < b$, the interval $(a,b)$ is nonempty; taking any point $c$ in it, the derivative of a constant function is by definition $\lim_{h\to 0}(f(c+h)-f(c))/h = \lim_{h \to 0} 0/h = 0$, so $f'(c) = 0$.

Case $M > m$. By hypothesis 3 we have $f(a) = f(b)$. If both $M = f(a)$ and $m = f(a)$ held, we would get $M = m$, contrary to the case assumption; so at least one of $M \ne f(a)$ and $m \ne f(a)$ holds.

Suppose $M \ne f(a) = f(b)$. The point $x_M$ where the maximum is attained satisfies $f(x_M) = M \ne f(a), f(b)$, hence $x_M \ne a$ and $x_M \ne b$, that is, $c := x_M \in (a,b)$. Since $f(x) \le f(c)$ for every $x \in [a,b]$, the point $c$ is in particular a local maximum point of $f$ on the open interval $(a,b)$ (take $\min\lbrace c-a,\ b-c \rbrace$ as the $\delta$ in <Ref to="def-local-extremum" />). By hypothesis 2, $f$ is differentiable at $c$, so applying <Ref to="lem-fermat" /> to $f$ regarded as a function on the open interval $(a,b)$ gives $f'(c) = 0$.

In the case $m \ne f(a)$, the point $x_m \in (a,b)$ is a local minimum point and <Ref to="lem-fermat" /> applies in the same way, giving $f'(x_m) = 0$.
</Proof>

<Example id="ex-rolle-hypotheses" title="None of the three hypotheses of Rolle's theorem can be dropped">
For each of the three hypotheses we exhibit an example in which removing that hypothesis alone destroys the conclusion.

**Dropping hypothesis 2 (differentiability).** Consider $f(x) = |x|$ on $[-1,1]$. It is continuous and $f(-1) = f(1) = 1$, but for $x \ne 0$ we have $f'(x) = x/|x| = \pm 1$, which is never $0$. The cause is the failure of differentiability at $x = 0$ (right derivative $1$, left derivative $-1$).

**Dropping hypothesis 3 (equal values at the endpoints).** Consider $f(x) = x$ on $[0,1]$. It is continuous and differentiable, but $f(0) = 0 \ne 1 = f(1)$, and $f'(x) = 1$ is nowhere $0$.

**Dropping hypothesis 1 (continuity on the closed interval).** Consider the function on $[0,1]$ defined by $f(x) = x$ for $0 \le x < 1$ and $f(1) = 0$. Here $f(0) = f(1) = 0$, and $f$ is differentiable at every point of $(0,1)$ with $f'(x) = 1$. But $f$ is not continuous at $x = 1$ (as $x \to 1-$ we have $f(x) \to 1 \ne 0 = f(1)$), and $f'$ is never $0$. Thus a failure of continuity at a single endpoint already destroys the conclusion.
</Example>

### 3.2. Lagrange's mean value theorem

<Theorem id="thm-mvt" title="Lagrange's mean value theorem">
Let $a < b$ and let $f : [a,b] \to \mathbb{R}$ be continuous on $[a,b]$ and differentiable at every point of $(a,b)$. Then there exists $c \in (a,b)$ with
$$
f(b) - f(a) = f'(c)\,(b-a) .
$$
Equivalently, $\dfrac{f(b)-f(a)}{b-a} = f'(c)$.
</Theorem>

<Proof of="thm-mvt">
We subtract from $f$ the straight line joining the two endpoints (the chord), so as to reach a situation where Rolle's theorem applies. Put

$$
g(x) = f(x) - f(a) - \frac{f(b)-f(a)}{b-a}(x - a) \qquad (x \in [a,b]) .
$$

Being the difference of $f$ and an affine function, $g$ is continuous on $[a,b]$ and differentiable at every point of $(a,b)$ (this uses the properties assumed of $f$, together with the fact that an affine function is everywhere continuous and differentiable). Moreover
$$
g(a) = f(a) - f(a) - 0 = 0, \qquad g(b) = f(b) - f(a) - \frac{f(b)-f(a)}{b-a}(b-a) = 0 ,
$$
so $g(a) = g(b)$. Hence $g$ satisfies all the hypotheses of <Ref to="thm-rolle" />, and there is $c \in (a,b)$ with $g'(c) = 0$. On $(a,b)$ we have
$$
g'(x) = f'(x) - \frac{f(b)-f(a)}{b-a} ,
$$
so $g'(c) = 0$ says exactly that $f'(c) = \dfrac{f(b)-f(a)}{b-a}$. Multiplying both sides by $b - a \ne 0$ gives the asserted identity.
</Proof>

The affine function subtracted in the proof is precisely the chord joining $(a,f(a))$ and $(b,f(b))$. So the theorem says: a curve always has a tangent line parallel to its chord.

<Figure caption="The mean value theorem. A point c whose tangent line (dashed) is parallel to the chord joining the endpoints (solid) always exists inside the open interval.">
<svg viewBox="0 0 480 270" width="100%" role="img" aria-label="A curve together with the chord joining its endpoints and a tangent line parallel to that chord">
  <line x1="40" y1="230" x2="458" y2="230" stroke="currentColor" stroke-width="1" />
  <line x1="52" y1="18" x2="52" y2="242" stroke="currentColor" stroke-width="1" />
  <line x1="80" y1="180" x2="80" y2="230" stroke="currentColor" stroke-width="1" stroke-dasharray="3 4" opacity="0.55" />
  <line x1="240" y1="90" x2="240" y2="230" stroke="currentColor" stroke-width="1" stroke-dasharray="3 4" opacity="0.55" />
  <line x1="400" y1="100" x2="400" y2="230" stroke="currentColor" stroke-width="1" stroke-dasharray="3 4" opacity="0.55" />
  <path d="M 80 180 Q 240 40 400 100" fill="none" stroke="currentColor" stroke-width="2.2" />
  <line x1="80" y1="180" x2="400" y2="100" stroke="var(--sl-color-accent)" stroke-width="2" />
  <line x1="140" y1="115" x2="360" y2="60" stroke="var(--sl-color-accent)" stroke-width="2" stroke-dasharray="7 5" />
  <circle cx="80" cy="180" r="3.6" fill="currentColor" />
  <circle cx="400" cy="100" r="3.6" fill="currentColor" />
  <circle cx="240" cy="90" r="4.4" fill="var(--sl-color-accent)" />
  <text x="88" y="120" font-size="14" fill="currentColor">y = f(x)</text>
  <text x="280" y="152" font-size="13" fill="currentColor">chord</text>
  <text x="322" y="46" font-size="13" fill="currentColor">tangent</text>
  <text x="75" y="250" font-size="14" fill="currentColor">a</text>
  <text x="235" y="250" font-size="14" fill="currentColor">c</text>
  <text x="395" y="250" font-size="14" fill="currentColor">b</text>
</svg>
</Figure>

<Corollary id="cor-monotonicity" title="The sign of the derivative and monotonicity">
Let $I \subset \mathbb{R}$ be an interval and let $f : I \to \mathbb{R}$ be continuous on $I$ and differentiable at every interior point of $I$.

1. $f' = 0$ everywhere in the interior of $I$ if and only if $f$ is constant on $I$.
2. $f' \ge 0$ everywhere in the interior of $I$ if and only if $f$ is nondecreasing on $I$ (that is, $x < y \Rightarrow f(x) \le f(y)$).
3. If $f' > 0$ everywhere in the interior of $I$, then $f$ is strictly increasing on $I$ (that is, $x < y \Rightarrow f(x) < f(y)$). The converse, however, fails.
</Corollary>

<Proof of="cor-monotonicity">
We first make a preparation common to 1, 2 and 3. Let $x < y$ be arbitrary points of $I$. Since $I$ is an interval, $[x,y] \subset I$. Now $f$ is continuous on $[x,y]$, and the open interval $(x,y)$ is contained in the interior of $I$ (a point lying between two points of $I$ is an interior point of $I$), so $f$ is differentiable at every point of $(x,y)$. Hence <Ref to="thm-mvt" /> applies and yields a $c$ with
$$
f(y) - f(x) = f'(c)(y - x), \qquad c \in (x,y) .
$$
Since $y - x > 0$, the sign of $f(y)-f(x)$ agrees with the sign of $f'(c)$.

Proof of 1. If $f' = 0$ throughout the interior, the displayed identity gives $f(y) - f(x) = 0$ for all $x < y$, so $f$ is constant. Conversely, if $f$ is constant, then at every interior point $c$ the difference quotient is identically $0$, so $f'(c) = 0$.

Proof of 2. If $f' \ge 0$ throughout the interior, the identity gives $f(y)-f(x) = f'(c)(y-x) \ge 0$, so $f$ is nondecreasing. Conversely, if $f$ is nondecreasing, then for an interior point $c$ and $h \ne 0$ we have $(f(c+h)-f(c))/h \ge 0$ (for $h > 0$ both numerator and denominator are $\ge 0$; for $h < 0$ both are $\le 0$). Letting $h \to 0$ and using that limits preserve weak inequalities gives $f'(c) \ge 0$.

Proof of 3. If $f' > 0$ throughout the interior, the identity gives $f(y) - f(x) = f'(c)(y-x) > 0$, so $f$ is strictly increasing. A counterexample to the converse is $f(x) = x^3$. It is strictly increasing on $\mathbb{R}$ (if $x < y$ then $y^3 - x^3 = (y-x)(y^2+xy+x^2) > 0$; indeed $y^2 + xy + x^2 = (y + x/2)^2 + 3x^2/4$ is positive except at $x = y = 0$), yet $f'(0) = 0$.
</Proof>

Statement 1 is used in the form "two functions with the same derivative differ by a constant", which is what makes the indefinite integral well defined up to an additive constant. This fact plays a central role in [The fundamental theorem of calculus and the definite integral](/mathematics/calculus/integration-and-ftc).

<Example id="ex-mvt-inequality" title="Producing inequalities from the mean value theorem">
The mean value theorem is used more often by estimating the value of $f'$ and passing to an inequality than as an equality in its own right.

**(1) The sine function is $1$-Lipschitz.** For all real $x, y$ we have $|\sin x - \sin y| \le |x - y|$.

For $x = y$ both sides are $0$. For $x \ne y$ we may assume $x < y$ without loss of generality. Since $\sin$ is differentiable on all of $\mathbb{R}$, <Ref to="thm-mvt" /> applies on $[x,y]$ and gives some $c \in (x,y)$ with
$$
\sin y - \sin x = \cos(c)\,(y - x) .
$$
As $|\cos c| \le 1$, taking absolute values yields $|\sin y - \sin x| \le |y - x|$.

**(2) Two-sided bounds for the logarithm.** For $x > 0$,
$$
\frac{x}{1+x} < \log(1+x) < x .
$$
The function $f(t) = \log(1+t)$ is continuous on $[0,x]$ and differentiable on $(0,x)$ with $f'(t) = 1/(1+t)$. By <Ref to="thm-mvt" /> there is $c \in (0,x)$ with
$$
\log(1+x) - \log 1 = \frac{x}{1+c} .
$$
From $0 < c < x$ we get $1 < 1 + c < 1 + x$, and taking reciprocals of each side gives $\dfrac{1}{1+x} < \dfrac{1}{1+c} < 1$. Multiplying by $x > 0$,
$$
\frac{x}{1+x} < \frac{x}{1+c} = \log(1+x) < x .
$$
Checking at $x = 1$ gives $0.5 < \log 2 = 0.6931\ldots < 1$, so the bounds do hold.
</Example>

### 3.3. Cauchy's mean value theorem

Sometimes we want to compare the variations of two functions. Naively one might apply <Ref to="thm-mvt" /> to $f$ and to $g$ separately and take the quotient, but the intermediate points produced for $f$ and for $g$ are different, leaving us with the unwieldy expression $f'(c_1)/g'(c_2)$. The following theorem realizes the ratio at one and the same point $c$.

<Theorem id="thm-cauchy-mvt" title="Cauchy's mean value theorem">
Let $a < b$ and let $f, g : [a,b] \to \mathbb{R}$ both be continuous on $[a,b]$ and differentiable at every point of $(a,b)$. Then there exists $c \in (a,b)$ with
$$
\bigl(f(b) - f(a)\bigr) g'(c) = \bigl(g(b) - g(a)\bigr) f'(c) .
$$
If moreover $g'(x) \ne 0$ for every $x \in (a,b)$, then $g(b) \ne g(a)$ and we may write
$$
\frac{f(b)-f(a)}{g(b)-g(a)} = \frac{f'(c)}{g'(c)} .
$$
</Theorem>

<Proof of="thm-cauchy-mvt">
Put
$$
h(x) = \bigl(f(b)-f(a)\bigr)\bigl(g(x) - g(a)\bigr) - \bigl(g(b)-g(a)\bigr)\bigl(f(x) - f(a)\bigr) .
$$
Being a sum of constant multiples of $f$ and $g$, the function $h$ is continuous on $[a,b]$ and differentiable on $(a,b)$. Its values at the endpoints are
$$
h(a) = 0, \qquad h(b) = \bigl(f(b)-f(a)\bigr)\bigl(g(b)-g(a)\bigr) - \bigl(g(b)-g(a)\bigr)\bigl(f(b)-f(a)\bigr) = 0 ,
$$
so $h(a) = h(b)$. By <Ref to="thm-rolle" /> there is $c \in (a,b)$ with $h'(c) = 0$, and substituting into
$$
h'(x) = \bigl(f(b)-f(a)\bigr) g'(x) - \bigl(g(b)-g(a)\bigr) f'(x)
$$
gives the first assertion.

Now the second part. If $g(a) = g(b)$, then $g$ satisfies the hypotheses of <Ref to="thm-rolle" />, so there is $\xi \in (a,b)$ with $g'(\xi) = 0$, contradicting "$g'(x) \ne 0$ for every $x \in (a,b)$". Hence $g(b) \ne g(a)$. Dividing the identity of the first assertion by $\bigl(g(b)-g(a)\bigr) g'(c) \ne 0$ (here $g'(c) \ne 0$ by hypothesis) gives the stated form.
</Proof>

<Remark id="rem-two-points" title="Why a single intermediate point is indispensable">
Consider $f(x) = x^3$ and $g(x) = x^2$ on $[0,1]$. Applying <Ref to="thm-mvt" /> to $f$ and to $g$ separately, $f(1)-f(0) = 1 = 3c_1^2$ gives $c_1 = 1/\sqrt{3} = 0.5773\ldots$, and $g(1)-g(0) = 1 = 2c_2$ gives $c_2 = 1/2$, so the two intermediate points differ. The $c$ asserted by <Ref to="thm-cauchy-mvt" />, on the other hand, is determined by
$$
\frac{f(1)-f(0)}{g(1)-g(0)} = 1 = \frac{3c^2}{2c} = \frac{3c}{2}
$$
so that $c = 2/3 = 0.6666\ldots$, different from both $c_1$ and $c_2$. In the proof of l'Hôpital's rule in the next section, the ability to rewrite numerator and denominator as a ratio of derivatives at one and the same point $c$ is decisive.
</Remark>

## 4. L'Hôpital's rule

If $f(x) \to 0$ and $g(x) \to 0$ as $x \to a$, what is the limit of the quotient $f(x)/g(x)$? Among the rules for limits (<Ref to="mathematics/calculus/limits-and-continuity#thm-algebra" text="the algebra of limits" />), the quotient rule applies only when the limit of the denominator is nonzero, so this shape — the indeterminate form $0/0$ — has so far had to be handled by ad hoc devices in each case. L'Hôpital's rule replaces those devices by the mechanical operation of differentiating numerator and denominator separately.

The rule bears this name because it appeared in the 1696 textbook *Analyse des infiniment petits pour l'intelligence des lignes courbes* by the Marquis de l'Hôpital, though the content is believed to be due to Johann Bernoulli. L'Hôpital had a contract with Bernoulli granting him the right to use Bernoulli's results in his own book.

<Theorem id="thm-lhopital" title="L'Hôpital's rule (the 0/0 form, right-hand limits)">
Let $a \in \mathbb{R}$ and $\delta_0 > 0$, and let $f, g$ be real-valued functions differentiable on the open interval $(a, a+\delta_0)$. Assume the following three conditions.

1. $g'(x) \ne 0$ for every $x \in (a, a+\delta_0)$.
2. $\displaystyle \lim_{x \to a+} f(x) = 0$ and $\displaystyle \lim_{x \to a+} g(x) = 0$.
3. The limit $\displaystyle L = \lim_{x \to a+} \frac{f'(x)}{g'(x)}$ exists as a real number.

Then $g(x) \ne 0$ for every $x \in (a,a+\delta_0)$, and
$$
\lim_{x \to a+} \frac{f(x)}{g(x)} = L .
$$
</Theorem>

<Proof of="thm-lhopital">
**Step 0 (extend to functions continuous up to $a$).** Define $F, G : [a, a+\delta_0) \to \mathbb{R}$ by
$$
F(a) = 0,\quad F(x) = f(x)\ (x > a), \qquad G(a) = 0,\quad G(x) = g(x)\ (x > a) .
$$
Hypothesis 2 says exactly that $F$ and $G$ are right-continuous at $a$. On $(a, a+\delta_0)$ we have $F = f$ and $G = g$, which are differentiable and hence continuous. Therefore, for every $x \in (a, a+\delta_0)$, the functions $F$ and $G$ are continuous on $[a,x]$ and differentiable on $(a,x)$.

**Step 1 (the denominator does not vanish).** Suppose $g(x_0) = 0$ for some $x_0 \in (a, a+\delta_0)$. Then $G(a) = G(x_0) = 0$, and since $G$ is continuous on $[a,x_0]$ and differentiable on $(a,x_0)$, <Ref to="thm-rolle" /> yields $\xi \in (a,x_0)$ with $G'(\xi) = g'(\xi) = 0$, contradicting hypothesis 1. Hence $g \ne 0$ on $(a,a+\delta_0)$ and the quotient $f(x)/g(x)$ is meaningful.

**Step 2 (rewriting as a ratio at a single point).** Let $x \in (a,a+\delta_0)$ be arbitrary. On $(a,x) \subset (a,a+\delta_0)$ we have $G' = g' \ne 0$, so the second part of <Ref to="thm-cauchy-mvt" /> applies to $F, G$ on $[a,x]$, and for some $c_x \in (a,x)$
$$
\frac{f(x)}{g(x)} = \frac{F(x) - F(a)}{G(x) - G(a)} = \frac{F'(c_x)}{G'(c_x)} = \frac{f'(c_x)}{g'(c_x)} .
$$

**Step 3 (the $\varepsilon$ argument).** Let $\varepsilon > 0$ be arbitrary. By hypothesis 3 there is $\delta \in (0, \delta_0]$ such that $a < t < a + \delta$ implies
$$
\left| \frac{f'(t)}{g'(t)} - L \right| < \varepsilon .
$$
Now let $a < x < a + \delta$. The point $c_x$ from Step 2 satisfies $a < c_x < x < a+\delta$, so the estimate applies with $t = c_x$ and
$$
\left| \frac{f(x)}{g(x)} - L \right| = \left| \frac{f'(c_x)}{g'(c_x)} - L \right| < \varepsilon .
$$
Since $\varepsilon > 0$ was arbitrary, $\lim_{x \to a+} f(x)/g(x) = L$.
</Proof>

<Remark id="rem-lhopital-variants" title="Left-hand, two-sided and infinite versions">
For a left-hand limit $x \to a-$, put $\tilde f(y) = f(2a - y)$ and $\tilde g(y) = g(2a-y)$ to reduce to the theorem as stated. Indeed $\tilde f'(y) = -f'(2a-y)$ and $\tilde g'(y) = -g'(2a-y)$, so $\tilde f'/\tilde g'$ equals $f'/g'$ evaluated at $x = 2a-y$, and $y \to a+$ corresponds to $x \to a-$. A two-sided limit is obtained by applying both one-sided versions.

For $x \to +\infty$, substitute $t = 1/x$. With $F(t) = f(1/t)$ and $G(t) = g(1/t)$ we get $F'(t)/G'(t) = f'(1/t)/g'(1/t)$ (the factors $-1/t^2$ cancel), reducing to the case $t \to 0+$. The same conclusions hold when $L = \pm\infty$ and for the indeterminate form $\infty/\infty$, in which numerator and denominator both diverge to $\pm\infty$; but the proof for $\infty/\infty$ requires a different argument, since the trick of Step 0 — extending continuously — is unavailable. A unified proof may be found in Chapter 5 of Rudin's *Principles of Mathematical Analysis*.
</Remark>

<Example id="ex-lhopital-computations" title="Three indeterminate limits">
All three limits below are two-sided, so following <Ref to="rem-lhopital-variants" /> we apply <Ref to="thm-lhopital" /> separately on each side (the computation is the same on both sides, so we do not distinguish them in what follows).

**(1) $\displaystyle \lim_{x\to 0} \frac{1 - \cos x}{x^2}$.** Put $f(x) = 1-\cos x$ and $g(x) = x^2$. For $x \ne 0$ we have $g'(x) = 2x \ne 0$, and $f, g \to 0$ as $x \to 0$. Now
$$
\frac{f'(x)}{g'(x)} = \frac{\sin x}{2x}
$$
is again of the form $0/0$, so we apply the theorem once more with $f_1 = \sin x$ and $g_1 = 2x$. Here $g_1' = 2 \ne 0$, $f_1, g_1 \to 0$, and $f_1'/g_1' = \cos x / 2 \to 1/2$. Hence $\lim_{x\to0} \sin x/(2x) = 1/2$, and one further application of the theorem gives
$$
\lim_{x\to 0}\frac{1-\cos x}{x^2} = \frac{1}{2} .
$$
As a numerical check, at $x = 0.1$ we get $(1 - 0.99500417)/0.01 = 0.4995\ldots$, close to $1/2$.

**(2) $\displaystyle \lim_{x \to 0}\frac{x - \sin x}{x^3}$.** We differentiate numerator and denominator three times, obtaining $\dfrac{1 - \cos x}{3x^2}$, then $\dfrac{\sin x}{6x}$, then $\dfrac{\cos x}{6}$. At each stage, check that numerator and denominator both tend to $0$ as $x \to 0$ (this holds for $1 - \cos x$, $3x^2$, $\sin x$ and $6x$) and that the derivatives of the denominators, namely $3x^2$, $6x$ and $6$, are nonzero for $x \ne 0$. The last expression $\cos x/6$ tends to $1/6$ as $x \to 0$, so working backwards the limits at each stage are determined in turn, and
$$
\lim_{x\to0}\frac{x - \sin x}{x^3} = \frac{1}{6} .
$$
The actual value at $x = 0.1$ is $(0.1 - 0.09983342)/0.001 = 0.16658\ldots$, close to $1/6 = 0.16666\ldots$.

**(3) $\displaystyle \lim_{x\to 0}\left(\frac{1}{x} - \frac{1}{\sin x}\right)$.** This is of the form $\infty - \infty$, but putting it over a common denominator turns it into $0/0$:
$$
\frac{1}{x} - \frac{1}{\sin x} = \frac{\sin x - x}{x \sin x} .
$$
Numerator and denominator both tend to $0$ as $x \to 0$. The derivative of the denominator is $\sin x + x\cos x$, which is nonzero for $0 < |x| < 1$, since there $x$ and $\sin x$ have the same sign and $\cos x > 0$. One application gives
$$
\frac{\cos x - 1}{\sin x + x \cos x} ,
$$
again of the form $0/0$; the derivative of this denominator is $2\cos x - x \sin x$, which is positive for $|x| < 1$. A second application gives
$$
\frac{-\sin x}{2\cos x - x \sin x} \to \frac{0}{2} = 0 ,
$$
so the limit sought is $0$. This agrees with the rough picture supplied by (2): $\sin x - x$ is of the order of $x^3$ and $x \sin x$ of the order of $x^2$, so the quotient is of the order of $x$ and goes to $0$.
</Example>

<Remark id="rem-lhopital-pitfall" title="Three traps in l'Hôpital's rule">
**Not checking that the form is indeterminate.** We have $\lim_{x\to 0}\dfrac{x+2}{x+1} = 2$, but differentiating numerator and denominator gives $1/1 = 1$. Hypothesis 2 fails, so the theorem does not apply.

**When the limit of $f'/g'$ fails to exist, nothing can be concluded.** Put $f(x) = x^2 \sin(1/x)$ for $x \ne 0$ and $g(x) = x$. From $|f(x)| \le x^2$ we get $f \to 0$ as $x \to 0$; also $g \to 0$ and $g' = 1 \ne 0$. The original quotient is $f(x)/g(x) = x\sin(1/x)$, and $|x \sin(1/x)| \le |x| \to 0$ gives convergence to $0$ by squeezing. Yet
$$
\frac{f'(x)}{g'(x)} = 2x\sin\frac{1}{x} - \cos\frac{1}{x}
$$
approaches $-1$ along $x_n = 1/(2n\pi)$ and $+1$ along $x_n' = 1/((2n+1)\pi)$, so it has no limit. Only hypothesis 3 of the theorem fails; the original limit exists perfectly well. "Not obtainable by l'Hôpital" does not mean "no limit".

**Circular reasoning.** Applying l'Hôpital's rule to $\lim_{x\to0}\dfrac{\sin x}{x}$ to get $\cos x/1 \to 1$ is circular, because the proof that $(\sin)' = \cos$ itself uses the value $1$ of this very limit (<Ref to="mathematics/calculus/derivatives#lem-sinc" text="the fundamental trigonometric limit" />).
</Remark>

## 5. Taylor's theorem

The definition of differentiability can be read as saying that near $a$ the function $f$ is approximated by the affine function
$$
T_1(x) = f(a) + f'(a)(x-a)
$$
with an error that goes to $0$ faster than $|x-a|$ (<Ref to="mathematics/calculus/derivatives#thm-linear-approx" text="differentiability and linear approximation" />). What if we want greater accuracy? Raising the degree and using a quadratic or cubic polynomial is the natural move. Two questions arise: which polynomial should we choose, and how large is the error?

<Definition id="def-taylor-polynomial" title="Taylor polynomial and remainder">
Let $I$ be an open interval, let $a \in I$, and let $f : I \to \mathbb{R}$ be $n$ times differentiable at $a$. The polynomial
$$
T_n(x) = \sum_{k=0}^{n} \frac{f^{(k)}(a)}{k!}(x-a)^k = f(a) + f'(a)(x-a) + \frac{f''(a)}{2!}(x-a)^2 + \cdots + \frac{f^{(n)}(a)}{n!}(x-a)^n
$$
is called the **Taylor polynomial of $f$ of degree $n$ at $a$**. When $a = 0$ it is called a Maclaurin polynomial. Further,
$$
R_n(x) = f(x) - T_n(x)
$$
is called the **remainder of order $n$**.
</Definition>

<Remark id="rem-uniqueness" title="Where the Taylor polynomial comes from">
The polynomial $T_n$ is not pulled out of a hat: it is the unique polynomial determined by the following condition. "$P$ is a polynomial of degree at most $n$ satisfying $P^{(j)}(a) = f^{(j)}(a)$ for $j = 0,1,\ldots,n$."

First, $T_n$ satisfies this condition. Differentiating $(x-a)^k$ $j$ times and substituting $x = a$ gives $0$ when $j < k$ (a positive power of $x-a$ survives), $k!$ when $j = k$, and $0$ when $j > k$. Hence $T_n^{(j)}(a) = f^{(j)}(a) \cdot j!/j! = f^{(j)}(a)$.

Next, uniqueness. Let $P$ be another polynomial satisfying the condition and put $Q = T_n - P$, so that $\deg Q \le n$ and $Q^{(j)}(a) = 0$ for $j = 0,\ldots,n$. Writing $Q$ in powers of $x - a$ as $Q(x) = \sum_{k=0}^{n} b_k (x-a)^k$ (substituting $x = (x-a) + a$ and expanding puts it in this form), the same computation gives $Q^{(j)}(a) = j!\, b_j$, so $b_j = 0$ for every $j$, that is, $Q \equiv 0$ and $P = T_n$.
</Remark>

<Theorem id="thm-taylor" title="Taylor's theorem (Lagrange remainder)">
Let $I$ be an open interval, let $a \in I$, let $n \ge 0$ be an integer, and let $f : I \to \mathbb{R}$ be $n+1$ times differentiable on $I$. Then for every $x \in I$ with $x \ne a$ there exists a real number $c$ strictly between $a$ and $x$ (that is, $a < c < x$ or $x < c < a$) such that
$$
f(x) = \sum_{k=0}^{n} \frac{f^{(k)}(a)}{k!}(x-a)^k + \frac{f^{(n+1)}(c)}{(n+1)!}(x-a)^{n+1} .
$$
The last term is called the Lagrange remainder.
</Theorem>

Taking $n = 0$, the assertion reads $f(x) = f(a) + f'(c)(x-a)$, which is exactly <Ref to="thm-mvt" />. Taylor's theorem is the higher-order version of the mean value theorem, and its proof likewise reduces to the mean value theorem (in Cauchy's form).

<Proof of="thm-taylor">
We treat the case $a < x$ (for $x < a$, read $[x,a]$ everywhere in place of $[a,x]$; the same argument goes through verbatim).

As functions of $t \in [a,x]$, put
$$
F(t) = f(x) - \sum_{k=0}^{n} \frac{f^{(k)}(t)}{k!}(x-t)^k, \qquad G(t) = (x-t)^{n+1} .
$$
Since $f$ is $n+1$ times differentiable on $I$, each of $f^{(0)}, \ldots, f^{(n)}$ is differentiable and hence continuous. Therefore $F$ and $G$ are continuous on $[a,x]$ and differentiable on $(a,x)$.

We compute $F'$. By the product rule,
$$
\frac{d}{dt}\left[\frac{f^{(k)}(t)}{k!}(x-t)^k\right] = \frac{f^{(k+1)}(t)}{k!}(x-t)^k - \frac{f^{(k)}(t)}{(k-1)!}(x-t)^{k-1}
$$
(for $k = 0$ the second term is absent and only $f'(t)$ remains). Summing over $k = 0$ to $n$, the $k$-th first term cancels against the $(k+1)$-st second term, leaving
$$
\frac{d}{dt}\sum_{k=0}^{n} \frac{f^{(k)}(t)}{k!}(x-t)^k = \frac{f^{(n+1)}(t)}{n!}(x-t)^{n} .
$$
Hence
$$
F'(t) = -\frac{f^{(n+1)}(t)}{n!}(x-t)^{n}, \qquad G'(t) = -(n+1)(x-t)^{n} .
$$
For $t \in (a,x)$ we have $x - t > 0$, so $G'(t) \ne 0$, and the second part of <Ref to="thm-cauchy-mvt" /> applies to $F, G$ on $[a,x]$. Thus for some $c \in (a,x)$,
$$
\frac{F(x) - F(a)}{G(x) - G(a)} = \frac{F'(c)}{G'(c)} .
$$
Computing the left-hand side: $F(x) = f(x) - f(x) = 0$, $G(x) = 0$, $F(a) = f(x) - T_n(x) = R_n(x)$ and $G(a) = (x-a)^{n+1}$, so it equals
$$
\frac{0 - R_n(x)}{0 - (x-a)^{n+1}} = \frac{R_n(x)}{(x-a)^{n+1}} .
$$
On the right-hand side the factor $(x-c)^n \ne 0$ cancels and
$$
\frac{F'(c)}{G'(c)} = \frac{-f^{(n+1)}(c)(x-c)^n/n!}{-(n+1)(x-c)^n} = \frac{f^{(n+1)}(c)}{(n+1)!}
$$
(we used $n! \cdot (n+1) = (n+1)!$). Equating the two and multiplying by $(x-a)^{n+1}$ gives
$$
R_n(x) = \frac{f^{(n+1)}(c)}{(n+1)!}(x-a)^{n+1} ,
$$
and the assertion follows from $f(x) = T_n(x) + R_n(x)$.
</Proof>

<Aside type="tip">
The way this is used in practice is fixed. Find a constant $M$ with $|f^{(n+1)}(t)| \le M$ on an interval $J$, and estimate
$$
|R_n(x)| \le \frac{M}{(n+1)!}|x-a|^{n+1} .
$$
The exact location of the $c$ supplied by the theorem is unknown, and that is no obstacle. There is no need to know it.
</Aside>

<Definition id="def-landau-o" title="Landau's little-o notation">
Let $\varphi, \psi$ be functions defined on a punctured neighborhood of $a$, with $\psi$ nonvanishing near $a$. If
$$
\lim_{x \to a} \frac{\varphi(x)}{\psi(x)} = 0 ,
$$
we write $\varphi(x) = o(\psi(x))\ (x \to a)$. It means that $\varphi$ becomes small strictly faster than $\psi$.
</Definition>

<Remark id="rem-peano" title="The Peano form of the remainder">
Let $n \ge 1$ and let $f$ be of class $C^n$ on an open interval containing $a$. Then
$$
f(x) = T_n(x) + o\bigl((x-a)^n\bigr) \qquad (x \to a) .
$$
Applying <Ref to="thm-taylor" /> with $n-1$ in place of $n$, there is a point $c_x$ between $a$ and $x$ with
$$
f(x) = T_{n-1}(x) + \frac{f^{(n)}(c_x)}{n!}(x-a)^n = T_n(x) + \frac{f^{(n)}(c_x) - f^{(n)}(a)}{n!}(x-a)^n .
$$
As $x \to a$, the point $c_x$ lies between $a$ and $x$, so $c_x \to a$, and continuity of $f^{(n)}$ gives $f^{(n)}(c_x) - f^{(n)}(a) \to 0$. Hence the last term divided by $(x-a)^n$ converges to $0$, which is $o((x-a)^n)$ in the sense of <Ref to="def-landau-o" />.

The Lagrange form is convenient when we want to pin the size of the error down to a concrete number, the Peano form when we only need to match orders in a limit computation. For instance, part (2) of <Ref to="ex-lhopital-computations" /> becomes a one-liner from $\sin x = x - x^3/6 + o(x^3)$:
$$
\frac{x - \sin x}{x^3} = \frac{x^3/6 + o(x^3)}{x^3} \to \frac{1}{6} .
$$
</Remark>

## 6. Maclaurin expansions of the basic functions

In what follows we compute $T_n$ and $R_n$ with $a = 0$. In each example the procedure to check is the same. (i) Compute $f^{(k)}(0)$ and write down $T_n$. (ii) Estimate $f^{(n+1)}$ and bound $|R_n(x)|$. (iii) Determine the range of $x$ for which $R_n(x) \to 0$ as $n \to \infty$.

### 6.1. The exponential function

<Example id="ex-exp-maclaurin" title="The Maclaurin expansion of e^x">
For $f(x) = e^x$ we have $f^{(k)}(x) = e^x$ for every $k$, hence $f^{(k)}(0) = 1$. Therefore
$$
T_n(x) = \sum_{k=0}^{n} \frac{x^k}{k!} = 1 + x + \frac{x^2}{2!} + \cdots + \frac{x^n}{n!} .
$$
By <Ref to="thm-taylor" />, for some $c$ between $0$ and $x$ we have $R_n(x) = e^{c}x^{n+1}/(n+1)!$. Since $c$ lies between $0$ and $x$ we have $c \le |x|$, and since $e^t$ is strictly increasing (because $(e^t)' = e^t > 0$ and <Ref to="cor-monotonicity" />), it follows that $e^c \le e^{|x|}$. Hence
$$
|R_n(x)| \le e^{|x|}\,\frac{|x|^{n+1}}{(n+1)!} .
$$

Now fix $x$ and let us show that $a_n = |x|^{n+1}/(n+1)!$ tends to $0$. Choose a natural number $N$ with $N \ge 2|x|$. For $n \ge N$,
$$
\frac{a_{n+1}}{a_n} = \frac{|x|}{n+2} \le \frac{|x|}{N+2} < \frac{1}{2} .
$$
Consequently $a_n \le a_N (1/2)^{n-N}$ for $n \ge N$, and the right-hand side tends to $0$ as $n \to \infty$. Since $a_n \ge 0$, squeezing gives $a_n \to 0$ and therefore $R_n(x) \to 0$. As $x$ was arbitrary, for every real $x$
$$
e^x = \sum_{k=0}^{\infty}\frac{x^k}{k!} .
$$

**Numerical check.** Taking $x = 1$ and $n = 7$,
$$
T_7(1) = 1 + 1 + 0.5 + 0.1666667 + 0.0416667 + 0.0083333 + 0.0013889 + 0.0001984 = 2.7182540 .
$$
The error bound is $|R_7(1)| \le e^{1}/8! < 3/40320 = 7.44 \times 10^{-5}$. The difference from the true value $e = 2.7182818\ldots$ is $2.79 \times 10^{-5}$, comfortably inside the bound.
</Example>

### 6.2. The sine function

<Example id="ex-sin-maclaurin" title="The Maclaurin expansion of sin x">
The derivatives of $f(x) = \sin x$ cycle with period $4$ as $\cos x, -\sin x, -\cos x, \sin x$. Their values at $x = 0$ repeat as $0, 1, 0, -1$, so all even-order terms vanish and
$$
T_{2m+1}(x) = \sum_{j=0}^{m}\frac{(-1)^j}{(2j+1)!}x^{2j+1} = x - \frac{x^3}{3!} + \frac{x^5}{5!} - \cdots .
$$
Since $f^{(n+1)}$ is one of $\pm\sin$ or $\pm\cos$, we have $|f^{(n+1)}(t)| \le 1$ for every $t$. Hence <Ref to="thm-taylor" /> gives
$$
|R_n(x)| \le \frac{|x|^{n+1}}{(n+1)!} ,
$$
and as shown in <Ref to="ex-exp-maclaurin" /> the right-hand side tends to $0$ as $n \to \infty$ for each $x$. Therefore, for every real $x$,
$$
\sin x = \sum_{j=0}^{\infty}\frac{(-1)^j}{(2j+1)!}x^{2j+1} .
$$

**Numerical check.** Approximating $\sin(0.1)$ by $T_3(x) = x - x^3/6$ gives
$$
T_3(0.1) = 0.1 - \frac{0.001}{6} = 0.0998333333 .
$$
Here the error estimate admits a refinement. The coefficient of $x^4$ is $0$, so $T_3 = T_4$, and it pays to estimate with $n = 4$:
$$
|R_4(0.1)| \le \frac{0.1^5}{5!} = \frac{10^{-5}}{120} = 8.33\times 10^{-8} .
$$
Indeed $\sin(0.1) = 0.0998334166\ldots$, so the error is $8.33 \times 10^{-8}$, agreeing with the bound down to the digits. Raising $n$ up to the next degree whose coefficient vanishes in order to improve the bound is a standard practical device.
</Example>

### 6.3. The logarithm

<Example id="ex-log-maclaurin" title="The Maclaurin expansion of log(1+x)">
Consider $f(x) = \log(1+x)$ on $(-1, \infty)$. We have $f'(x) = (1+x)^{-1}$, and inductively
$$
f^{(k)}(x) = \frac{(-1)^{k-1}(k-1)!}{(1+x)^{k}} \qquad (k \ge 1)
$$
(the case $k = 1$ is correct, and differentiating both sides gives $(-1)^{k-1}(k-1)!\cdot(-k)(1+x)^{-k-1} = (-1)^{k}k!(1+x)^{-(k+1)}$, which is the case $k+1$). Hence $f(0) = 0$ and $f^{(k)}(0) = (-1)^{k-1}(k-1)!$, so
$$
T_n(x) = \sum_{k=1}^{n}\frac{(-1)^{k-1}(k-1)!}{k!}x^k = x - \frac{x^2}{2} + \frac{x^3}{3} - \cdots + \frac{(-1)^{n-1}}{n}x^n .
$$
The remainder, with some $c$ between $0$ and $x$, is
$$
R_n(x) = \frac{f^{(n+1)}(c)}{(n+1)!}x^{n+1} = \frac{(-1)^{n}n!}{(1+c)^{n+1}(n+1)!}x^{n+1} = \frac{(-1)^n}{n+1}\left(\frac{x}{1+c}\right)^{n+1} .
$$
This is where the cases part company.

**For $0 \le x \le 1$.** From $0 < c < x$ we get $1 + c > 1$, hence $|x/(1+c)| < x \le 1$ and therefore
$$
|R_n(x)| \le \frac{1}{n+1} \to 0 .
$$
Note that this holds at $x = 1$ as well.

**For $-1/2 \le x < 0$.** From $x < c < 0$ we get $1 + c > 1 + x \ge 1/2 > 0$, so
$$
\left|\frac{x}{1+c}\right| < \frac{|x|}{1+x} \le \frac{1/2}{1/2} = 1 ,
$$
and again $|R_n(x)| \le 1/(n+1) \to 0$.

**For $-1 < x < -1/2$.** If $c$ is close to $x$, then $1 + c$ becomes arbitrarily small and $|x/(1+c)|$ exceeds $1$. Putting $q = |x|/(1+x) > 1$, the estimate above becomes $q^{n+1}/(n+1) \to \infty$ and is useless. The Lagrange form of the remainder simply cannot handle this range. The conclusion itself is nevertheless correct: using the integral form of the remainder from the Appendix, one can show $R_n(x) \to 0$ on all of $-1 < x < 0$.

Altogether,
$$
\log(1+x) = \sum_{k=1}^{\infty}\frac{(-1)^{k-1}}{k}x^{k} \qquad (-1 < x \le 1) .
$$
For $x > 1$ the quantity $|x|^k/k$ does not tend to $0$, so the series itself diverges by <Ref to="mathematics/calculus/series-and-convergence#prop-term-to-zero" text="the vanishing-terms criterion" />.

**Numerical check.** Taking $x = 0.5$ and $n = 4$,
$$
T_4(0.5) = 0.5 - 0.125 + 0.0416667 - 0.015625 = 0.4010417 .
$$
The error bound is $|R_4(0.5)| \le (1/5)(0.5)^5 = 6.25\times10^{-3}$. Indeed $\log 1.5 = 0.4054651\ldots$, so the error is $4.42\times10^{-3}$, within the bound.

Convergence at $x = 1$ is extremely slow. Against $\log 2 = 0.6931\ldots$ we have $T_{10}(1) = 1 - 1/2 + 1/3 - \cdots - 1/10 = 0.6456\ldots$: ten terms get only the first decimal place right, exactly as the bound $|R_n(1)| \le 1/(n+1)$ predicts. Actual numerical work uses faster-converging rearrangements such as $\log\frac{1+y}{1-y} = 2(y + y^3/3 + y^5/5 + \cdots)$.
</Example>

| Function | Maclaurin expansion | Range where it converges to the function |
|---|---|---|
| $e^x$ | $\sum_{k\ge0} x^k/k!$ | all real numbers |
| $\sin x$ | $\sum_{j\ge0}(-1)^j x^{2j+1}/(2j+1)!$ | all real numbers |
| $\log(1+x)$ | $\sum_{k\ge1}(-1)^{k-1}x^k/k$ | $-1 < x \le 1$ |

<Remark id="rem-nonanalytic" title="A convergent series need not converge to the original function">
The function defined by $f(x) = e^{-1/x^2}$ for $x \ne 0$ and $f(0) = 0$ is known to be of class $C^\infty$ on $\mathbb{R}$ with $f^{(k)}(0) = 0$ for every $k$. Its Maclaurin series is then identically $0$ and converges on all of $\mathbb{R}$. But $f(x) > 0$ for $x \ne 0$, so the sum of the series does not agree with $f$. The reason is that the remainder $R_n(x) = f(x)$ does not tend to $0$.

In other words, "the Taylor series converges" and "its sum equals the original function" are two different assertions, and only an estimate of the remainder guarantees the second. For convergence tests for series themselves, see [Series and convergence tests](/mathematics/calculus/series-and-convergence).
</Remark>

## 7. Exercises

<Exercise id="exr-cubic-roots" difficulty="Standard">
Show that $p(x) = x^3 - 3x + 1$ has exactly three distinct real roots. (Use the intermediate value theorem for existence and <Ref to="thm-rolle" /> for the upper bound on the number of roots.)
<Solution>
**There are at least three.** Being a polynomial, $p$ is continuous on $\mathbb{R}$. Computing values,
$$
p(-2) = -8 + 6 + 1 = -1 < 0,\quad p(0) = 1 > 0,\quad p(1) = 1 - 3 + 1 = -1 < 0,\quad p(2) = 8 - 6 + 1 = 3 > 0 .
$$
By the intermediate value theorem, each of $(-2,0)$, $(0,1)$ and $(1,2)$ contains at least one zero of $p$. These intervals are pairwise disjoint, so there are at least three distinct real roots.

**There are not four or more.** Suppose there were four distinct real roots $r_1 < r_2 < r_3 < r_4$. For each $i$ we have $p(r_i) = p(r_{i+1}) = 0$, and $p$ is continuous on $[r_i, r_{i+1}]$ and differentiable on $(r_i,r_{i+1})$, so <Ref to="thm-rolle" /> gives $s_i \in (r_i, r_{i+1})$ with $p'(s_i) = 0$. For $i = 1,2,3$ the resulting points satisfy $s_1 < r_2 < s_2 < r_3 < s_3$ and are therefore distinct, so $p'$ would have at least three distinct zeros. But the zeros of $p'(x) = 3x^2 - 3 = 3(x-1)(x+1)$ are only $x = \pm 1$, two in number — a contradiction.

Hence there are exactly three roots.
</Solution>
</Exercise>

<Exercise id="exr-lhopital-two" difficulty="Standard">
Compute the following limits, verifying at each application that the hypotheses of the theorem are satisfied.

(1) $\displaystyle \lim_{x\to0}\frac{\tan x - x}{x^3}$ 　(2) for a real number $a$, $\displaystyle \lim_{x\to0}(1+ax)^{1/x}$
<Solution>
**(1)** Put $f(x) = \tan x - x$ and $g(x) = x^3$. For $0 < |x| < \pi/2$ both are differentiable, $g'(x) = 3x^2 \ne 0$ for $x \ne 0$, and $f, g \to 0$ as $x \to 0$. Using $(\tan)' = 1/\cos^2$,
$$
f'(x) = \frac{1}{\cos^2 x} - 1 = \frac{1 - \cos^2 x}{\cos^2 x} = \frac{\sin^2 x}{\cos^2 x} = \tan^2 x ,
$$
so
$$
\frac{f'(x)}{g'(x)} = \frac{\tan^2 x}{3x^2} = \frac{1}{3}\left(\frac{\tan x}{x}\right)^2 .
$$
Since $\dfrac{\tan x}{x} = \dfrac{\sin x}{x}\cdot\dfrac{1}{\cos x} \to 1 \cdot 1 = 1$, the product rule for limits gives $f'/g' \to 1/3$. By <Ref to="thm-lhopital" /> (in the two-sided version of <Ref to="rem-lhopital-variants" />),
$$
\lim_{x\to0}\frac{\tan x - x}{x^3} = \frac{1}{3} .
$$

**(2)** If $a = 0$ the value is identically $1$, so assume $a \ne 0$. For $|x|$ small enough we have $1 + ax > 0$, so we may write $(1+ax)^{1/x} = \exp\bigl(\frac{\log(1+ax)}{x}\bigr)$. For the exponent, put $f(x) = \log(1+ax)$ and $g(x) = x$; then $f, g \to 0$ as $x \to 0$, $g' = 1 \ne 0$, and
$$
\frac{f'(x)}{g'(x)} = \frac{a}{1+ax} \to a .
$$
Hence $\log(1+ax)/x \to a$. Since $\exp$ is continuous, the rule for limits of composite functions gives
$$
\lim_{x\to0}(1+ax)^{1/x} = e^{a} .
$$
Taking $a = 1$ yields $\lim_{x\to0}(1+x)^{1/x} = e$, recovering the classical defining formula for $e$.
</Solution>
</Exercise>

<Exercise id="exr-cos-approx" difficulty="Standard">
Find the fourth-degree Maclaurin polynomial of $\cos x$ at $0$ and estimate the error for $|x| \le 0.5$. Then compute the approximate value of $\cos(0.5)$ and compare it with the true value $0.8775825619\ldots$.
<Solution>
For $f(x) = \cos x$ the higher derivatives at $0$ are $f(0) = 1$, $f'(0) = -\sin 0 = 0$, $f''(0) = -\cos 0 = -1$, $f'''(0) = \sin 0 = 0$ and $f^{(4)}(0) = \cos 0 = 1$. Hence
$$
T_4(x) = 1 - \frac{x^2}{2} + \frac{x^4}{24} .
$$
The coefficient of $x^5$ is $f^{(5)}(0) = -\sin 0 = 0$, so $T_4 = T_5$ and it pays to estimate the error with $n = 5$. Since $|f^{(6)}(t)| = |-\cos t| \le 1$, <Ref to="thm-taylor" /> gives
$$
|R_5(x)| \le \frac{|x|^6}{6!} \le \frac{0.5^6}{720} = \frac{0.015625}{720} = 2.17\times10^{-5} \qquad (|x| \le 0.5)
$$
(estimating with $n = 4$ would give $0.5^5/120 = 2.60\times10^{-4}$, a bound looser by one order of magnitude).

The approximate value at $x = 0.5$ is
$$
T_4(0.5) = 1 - \frac{0.25}{2} + \frac{0.0625}{24} = 1 - 0.125 + 0.0026042 = 0.8776042 .
$$
The difference from the true value is $0.8776042 - 0.8775826 = 2.16\times10^{-5}$, just inside the bound $2.17\times10^{-5}$ above. Adding three terms has produced a value correct to four decimal places.
</Solution>
</Exercise>

<Exercise id="exr-average-ratio" difficulty="Hard">
Let $f : [0,\infty) \to \mathbb{R}$ be continuous on $[0,\infty)$ and differentiable at every point of $(0,\infty)$, with $f(0) = 0$ and with $f'$ nondecreasing on $(0,\infty)$. Show that $g(x) = f(x)/x$ is nondecreasing on $(0,\infty)$.
<Solution>
Let $0 < x < y$ be arbitrary.

Since $f$ is continuous on $[0,x]$ and differentiable on $(0,x)$, <Ref to="thm-mvt" /> gives some $c_1 \in (0,x)$ with
$$
f(x) - f(0) = f'(c_1)\,x .
$$
As $f(0) = 0$, this yields $\dfrac{f(x)}{x} = f'(c_1)$.

Similarly, $f$ is continuous on $[x,y]$ and differentiable on $(x,y)$, so for some $c_2 \in (x,y)$
$$
f(y) - f(x) = f'(c_2)\,(y-x) .
$$
Here $c_1 < x < c_2$, and $f'$ is nondecreasing, so $f'(c_1) \le f'(c_2)$. Combining this with $y - x > 0$,
$$
f(y) = f(x) + f'(c_2)(y-x) \ge f(x) + f'(c_1)(y-x) = f(x) + \frac{f(x)}{x}(y-x) = \frac{f(x)}{x}\,y .
$$
Dividing both sides by $y > 0$,
$$
\frac{f(y)}{y} \ge \frac{f(x)}{x} ,
$$
that is, $g(y) \ge g(x)$. Since $0 < x < y$ were arbitrary, $g$ is nondecreasing.

The hypothesis that $f'$ is nondecreasing means that $f$ is convex. This exercise establishes, using nothing but the mean value theorem, the geometrically natural fact that for a convex function through the origin the slope $f(x)/x$ as seen from the origin is increasing.
</Solution>
</Exercise>

## References

- T. Takagi, *Kaiseki Gairon*, revised 3rd ed., Iwanami Shoten, 1983 (in Japanese) — Chapter 2 (Differentiation). The classical treatment running from the mean value theorem to Taylor's formula.
- M. Sugiura, *Kaiseki Nyūmon I*, University of Tokyo Press, 1980 (in Japanese) — Chapter II (Differentiation). The various forms of the remainder (Lagrange, Cauchy, integral) are compared carefully.
- W. Rudin, *Principles of Mathematical Analysis*, 3rd ed., McGraw-Hill, 1976 — Chapter 5 (Differentiation). Contains a proof treating the $0/0$ and $\infty/\infty$ forms of l'Hôpital's rule in a unified way.
- M. Spivak, *Calculus*, 4th ed., Publish or Perish, 2008 — Chapter 20 (Approximation by Polynomial Functions). Several proofs of Taylor's theorem and a discussion of the meaning of the remainder.
- E. Hairer, G. Wanner, *Analysis by Its History*, Springer, 1996 — Chapter II. The historical circumstances in which Taylor expansions and l'Hôpital's rule arose, presented in close contact with the original sources.

## Appendix: The integral form of the remainder

Let us settle the case $-1 < x < -1/2$ left open in <Ref to="ex-log-maclaurin" />. To that end we derive another representation of the remainder. Throughout, $f$ is of class $C^{n+1}$ on an open interval containing $a$ and $x$ (that is, $f^{(n+1)}$ exists and is continuous).

By the fundamental theorem of calculus (<Ref to="mathematics/calculus/integration-and-ftc#thm-ftc2" text="the Newton–Leibniz formula" /> in [The fundamental theorem of calculus and the definite integral](/mathematics/calculus/integration-and-ftc)),
$$
f(x) - f(a) = \int_a^x f'(t)\,dt .
$$
Noting that the function $-(x-t)$ of $t$ is an antiderivative of $1$, <Ref to="mathematics/calculus/integration-and-ftc#thm-by-parts" text="integration by parts" /> gives
$$
\int_a^x f'(t)\,dt = \Bigl[-(x-t)f'(t)\Bigr]_a^x + \int_a^x (x-t)f''(t)\,dt = (x-a)f'(a) + \int_a^x (x-t)f''(t)\,dt .
$$
Repeating the same operation, induction yields
$$
f(x) = \sum_{k=0}^{n}\frac{f^{(k)}(a)}{k!}(x-a)^k + \frac{1}{n!}\int_a^x (x-t)^n f^{(n+1)}(t)\,dt .
$$
The inductive step is the integration by parts
$$
\frac{1}{n!}\int_a^x (x-t)^n f^{(n+1)}(t)\,dt = \frac{f^{(n+1)}(a)}{(n+1)!}(x-a)^{n+1} + \frac{1}{(n+1)!}\int_a^x (x-t)^{n+1}f^{(n+2)}(t)\,dt ,
$$
which uses the fact that $-(x-t)^{n+1}/(n+1)!$ is an antiderivative (in $t$) of $(x-t)^n/n!$. The last integral is the integral form of the remainder.

We apply this to $f(x) = \log(1+x)$ with $a = 0$ and $-1 < x < 0$. Since $f^{(n+1)}(t) = (-1)^n n!/(1+t)^{n+1}$,
$$
R_n(x) = \frac{1}{n!}\int_0^x (x-t)^n \frac{(-1)^n n!}{(1+t)^{n+1}}\,dt = (-1)^n\int_0^x \left(\frac{x-t}{1+t}\right)^n \frac{dt}{1+t} .
$$
For $x < t < 0$ we have $1 + t > 1 + x > 0$, and
$$
\left|\frac{x-t}{1+t}\right| = \frac{t-x}{1+t} \le |x| .
$$
Indeed, this inequality is equivalent to $t - x \le |x|(1+t) = -x(1+t)$, that is, to $t(1+x) \le 0$, which follows from $t \le 0$ and $1 + x > 0$. Therefore
$$
|R_n(x)| \le \int_x^0 |x|^n\frac{dt}{1+t} = |x|^n\bigl[\log(1+t)\bigr]_x^0 = |x|^n\bigl(-\log(1+x)\bigr) .
$$
Since $|x| < 1$ we have $|x|^n \to 0$, and $-\log(1+x)$ is a constant independent of $n$, so $R_n(x) \to 0$. This justifies the expansion on all of $-1 < x < 0$ and completes the assertion of <Ref to="ex-log-maclaurin" />.

The Lagrange form can also be derived from the integral form. If $f^{(n+1)}$ is continuous, then <Ref to="mathematics/calculus/integration-and-ftc#prop-mvt-integral" text="the mean value theorem for integrals" /> applies and, for some $c$ between $a$ and $x$,
$$
\frac{1}{n!}\int_a^x (x-t)^n f^{(n+1)}(t)\,dt = \frac{f^{(n+1)}(c)}{n!}\int_a^x (x-t)^n\,dt = \frac{f^{(n+1)}(c)}{(n+1)!}(x-a)^{n+1} .
$$
Note, however, that the integral form requires continuity of $f^{(n+1)}$, so the hypotheses of <Ref to="thm-taylor" /> are weaker.
