Calculus courses teach the derivative as a set of rules. Analysis asks what the rules rest on. This post defines the derivative as a limit, proves that differentiable functions are continuous, and proves the product and chain rules without the usual gap. The centre of the post is the Mean Value Theorem. It is the one tool that turns information about f′f' into information about ff, and almost every later result depends on it: "zero derivative means constant", L'Hôpital's rule, and Taylor's theorem with a remainder you can actually bound. Along the way you meet functions that break naive intuition: a derivative that exists everywhere but is not continuous, a smooth function whose Taylor series is useless, and a continuous function with no derivative anywhere. It builds on the ε\varepsilon–δ\delta limits, the Extreme Value Theorem and the Intermediate Value Theorem from post 02.

Series map: 00 The Real Numbers & Completeness → 01 Sequences & Series → 02 Topology of ℝ & Continuity → 03 Differentiation & Taylor's Theorem (this post) → 04 The Riemann Integral → 05 Uniform Convergence & Power Series.


Learning Outcome

  • Define the derivative as a limit of difference quotients and compute it from the definition.
  • Prove that a function differentiable at a point is continuous there, and show with ∣x∣\lvert x\rvert that the converse fails.
  • Prove the product rule and the chain rule, using the "linear approximation" form of the derivative to avoid dividing by zero.
  • State and prove the Interior Extremum Theorem, Rolle's Theorem, the Mean Value Theorem and Cauchy's Generalised Mean Value Theorem.
  • Use the Mean Value Theorem to prove "f′=0f' = 0 implies constant", monotonicity tests and numeric inequalities.
  • State and prove Darboux's theorem, and explain why x2sin⁡(1/x)x^2\sin(1/x) matters.
  • Apply L'Hôpital's rule with all of its hypotheses checked.
  • State and prove Taylor's theorem with the Lagrange remainder, and use it to get a proven error bound.
  • Place the smooth non-analytic function e−1/x2e^{-1/x^2} and Weierstrass's nowhere-differentiable function in the hierarchy of smoothness.

Chapter 1 — The derivative as a limit

Terminology

  • Interval — in this post, II always means an interval of R\mathbb{R} with more than one point.
  • Difference quotient — for x≠cx \neq c, the slope of the secant line through (c,f(c))(c, f(c)) and (x,f(x))(x, f(x)), that is f(x)−f(c)x−c\frac{f(x) - f(c)}{x - c}.
  • Derivative at a point — the limit of the difference quotient as x→cx \to c, when that limit exists as a real number.
  • One-sided derivative — the same limit taken only from the right (x→c+x \to c^+) or only from the left. At an endpoint of a closed interval only one side makes sense, and "differentiable at the endpoint" means the one-sided derivative exists.
  • Differentiable on an interval — differentiable at every point of it.
  • Class CkC^k — Ck(I)C^k(I) is the set of functions whose first kk derivatives exist on II and whose kk-th derivative is continuous. C∞C^\infty means derivatives of every order exist.

Definition

Let f:I→Rf : I \to \mathbb{R} and c∈Ic \in I. Then ff is differentiable at cc if the limit

f′(c)=lim⁡x→cf(x)−f(c)x−cf'(c) = \lim_{x \to c} \frac{f(x) - f(c)}{x - c}

exists (as a real number). In ε\varepsilon–δ\delta form: for every ε>0\varepsilon > 0 there is δ>0\delta > 0 such that 0<∣x−c∣<δ0 < \lvert x - c\rvert < \delta and x∈Ix \in I imply

∣f(x)−f(c)x−c−f′(c)∣<ε.\left\lvert \frac{f(x) - f(c)}{x - c} - f'(c) \right\rvert < \varepsilon.

Writing x=c+hx = c + h gives the equivalent form f′(c)=lim⁡h→0f(c+h)−f(c)hf'(c) = \lim_{h \to 0} \frac{f(c+h) - f(c)}{h}.

Worked example. For f(x)=x2f(x) = x^2 and c=3c = 3:

x2−9x−3=x+3(x≠3),sof′(3)=lim⁡x→3(x+3)=6.\frac{x^2 - 9}{x - 3} = x + 3 \quad (x \neq 3), \qquad \text{so} \qquad f'(3) = \lim_{x \to 3} (x + 3) = 6.

The cancellation is legal because the limit never looks at x=3x = 3 itself.

Worked example: the absolute value at 0. For f(x)=∣x∣f(x) = \lvert x\rvert the difference quotient at 00 is ∣x∣x\frac{\lvert x\rvert}{x}, which is 11 for x>0x > 0 and −1-1 for x<0x < 0. The right-hand limit is 11, the left-hand limit is −1-1, so the two-sided limit does not exist. The function ∣x∣\lvert x\rvert is continuous at 0 but not differentiable there. Its graph has a corner.

Differentiable implies continuous

Theorem. If f:I→Rf : I \to \mathbb{R} is differentiable at cc, then ff is continuous at cc.

Proof. For x≠cx \neq c,

f(x)−f(c)=f(x)−f(c)x−c⋅(x−c).f(x) - f(c) = \frac{f(x) - f(c)}{x - c} \cdot (x - c).

As x→cx \to c the first factor tends to f′(c)f'(c) and the second tends to 00. By the product rule for limits (post 01, carried over to functions via sequences in post 02), f(x)−f(c)→f′(c)⋅0=0f(x) - f(c) \to f'(c) \cdot 0 = 0. So lim⁡x→cf(x)=f(c)\lim_{x \to c} f(x) = f(c). ■\blacksquare

The converse is false: ∣x∣\lvert x\rvert is continuous at 0 and not differentiable there. Chapter 7 shows something much stronger: a function can be continuous everywhere and differentiable nowhere.

The linear-approximation form (Carathéodory)

The following reformulation removes every risky division from later proofs.

Lemma. ff is differentiable at cc if and only if there is a function φ:I→R\varphi : I \to \mathbb{R} that is continuous at cc and satisfies

f(x)−f(c)=φ(x) (x−c)for all x∈I.f(x) - f(c) = \varphi(x)\,(x - c) \quad \text{for all } x \in I.

In that case f′(c)=φ(c)f'(c) = \varphi(c).

Proof. If f′(c)f'(c) exists, define φ(x)=f(x)−f(c)x−c\varphi(x) = \frac{f(x) - f(c)}{x - c} for x≠cx \neq c and φ(c)=f′(c)\varphi(c) = f'(c). The identity holds (at x=cx = c both sides are 0) and φ\varphi is continuous at cc by the definition of f′(c)f'(c). Conversely, if such a φ\varphi exists, then for x≠cx \neq c the difference quotient equals φ(x)\varphi(x), which tends to φ(c)\varphi(c). ■\blacksquare

Read it as: near cc, ff changes by "slope times displacement", where the slope φ(x)\varphi(x) is allowed to wobble but settles to f′(c)f'(c).


Chapter 2 — Rules of differentiation

Theorem (algebra of derivatives). Let f,gf, g be differentiable at cc and k∈Rk \in \mathbb{R}. Then

  • (f+g)′(c)=f′(c)+g′(c)(f + g)'(c) = f'(c) + g'(c) and (kf)′(c)=kf′(c)(kf)'(c) = k f'(c);
  • (fg)′(c)=f′(c)g(c)+f(c)g′(c)(fg)'(c) = f'(c)g(c) + f(c)g'(c);
  • if g(c)≠0g(c) \neq 0, then (f/g)′(c)=f′(c)g(c)−f(c)g′(c)g(c)2(f/g)'(c) = \dfrac{f'(c)g(c) - f(c)g'(c)}{g(c)^2}.

Proof of the product rule. Add and subtract f(x)g(c)f(x)g(c):

f(x)g(x)−f(c)g(c)x−c=f(x) g(x)−g(c)x−c+g(c) f(x)−f(c)x−c.\frac{f(x)g(x) - f(c)g(c)}{x - c} = f(x)\,\frac{g(x) - g(c)}{x - c} + g(c)\,\frac{f(x) - f(c)}{x - c}.

As x→cx \to c: f(x)→f(c)f(x) \to f(c) because differentiable implies continuous, and the two quotients tend to g′(c)g'(c) and f′(c)f'(c). ■\blacksquare

The sum rule is immediate from limit laws. For the quotient rule, first prove (1/g)′(c)=−g′(c)/g(c)2(1/g)'(c) = -g'(c)/g(c)^2 (note that g(x)≠0g(x) \neq 0 near cc by continuity), then apply the product rule.

The chain rule, done properly

Theorem (chain rule). Let g:I→Rg : I \to \mathbb{R} be differentiable at cc, let g(I)⊆Jg(I) \subseteq J for an interval JJ, and let f:J→Rf : J \to \mathbb{R} be differentiable at g(c)g(c). Then f∘gf \circ g is differentiable at cc and

(f∘g)′(c)=f′(g(c))⋅g′(c).(f \circ g)'(c) = f'(g(c)) \cdot g'(c).

The tempting wrong proof. Write

f(g(x))−f(g(c))x−c=f(g(x))−f(g(c))g(x)−g(c)⋅g(x)−g(c)x−c\frac{f(g(x)) - f(g(c))}{x - c} = \frac{f(g(x)) - f(g(c))}{g(x) - g(c)} \cdot \frac{g(x) - g(c)}{x - c}

and let x→cx \to c. This breaks whenever g(x)=g(c)g(x) = g(c) for xx arbitrarily close to cc, because then you divide by zero infinitely often. That really happens: g(x)=x2sin⁡(1/x)g(x) = x^2 \sin(1/x) (with g(0)=0g(0) = 0) takes the value 00 at x=1/(nπ)x = 1/(n\pi) for every integer n≥1n \geq 1.

Correct proof. By the lemma, there is ψ\psi continuous at d=g(c)d = g(c) with f(y)−f(d)=ψ(y)(y−d)f(y) - f(d) = \psi(y)(y - d) for all y∈Jy \in J, and ψ(d)=f′(d)\psi(d) = f'(d). There is also φ\varphi continuous at cc with g(x)−g(c)=φ(x)(x−c)g(x) - g(c) = \varphi(x)(x - c) and φ(c)=g′(c)\varphi(c) = g'(c). Put y=g(x)y = g(x):

f(g(x))−f(g(c))=ψ(g(x)) (g(x)−g(c))=ψ(g(x)) φ(x) (x−c).f(g(x)) - f(g(c)) = \psi(g(x))\,\bigl(g(x) - g(c)\bigr) = \psi(g(x))\,\varphi(x)\,(x - c).

The function x↦ψ(g(x))φ(x)x \mapsto \psi(g(x))\varphi(x) is continuous at cc: gg is continuous at cc, ψ\psi is continuous at g(c)g(c), and products of functions continuous at cc are continuous at cc. By the lemma again, f∘gf \circ g is differentiable at cc with derivative ψ(g(c))φ(c)=f′(g(c)) g′(c)\psi(g(c))\varphi(c) = f'(g(c))\,g'(c). ■\blacksquare

No division by g(x)−g(c)g(x) - g(c) appears anywhere.

Trick: whenever a proof wants to divide by something that might be zero, try the Carathéodory form. It turns "limit of a quotient" into "continuity of a factor", and continuity composes cleanly.


Chapter 3 — Extrema, Rolle and the Mean Value Theorem

Interior extremum theorem

Theorem. Let f:(a,b)→Rf : (a, b) \to \mathbb{R} have a maximum (or minimum) at c∈(a,b)c \in (a, b), and let ff be differentiable at cc. Then f′(c)=0f'(c) = 0.

Proof (maximum case). For x>cx > c we have f(x)−f(c)≤0f(x) - f(c) \leq 0 and x−c>0x - c > 0, so the difference quotient is ≤0\leq 0; the right-hand limit gives f′(c)≤0f'(c) \leq 0. For x<cx < c the numerator is ≤0\leq 0 and the denominator <0< 0, so the quotient is ≥0\geq 0; the left-hand limit gives f′(c)≥0f'(c) \geq 0. Hence f′(c)=0f'(c) = 0. ■\blacksquare

Watch out: the point must be interior. f(x)=xf(x) = x on [0,1][0, 1] has its maximum at 11 and f′(1)=1f'(1) = 1. And the converse fails: f(x)=x3f(x) = x^3 has f′(0)=0f'(0) = 0 but no extremum at 00.

Rolle's theorem

Theorem (Rolle). Let ff be continuous on [a,b][a, b] and differentiable on (a,b)(a, b), with f(a)=f(b)f(a) = f(b). Then there is c∈(a,b)c \in (a, b) with f′(c)=0f'(c) = 0.

Proof. By the Extreme Value Theorem (post 02), ff attains a maximum MM and a minimum mm on the compact set [a,b][a, b]. If both are attained only at the endpoints, then M=m=f(a)M = m = f(a) and ff is constant, so f′(c)=0f'(c) = 0 for every c∈(a,b)c \in (a, b). Otherwise one of them is attained at some interior cc, and the interior extremum theorem gives f′(c)=0f'(c) = 0. ■\blacksquare

All three hypotheses matter. Continuity at the endpoints: f(x)=xf(x) = x on [0,1)[0,1) with f(1)=0f(1) = 0. Differentiability inside: ∣x∣\lvert x\rvert on [−1,1][-1, 1]. Equal end values: xx on [0,1][0, 1].

The Mean Value Theorem

Theorem (MVT). Let ff be continuous on [a,b][a, b] and differentiable on (a,b)(a, b). Then there is c∈(a,b)c \in (a, b) with

f′(c)=f(b)−f(a)b−a.f'(c) = \frac{f(b) - f(a)}{b - a}.

Geometrically: somewhere the tangent line is parallel to the secant line through the end points.

Proof. Subtract the secant line. Let

h(x)=f(x)−(f(a)+f(b)−f(a)b−a (x−a)).h(x) = f(x) - \left( f(a) + \frac{f(b) - f(a)}{b - a}\,(x - a) \right).

Then hh is continuous on [a,b][a, b], differentiable on (a,b)(a, b), and h(a)=h(b)=0h(a) = h(b) = 0. Rolle gives c∈(a,b)c \in (a, b) with 0=h′(c)=f′(c)−f(b)−f(a)b−a0 = h'(c) = f'(c) - \frac{f(b) - f(a)}{b - a}. ■\blacksquare

Worked example. f(x)=x3f(x) = x^3 on [0,2][0, 2]. The secant slope is 8−02−0=4\frac{8 - 0}{2 - 0} = 4. Solve f′(c)=3c2=4f'(c) = 3c^2 = 4 in (0,2)(0, 2): c=23≈1.1547c = \frac{2}{\sqrt 3} \approx 1.1547. The theorem only promises that such a cc exists; here you can find it.

Left: the graph of x cubed on 0 to 2 with the secant line of slope 4 and the parallel tangent at c = 2 over root 3, about 1.1547. Right: sin x with its Taylor polynomials of degree 1, 3, 5 and 7 hugging it over a wider and wider range, and the proven error bound at x = 0.1

Consequences

Corollary 1 (zero derivative). If f′(x)=0f'(x) = 0 for every xx in an interval II, then ff is constant on II.

Proof. Take x<yx < y in II. The MVT on [x,y][x, y] gives f(y)−f(x)=f′(c)(y−x)=0f(y) - f(x) = f'(c)(y - x) = 0. ■\blacksquare

The interval matters: f(x)=sign⁡(x)f(x) = \operatorname{sign}(x) on R∖{0}\mathbb{R} \setminus \{0\} has f′=0f' = 0 everywhere on its domain but is not constant, because the domain is not an interval.

Corollary 2 (same derivative). If f′=g′f' = g' on an interval, then f−gf - g is constant. This is why antiderivatives are unique "up to +C+C".

Corollary 3 (monotonicity). On an interval II, with ff differentiable on II:

Hypothesis on the interval Conclusion
f′≥0f' \geq 0 ff is increasing (x<y⇒f(x)≤f(y)x < y \Rightarrow f(x) \leq f(y))
f′>0f' > 0 ff is strictly increasing
f′≤0f' \leq 0 or f′<0f' < 0 decreasing or strictly decreasing
∣f′∣≤M\lvert f'\rvert \leq M ∣f(x)−f(y)∣≤M∣x−y∣\lvert f(x) - f(y)\rvert \leq M\lvert x - y\rvert (Lipschitz)

Each line is one application of f(y)−f(x)=f′(c)(y−x)f(y) - f(x) = f'(c)(y - x). The converse of line 2 fails: x3x^3 is strictly increasing but f′(0)=0f'(0) = 0.

Worked example: a Lipschitz bound. Since ∣cos⁡∣≤1\lvert \cos\rvert \leq 1, the last line gives ∣sin⁡a−sin⁡b∣≤∣a−b∣\lvert \sin a - \sin b\rvert \leq \lvert a - b\rvert for all real a,ba, b.

Worked example: estimating a square root. Apply the MVT to x\sqrt{x} on [100,101][100, 101]: 101−10=12c\sqrt{101} - 10 = \frac{1}{2\sqrt c} for some c∈(100,101)c \in (100, 101). Since 10<c<10110 < \sqrt c < \sqrt{101},

0.04975…=12101<101−10<120=0.05.0.04975\ldots = \frac{1}{2\sqrt{101}} < \sqrt{101} - 10 < \frac{1}{20} = 0.05.

The true value is 101−10=0.049875…\sqrt{101} - 10 = 0.049875\ldots, inside the bracket.

Cauchy's generalised Mean Value Theorem

Theorem (Cauchy MVT). Let f,gf, g be continuous on [a,b][a, b] and differentiable on (a,b)(a, b). Then there is c∈(a,b)c \in (a, b) with

(f(b)−f(a)) g′(c)=(g(b)−g(a)) f′(c).\bigl(f(b) - f(a)\bigr)\,g'(c) = \bigl(g(b) - g(a)\bigr)\,f'(c).

Proof. Let h(x)=(f(b)−f(a))g(x)−(g(b)−g(a))f(x)h(x) = \bigl(f(b) - f(a)\bigr) g(x) - \bigl(g(b) - g(a)\bigr) f(x). A direct computation gives h(a)=f(b)g(a)−g(b)f(a)=h(b)h(a) = f(b)g(a) - g(b)f(a) = h(b). Rolle gives cc with h′(c)=0h'(c) = 0, which is the claim. ■\blacksquare

With g(x)=xg(x) = x this is the ordinary MVT. The version with two functions is what L'Hôpital's rule needs.


Chapter 4 — Derivatives are not arbitrary functions

A derivative that is not continuous

Let

g(x)={x2sin⁡(1/x)x≠0,0x=0.g(x) = \begin{cases} x^2 \sin(1/x) & x \neq 0, \\ 0 & x = 0. \end{cases}

At 00: ∣g(x)−g(0)x∣=∣xsin⁡(1/x)∣≤∣x∣→0\left\lvert \frac{g(x) - g(0)}{x} \right\rvert = \lvert x \sin(1/x)\rvert \leq \lvert x\rvert \to 0, so g′(0)=0g'(0) = 0. For x≠0x \neq 0 the ordinary rules give

g′(x)=2xsin⁡(1/x)−cos⁡(1/x).g'(x) = 2x\sin(1/x) - \cos(1/x).

As x→0x \to 0 the first term tends to 00 but cos⁡(1/x)\cos(1/x) oscillates between −1-1 and 11 for ever. So g′g' exists at every point of R\mathbb{R}, yet lim⁡x→0g′(x)\lim_{x \to 0} g'(x) does not exist. A function can be differentiable everywhere with a discontinuous derivative. In the notation of Chapter 1: gg is differentiable on R\mathbb{R} but g∉C1(R)g \notin C^1(\mathbb{R}).

Darboux's theorem

Discontinuous derivatives still cannot jump. They always have the intermediate value property.

Theorem (Darboux). Let ff be differentiable on [a,b][a, b] (one-sided at the endpoints). If yy lies strictly between f′(a)f'(a) and f′(b)f'(b), then there is c∈(a,b)c \in (a, b) with f′(c)=yf'(c) = y.

Proof. Assume f′(a)<y<f′(b)f'(a) < y < f'(b) (the other case is symmetric). Let g(x)=f(x)−yxg(x) = f(x) - yx. Then gg is differentiable on [a,b][a, b] with g′(a)=f′(a)−y<0g'(a) = f'(a) - y < 0 and g′(b)=f′(b)−y>0g'(b) = f'(b) - y > 0. As a continuous function on [a,b][a, b], gg attains a minimum at some cc (EVT).

  • c≠ac \neq a: since g′(a)<0g'(a) < 0, the quotient g(x)−g(a)x−a\frac{g(x) - g(a)}{x - a} is negative for xx slightly bigger than aa, so g(x)<g(a)g(x) < g(a) there, and aa is not a minimum.
  • c≠bc \neq b: since g′(b)>0g'(b) > 0, the quotient g(x)−g(b)x−b\frac{g(x) - g(b)}{x - b} is positive for xx slightly smaller than bb; the denominator is negative, so g(x)<g(b)g(x) < g(b), and bb is not a minimum.

So c∈(a,b)c \in (a, b) and the interior extremum theorem gives g′(c)=0g'(c) = 0, that is, f′(c)=yf'(c) = y. ■\blacksquare

Note that the proof does not use the Intermediate Value Theorem for f′f', because f′f' need not be continuous.

Consequence. A derivative cannot have a jump discontinuity. For example, there is no differentiable F:R→RF : \mathbb{R} \to \mathbb{R} with F′(x)=sign⁡(x)F'(x) = \operatorname{sign}(x) for all xx: that function takes the values −1-1 and 11 but never 12\tfrac12.

Common pitfall: "has the intermediate value property" does not imply "continuous". The derivative g′g' above has the property (by Darboux) and is discontinuous at 00.


Chapter 5 — L'Hôpital's rule

Theorem (L'Hôpital, zero-over-zero form). Let f,gf, g be differentiable on (a,b)(a, b), with g′(x)≠0g'(x) \neq 0 for all x∈(a,b)x \in (a, b). Suppose

lim⁡x→a+f(x)=0,lim⁡x→a+g(x)=0,lim⁡x→a+f′(x)g′(x)=L,\lim_{x \to a^+} f(x) = 0, \qquad \lim_{x \to a^+} g(x) = 0, \qquad \lim_{x \to a^+} \frac{f'(x)}{g'(x)} = L,

where L∈RL \in \mathbb{R} (the rule also holds for L=±∞L = \pm\infty). Then lim⁡x→a+f(x)g(x)=L\lim_{x \to a^+} \frac{f(x)}{g(x)} = L. The same holds for x→b−x \to b^-, for two-sided limits, and for x→±∞x \to \pm\infty.

Proof (LL finite). Extend ff and gg to [a,b)[a, b) by f(a)=g(a)=0f(a) = g(a) = 0; they are now continuous on [a,x][a, x] for each x∈(a,b)x \in (a, b). By Rolle, g(x)≠0g(x) \neq 0 (otherwise g′=0g' = 0 somewhere in (a,x)(a, x)). Cauchy's MVT on [a,x][a, x] gives cx∈(a,x)c_x \in (a, x) with

f(x)g(x)=f(x)−f(a)g(x)−g(a)=f′(cx)g′(cx).\frac{f(x)}{g(x)} = \frac{f(x) - f(a)}{g(x) - g(a)} = \frac{f'(c_x)}{g'(c_x)}.

Given ε>0\varepsilon > 0, choose δ\delta with ∣f′(t)g′(t)−L∣<ε\left\lvert \frac{f'(t)}{g'(t)} - L \right\rvert < \varepsilon for a<t<a+δa < t < a + \delta. If a<x<a+δa < x < a + \delta then a<cx<a+δa < c_x < a + \delta too, so ∣f(x)g(x)−L∣<ε\left\lvert \frac{f(x)}{g(x)} - L\right\rvert < \varepsilon. ■\blacksquare

The infinity-over-infinity form. The same conclusion holds if instead lim⁡x→a+∣g(x)∣=∞\lim_{x \to a^+} \lvert g(x)\rvert = \infty (nothing more is needed about ff). The proof is a little longer; see Rudin, Theorem 5.13.

Worked example. Find lim⁡x→0x−sin⁡xx3\lim_{x \to 0} \frac{x - \sin x}{x^3}.

  1. f(x)=x−sin⁡xf(x) = x - \sin x and g(x)=x3g(x) = x^3 both tend to 00; the quotient of derivatives is 1−cos⁡x3x2\frac{1 - \cos x}{3x^2}, still of the form 0/00/0.
  2. Differentiate again: sin⁡x6x\frac{\sin x}{6x}, still 0/00/0.
  3. Once more: cos⁡x6→16\frac{\cos x}{6} \to \frac16.

Reading the chain backwards, each step's hypotheses hold near 00: the denominators x3x^3, 3x23x^2, 6x6x have derivatives 3x23x^2, 6x6x, 66, which are non-zero for x≠0x \neq 0. So

lim⁡x→0x−sin⁡xx3=16.\lim_{x \to 0} \frac{x - \sin x}{x^3} = \frac16.

Common pitfall: the rule goes one way only. With f(x)=x+sin⁡xf(x) = x + \sin x and g(x)=xg(x) = x as x→∞x \to \infty, f/g=1+sin⁡xx→1f/g = 1 + \frac{\sin x}{x} \to 1, but f′/g′=1+cos⁡xf'/g' = 1 + \cos x has no limit. The rule is silent, not wrong: its hypothesis "the limit of f′/g′f'/g' exists" fails.

Watch out: check the 0/00/0 or ∞/∞\infty/\infty form first. lim⁡x→0x+1x+2=12\lim_{x \to 0} \frac{x + 1}{x + 2} = \frac12, but "differentiating" top and bottom gives 11.


Chapter 6 — Taylor's theorem

Taylor polynomials

If ff is nn times differentiable at aa, its Taylor polynomial of degree nn at aa is

Pn(x)=∑k=0nf(k)(a)k!(x−a)k=f(a)+f′(a)(x−a)+⋯+f(n)(a)n!(x−a)n.P_n(x) = \sum_{k=0}^{n} \frac{f^{(k)}(a)}{k!}(x - a)^k = f(a) + f'(a)(x - a) + \dots + \frac{f^{(n)}(a)}{n!}(x - a)^n.

It is the unique polynomial of degree at most nn whose value and first nn derivatives at aa match those of ff. P1P_1 is the tangent line. The remainder is Rn(x)=f(x)−Pn(x)R_n(x) = f(x) - P_n(x). Everything useful about Taylor polynomials is a statement about RnR_n.

The theorem

Theorem (Taylor, Lagrange remainder). Let n≥0n \geq 0. Suppose f(n)f^{(n)} is continuous on [a,b][a, b] and differentiable on (a,b)(a, b). Then there is c∈(a,b)c \in (a, b) with

f(b)=∑k=0nf(k)(a)k!(b−a)k+f(n+1)(c)(n+1)!(b−a)n+1.f(b) = \sum_{k=0}^{n} \frac{f^{(k)}(a)}{k!}(b - a)^k + \frac{f^{(n+1)}(c)}{(n+1)!}(b - a)^{n+1}.

The same holds with b<ab < a (then cc lies between bb and aa). For n=0n = 0 this is exactly the MVT.

Proof. Let PnP_n be the Taylor polynomial at aa and choose the number MM so that

f(b)=Pn(b)+M(b−a)n+1.f(b) = P_n(b) + M(b - a)^{n+1}.

Define g(x)=f(x)−Pn(x)−M(x−a)n+1g(x) = f(x) - P_n(x) - M(x - a)^{n+1} on [a,b][a, b]. Because Pn(k)(a)=f(k)(a)P_n^{(k)}(a) = f^{(k)}(a) for k≤nk \leq n and every derivative of order at most nn of (x−a)n+1(x-a)^{n+1} vanishes at aa,

g(a)=g′(a)=⋯=g(n)(a)=0,g(b)=0.g(a) = g'(a) = \dots = g^{(n)}(a) = 0, \qquad g(b) = 0.

  • Rolle on [a,b][a, b] with g(a)=g(b)=0g(a) = g(b) = 0 gives x1∈(a,b)x_1 \in (a, b) with g′(x1)=0g'(x_1) = 0.
  • Rolle on [a,x1][a, x_1] with g′(a)=g′(x1)=0g'(a) = g'(x_1) = 0 gives x2∈(a,x1)x_2 \in (a, x_1) with g′′(x2)=0g''(x_2) = 0.
  • Continue: after n+1n + 1 steps you have xn+1∈(a,b)x_{n+1} \in (a, b) with g(n+1)(xn+1)=0g^{(n+1)}(x_{n+1}) = 0.

(The hypotheses let each step apply Rolle: g(k)g^{(k)} is continuous on [a,b][a, b] and differentiable on (a,b)(a, b) for every k≤nk \leq n.) Since PnP_n has degree at most nn, Pn(n+1)=0P_n^{(n+1)} = 0, and the (n+1)(n+1)-th derivative of M(x−a)n+1M(x - a)^{n+1} is (n+1)! M(n+1)!\,M. So 0=f(n+1)(xn+1)−(n+1)! M0 = f^{(n+1)}(x_{n+1}) - (n+1)!\,M. With c=xn+1c = x_{n+1}, M=f(n+1)(c)(n+1)!M = \frac{f^{(n+1)}(c)}{(n+1)!}, which is the claim. ■\blacksquare

The error bound you actually use. If ∣f(n+1)(t)∣≤K\lvert f^{(n+1)}(t)\rvert \leq K for all tt between aa and xx, then

∣f(x)−Pn(x)∣≤K(n+1)! ∣x−a∣n+1.\lvert f(x) - P_n(x)\rvert \leq \frac{K}{(n+1)!}\,\lvert x - a\rvert^{n+1}.

Worked example 1: the number e

Take f(x)=exf(x) = e^x, a=0a = 0, x=1x = 1. Every derivative is exe^x, so Pn(1)=∑k=0n1k!P_n(1) = \sum_{k=0}^{n} \frac{1}{k!} and

e−Pn(1)=ec(n+1)!for some c∈(0,1).e - P_n(1) = \frac{e^{c}}{(n+1)!} \quad \text{for some } c \in (0, 1).

You also need a bound on ee that does not use this computation. The standard one is e<3e < 3: expanding (1+1/m)m(1 + 1/m)^m with the binomial theorem shows that every term of the sequence defining ee is at most ∑k=0m1k!\sum_{k=0}^{m} \frac{1}{k!}, and since k!≥2k−1k! \geq 2^{k-1} this is at most 1+1+12+16+(18+116+… )=3512<31 + 1 + \tfrac12 + \tfrac16 + \bigl(\tfrac18 + \tfrac1{16} + \dots\bigr) = \tfrac{35}{12} < 3. With ec<e<3e^c < e < 3 you get 0<e−Pn(1)<3(n+1)!0 < e - P_n(1) < \frac{3}{(n+1)!}.

With n=7n = 7:

P7(1)=1+1+12+16+124+1120+1720+15040=685252=2.718253968…,P_7(1) = 1 + 1 + \tfrac12 + \tfrac16 + \tfrac1{24} + \tfrac1{120} + \tfrac1{720} + \tfrac1{5040} = \frac{685}{252} = 2.718253968\ldots,

and the error is below 38!=340320≈7.44×10−5\frac{3}{8!} = \frac{3}{40320} \approx 7.44 \times 10^{-5}. The true error is e−685252≈2.79×10−5e - \frac{685}{252} \approx 2.79 \times 10^{-5}, inside the bound. The bound is honest: it is proved, not observed.

Worked example 2: sin(0.1) with an almost sharp bound

For f=sin⁡f = \sin at a=0a = 0 the derivatives cycle through sin⁡,cos⁡,−sin⁡,−cos⁡\sin, \cos, -\sin, -\cos, so

sin⁡x=x−x33!+x55!−x77!+…\sin x = x - \frac{x^3}{3!} + \frac{x^5}{5!} - \frac{x^7}{7!} + \dots

The coefficient of x4x^4 is 00, so P3=P4P_3 = P_4. Use the degree-4 remainder, which involves f(5)=cos⁡f^{(5)} = \cos with ∣cos⁡∣≤1\lvert\cos\rvert \leq 1:

∣sin⁡(0.1)−P4(0.1)∣≤(0.1)55!=10−5120≈8.33×10−8.\lvert \sin(0.1) - P_4(0.1)\rvert \leq \frac{(0.1)^5}{5!} = \frac{10^{-5}}{120} \approx 8.33 \times 10^{-8}.

Here P4(0.1)=0.1−0.0016=5996000=0.0998333…P_4(0.1) = 0.1 - \frac{0.001}{6} = \frac{599}{6000} = 0.0998333\ldots, while sin⁡(0.1)=0.0998334166…\sin(0.1) = 0.0998334166\ldots. The actual error is 8.3313×10−88.3313 \times 10^{-8}, just under the bound 8.3333×10−88.3333 \times 10^{-8}.

Trick: when the next Taylor coefficient is zero, the degree-nn polynomial equals the degree-(n+1)(n+1) one, and you may use the smaller, higher-order remainder. For sin⁡\sin and cos⁡\cos this gains a whole power of xx for free.

Watch out: the bound needs KK to bound f(n+1)f^{(n+1)} on the whole interval between aa and xx, not just at aa. For exe^x on [0,1][0, 1] that is why you need e<3e < 3 first.


Chapter 7 — Smooth, analytic, and the monsters

Smooth but not analytic

Let

f(x)={e−1/x2x≠0,0x=0.f(x) = \begin{cases} e^{-1/x^2} & x \neq 0, \\ 0 & x = 0. \end{cases}

Claim. ff is C∞C^\infty on R\mathbb{R} and f(k)(0)=0f^{(k)}(0) = 0 for every k≥0k \geq 0.

Sketch of proof. For x≠0x \neq 0, induction shows f(k)(x)=pk(1/x) e−1/x2f^{(k)}(x) = p_k(1/x)\,e^{-1/x^2} for some polynomial pkp_k. At 00, use the definition and induction: f(k)(x)−0x=1xpk(1/x)e−1/x2\frac{f^{(k)}(x) - 0}{x} = \frac1x p_k(1/x) e^{-1/x^2}, and with t=1/xt = 1/x this is a polynomial in tt times e−t2e^{-t^2}, which tends to 00 as ∣t∣→∞\lvert t\rvert \to \infty because et2e^{t^2} outgrows every power of tt. So f(k+1)(0)=0f^{(k+1)}(0) = 0. ■\blacksquare

Consequently every Taylor polynomial of ff at 00 is the zero polynomial, and Rn(x)=f(x)>0R_n(x) = f(x) > 0 for every x≠0x \neq 0 and every nn. The Taylor series at 00 converges everywhere, to the wrong function. So "infinitely differentiable" does not imply "equal to its Taylor series". A function that equals its Taylor series near each point is called (real) analytic; this ff is smooth but not analytic at 00. Taylor's theorem is not wrong here: it only claims the remainder has the Lagrange form, and here the remainder simply does not go to 00. Post 05 returns to this with power series.

Continuous but nowhere differentiable

Theorem (Weierstrass, 1872). Let 0<a<10 < a < 1, let bb be an odd positive integer, and let ab>1+3π2ab > 1 + \frac{3\pi}{2}. Then

W(x)=∑n=0∞ancos⁡(bnπx)W(x) = \sum_{n=0}^{\infty} a^n \cos(b^n \pi x)

is continuous at every x∈Rx \in \mathbb{R} and differentiable at no x∈Rx \in \mathbb{R}.

For example, a=12a = \frac12, b=13b = 13 gives ab=6.5>1+3π2≈5.712ab = 6.5 > 1 + \frac{3\pi}{2} \approx 5.712. Continuity comes from the Weierstrass M-test of post 05: ∣ancos⁡(bnπx)∣≤an\lvert a^n \cos(b^n \pi x)\rvert \leq a^n and ∑an\sum a^n converges, so the series converges uniformly, and uniform limits of continuous functions are continuous. The non-differentiability proof is a careful estimate of difference quotients (Hardy showed in 1916 that ab≥1ab \geq 1 is enough). The picture to keep: the graph has corners at every scale, like ∣x∣\lvert x\rvert at 00, but everywhere.

The hierarchy

Class Example that is in this class but not the next
continuous ∣x∣\lvert x\rvert (not differentiable at 0)
differentiable x2sin⁡(1/x)x^2\sin(1/x) (derivative not continuous at 0)
C1C^1 x∣x∣x\lvert x\rvert (derivative 2∣x∣2\lvert x\rvert, not differentiable at 0)
C∞C^\infty e−1/x2e^{-1/x^2} (not analytic at 0)
analytic sin⁡x\sin x, exe^x, polynomials

Each row is strictly larger than the next. Weierstrass's WW sits in row 1 and is as far from row 2 as possible.


Practice Exercises

Exercise 1. Show that f(x)=x∣x∣f(x) = x\lvert x\rvert is differentiable on R\mathbb{R} with f′(x)=2∣x∣f'(x) = 2\lvert x\rvert, and that f′f' is not differentiable at 00.

Solution

For x>0x > 0, f(x)=x2f(x) = x^2 so f′(x)=2xf'(x) = 2x; for x<0x < 0, f(x)=−x2f(x) = -x^2 so f′(x)=−2xf'(x) = -2x. At 00: f(x)−f(0)x=∣x∣→0\frac{f(x) - f(0)}{x} = \lvert x\rvert \to 0, so f′(0)=0f'(0) = 0. In all cases f′(x)=2∣x∣f'(x) = 2\lvert x\rvert. Then f′=2∣x∣f' = 2\lvert x\rvert has a corner at 00 (difference quotients ±2\pm 2), so f′′(0)f''(0) does not exist. So f∈C1(R)f \in C^1(\mathbb{R}) but ff is not twice differentiable.

Exercise 2. Find the point cc promised by the MVT for f(x)=xf(x) = \sqrt{x} on [1,4][1, 4].

Solution

Secant slope 4−14−1=13\frac{\sqrt4 - \sqrt1}{4 - 1} = \frac13. Solve f′(c)=12c=13f'(c) = \frac{1}{2\sqrt c} = \frac13: c=32\sqrt c = \frac32, so c=94=2.25c = \frac94 = 2.25, which lies in (1,4)(1, 4).

Exercise 3. Prove that ln⁡(1+x)<x\ln(1 + x) < x for every x>0x > 0.

Solution

Apply the MVT to ln⁡(1+t)\ln(1 + t) on [0,x][0, x]: ln⁡(1+x)−ln⁡1=11+c x\ln(1 + x) - \ln 1 = \frac{1}{1 + c}\,x for some c∈(0,x)c \in (0, x). Since c>0c > 0, 11+c<1\frac{1}{1 + c} < 1, so ln⁡(1+x)<x\ln(1 + x) < x.

Exercise 4. Compute lim⁡x→01−cos⁡xx2\lim_{x \to 0} \frac{1 - \cos x}{x^2} with L'Hôpital's rule, checking the hypotheses.

Solution

Both 1−cos⁡x1 - \cos x and x2x^2 tend to 00, both are differentiable, and (x2)′=2x≠0(x^2)' = 2x \neq 0 for x≠0x \neq 0. The quotient of derivatives is sin⁡x2x→12\frac{\sin x}{2x} \to \frac12 (using sin⁡xx→1\frac{\sin x}{x} \to 1, or one more application of the rule). So the limit is 12\frac12.

Exercise 5. Approximate 1.1\sqrt{1.1} by the degree-2 Taylor polynomial of 1+x\sqrt{1 + x} at 00, and prove an error bound.

Solution

f(x)=(1+x)1/2f(x) = (1 + x)^{1/2} gives f(0)=1f(0) = 1, f′(0)=12f'(0) = \frac12, f′′(0)=−14f''(0) = -\frac14, so P2(x)=1+x2−x28P_2(x) = 1 + \frac{x}{2} - \frac{x^2}{8} and P2(0.1)=1+0.05−0.00125=1.04875P_2(0.1) = 1 + 0.05 - 0.00125 = 1.04875. The third derivative is f′′′(t)=38(1+t)−5/2f'''(t) = \frac38 (1 + t)^{-5/2}, which is at most 38\frac38 for t∈(0,0.1)t \in (0, 0.1). So

∣1.1−1.04875∣≤3/83!(0.1)3=116000=6.25×10−5.\lvert \sqrt{1.1} - 1.04875\rvert \leq \frac{3/8}{3!}(0.1)^3 = \frac{1}{16000} = 6.25 \times 10^{-5}.

Check: 1.1=1.0488088…\sqrt{1.1} = 1.0488088\ldots, an error of about 5.88×10−55.88 \times 10^{-5}. Since f′′′>0f''' > 0 the remainder is positive, so 1.048751.04875 is an underestimate.

Exercise 6. Suppose f:R→Rf : \mathbb{R} \to \mathbb{R} satisfies ∣f(x)−f(y)∣≤(x−y)2\lvert f(x) - f(y)\rvert \leq (x - y)^2 for all x,yx, y. Prove that ff is constant.

Solution

For x≠yx \neq y, ∣f(x)−f(y)x−y∣≤∣x−y∣\left\lvert \frac{f(x) - f(y)}{x - y}\right\rvert \leq \lvert x - y\rvert. Letting x→yx \to y gives f′(y)=0f'(y) = 0 for every yy. By Corollary 1 of the MVT on the interval R\mathbb{R}, ff is constant.

Exercise 7. Can the floor function ⌊x⌋\lfloor x \rfloor be the derivative of some function FF on [0,2][0, 2]?

Solution

No. On [0,2][0, 2] the floor function takes the values 00, 11 and 22 but never 12\frac12. If F′=⌊x⌋F' = \lfloor x \rfloor on [0,2][0, 2], Darboux's theorem on [0,1][0, 1] (where F′(0)=0F'(0) = 0 and F′(1)=1F'(1) = 1) would give cc with F′(c)=12F'(c) = \frac12. Contradiction.


Cheat-sheet

Result Hypotheses Conclusion
Differentiable ⇒ continuous f′(c)f'(c) exists ff continuous at cc
Carathéodory form f′(c)f'(c) exists f(x)−f(c)=φ(x)(x−c)f(x) - f(c) = \varphi(x)(x - c), φ\varphi continuous at cc
Chain rule g′(c)g'(c) and f′(g(c))f'(g(c)) exist (f∘g)′(c)=f′(g(c))g′(c)(f\circ g)'(c) = f'(g(c))g'(c)
Interior extremum max or min at interior cc, f′(c)f'(c) exists f′(c)=0f'(c) = 0
Rolle continuous on [a,b][a,b], diff. on (a,b)(a,b), f(a)=f(b)f(a) = f(b) some f′(c)=0f'(c) = 0
MVT continuous on [a,b][a,b], diff. on (a,b)(a,b) f(b)−f(a)=f′(c)(b−a)f(b) - f(a) = f'(c)(b - a)
Cauchy MVT same, for ff and gg (f(b)−f(a))g′(c)=(g(b)−g(a))f′(c)(f(b) - f(a))g'(c) = (g(b) - g(a))f'(c)
Darboux diff. on [a,b][a,b] f′f' has the intermediate value property
L'Hôpital 0/00/0 or ∞/∞\infty/\infty, g′≠0g' \neq 0, f′/g′→Lf'/g' \to L f/g→Lf/g \to L
Taylor (Lagrange) f(n)f^{(n)} continuous on [a,b][a,b], diff. on (a,b)(a,b) Rn=f(n+1)(c)(n+1)!(b−a)n+1R_n = \frac{f^{(n+1)}(c)}{(n+1)!}(b - a)^{n+1}
Error bound ∣f(n+1)∣≤K\lvert f^{(n+1)}\rvert \leq K between aa and xx ∣Rn(x)∣≤K(n+1)!∣x−a∣n+1\lvert R_n(x)\rvert \leq \frac{K}{(n+1)!}\lvert x - a\rvert^{n+1}
Smooth but not analytic e−1/x2e^{-1/x^2} all f(k)(0)=0f^{(k)}(0) = 0, Taylor series is 00

What's next

Post 04 builds the Riemann integral from scratch: partitions, upper and lower Darboux sums, the Riemann criterion, and proofs that continuous and monotone functions are integrable. The Mean Value Theorem from this post is the engine of the proof of the Fundamental Theorem of Calculus there, and a relative of x2sin⁡(1/x)x^2\sin(1/x) returns as a warning about what that theorem needs.


References

  • Stephen Abbott, Understanding Analysis, 2nd ed., Springer (Undergraduate Texts in Mathematics), 2015 — Chapter 5, "The Derivative", including Darboux's theorem and a continuous nowhere-differentiable function.
  • Walter Rudin, Principles of Mathematical Analysis, 3rd ed., McGraw-Hill, 1976 — Chapter 5 (Theorems 5.10 MVT, 5.12 Darboux, 5.13 L'Hôpital, 5.15 Taylor).
  • Robert G. Bartle and Donald R. Sherbert, Introduction to Real Analysis, 4th ed., Wiley, 2011 — Chapter 6, including the Carathéodory form of the chain rule.
  • Michael Spivak, Calculus, 4th ed., Publish or Perish, 2008 — Chapters 10–11 and 20 (Taylor polynomials and remainders).
  • Jiří Lebl, Basic Analysis I: Introduction to Real Analysis, free textbook — jirka.org/ra, Chapter 4.
  • MIT OpenCourseWare, 18.100A Real Analysis (Fall 2020), lecture notes on differentiation and Taylor's theorem.
  • G. H. Hardy, "Weierstrass's non-differentiable function", Transactions of the American Mathematical Society 17 (1916), 301–325.

Note: this post is in progress. Planned additions: the Peano and integral forms of the Taylor remainder, convex functions and the second-derivative test, a full proof that the Weierstrass function is nowhere differentiable, and Newton's method with its quadratic error bound.