Calculus · Differential calculus
The tangent line is the best straight-line approximation of a function near a point. Taylor's formula goes further: it gives the best approximating polynomial of any degree, and, crucially, an exact expression for the error. With it you can compute \(\sin 0.5\) by hand to four decimals and know they are correct, evaluate tricky limits, and prove inequalities. This post explains the formula, where it comes from, and how to use it.
Near a point \(a\), the tangent line \( f(a) + f'(a)(x - a) \) has the same value and the same slope as \(f\) (post on the differential). But a line can't bend, so it soon drifts away from the curve. A parabola can bend: if we also match the second derivative, the curvature, the approximation improves. Matching the third derivative improves it further, and so on.
Which polynomial of degree \(n\) has the same value and the same first \(n\) derivatives at \(a\) as \(f\)? Write it in powers of \((x - a)\):
\[ T_n(x) = c_0 + c_1(x - a) + c_2(x - a)^2 + \cdots + c_n(x - a)^n. \]Differentiating \(k\) times and putting \(x = a\) kills every term except one: \( T_n^{(k)}(a) = k!\,c_k \). So the condition \( T_n^{(k)}(a) = f^{(k)}(a) \) gives
\[ c_k = \frac{f^{(k)}(a)}{k!}. \]For \(n = 1\) it is the tangent line; for \(n = 2\), the parabola that "hugs" the curve best at \(a\).
The polynomial is only an approximation. Taylor's formula says what the exact error is.
The last term is the remainder:
How to read Lagrange's form: the remainder looks exactly like the next term of the polynomial, except that the derivative is evaluated not at \(a\), but at some unknown point \(\xi\) between \(a\) and \(x\). We don't know \(\xi\) (it depends on \(x\) and on \(n\)), but we usually don't need it: it is enough to bound \( |f^{(n+1)}| \) on the interval.
Special case \(n = 0\): the formula reads \( f(x) = f(a) + (x - a)f'(\xi) \), which is Lagrange's mean value theorem. Taylor's formula is its far-reaching generalization.
The proof is a clever application of Cauchy's mean value theorem (post on mean value theorems). Fix \(x\), and regard the "Taylor polynomial centred at a variable point \(t\)" as a function of \(t\):
\[ g(t) = f(x) - \left[f(t) + \frac{f'(t)}{1!}(x - t) + \cdots + \frac{f^{(n)}(t)}{n!}(x - t)^n\right]. \]At the two ends: \( g(x) = 0 \) (every power of \(x - t\) vanishes) and \( g(a) = R_n(x) \) (exactly the remainder we want). When we differentiate in \(t\), the terms cancel in pairs (a telescoping sum), and only one survives:
\[ g'(t) = -\frac{f^{(n+1)}(t)}{n!}(x - t)^n. \]Now apply Cauchy's theorem to \(g\) and an auxiliary function \(\varphi\) on the interval between \(a\) and \(x\):
\[ \frac{g(x) - g(a)}{\varphi(x) - \varphi(a)} = \frac{g'(\xi)}{\varphi'(\xi)}. \]Different choices of \(\varphi\) give different forms of the same remainder. Lagrange's is the easiest to use; Cauchy's is sometimes sharper (see Section 8).
Using the \(n\)-th derivatives from the post on higher derivatives, we get the expansions you should know by heart, now with their remainders:
| Function | Maclaurin's formula (Lagrange remainder) |
|---|---|
| \(e^x\) | \( 1 + x + \frac{x^2}{2!} + \cdots + \frac{x^n}{n!} + \frac{e^{\theta x}}{(n+1)!}x^{n+1} \) |
| \(\sin x\) | \( x - \frac{x^3}{3!} + \cdots + (-1)^{m-1}\frac{x^{2m-1}}{(2m-1)!} + R_{2m}, \quad |R_{2m}| \le \frac{|x|^{2m+1}}{(2m+1)!} \) |
| \(\cos x\) | \( 1 - \frac{x^2}{2!} + \cdots + (-1)^m\frac{x^{2m}}{(2m)!} + R_{2m+1}, \quad |R_{2m+1}| \le \frac{|x|^{2m+2}}{(2m+2)!} \) |
| \(\ln(1 + x)\) | \( x - \frac{x^2}{2} + \cdots + (-1)^{n-1}\frac{x^n}{n} + \frac{(-1)^n x^{n+1}}{(n+1)(1 + \theta x)^{n+1}} \) |
| \((1 + x)^\alpha\) | \( 1 + \alpha x + \frac{\alpha(\alpha-1)}{2!}x^2 + \cdots + \binom\alpha n x^n + \binom{\alpha}{n+1}(1 + \theta x)^{\alpha - n - 1}x^{n+1} \) |
A small trick for sine and cosine: since \(\sin x\) has only odd powers, its polynomial of degree \(2m - 1\) is also its polynomial of degree \(2m\) (the even coefficient is zero). So we can use the remainder \(R_{2m}\), with \(x^{2m+1}\), which is smaller. All derivatives of \(\sin\) and \(\cos\) are bounded by \(1\), which gives the simple bounds in the table.
This is the main practical use: replace \(f\) by \(T_n\) and bound the remainder to know how accurate the result is.
If \(f^{(n+1)}\) is bounded near \(a\), the remainder \(R_n(x)\) contains the factor \((x - a)^{n+1}\), so it tends to zero faster than \((x - a)^n\). This is written
\[ f(x) = T_n(x) + o\big((x - a)^n\big), \qquad x \to a, \]where \( o\big((x - a)^n\big) \) ("little o") denotes any quantity with \( \frac{o((x - a)^n)}{(x - a)^n} \to 0 \). This is the Peano form of the remainder, and it is all that's needed for limits: replace each function by its Taylor polynomial, cancel, and look at the lowest surviving power.
L'Hôpital's rule would need three differentiations; with Taylor's formula it is one line.
When the sign of the remainder is known, Taylor's formula proves inequalities.
It is worth separating two things that are easily confused:
So Taylor's formula is the tool for proving that a Taylor series converges to the function: estimate \(R_n\) and show it tends to zero. For \(e^x\), \(\sin x\), \(\cos x\) this works with Lagrange's form for every \(x\).
| Concept | Formula |
|---|---|
| Taylor polynomial | \( T_n(x) = \sum_{k=0}^n\frac{f^{(k)}(a)}{k!}(x - a)^k \) |
| Taylor's formula | \( f(x) = T_n(x) + R_n(x) \) |
| Lagrange remainder | \( R_n = \frac{(x - a)^{n+1}}{(n+1)!}f^{(n+1)}[a + \theta(x - a)] \) |
| Cauchy remainder | \( R_n = \frac{(1 - \theta_1)^n(x - a)^{n+1}}{n!}f^{(n+1)}[a + \theta_1(x - a)] \) |
| Peano remainder | \( R_n = o\big((x - a)^n\big),\ x \to a \) |
| Error bound | \( |R_n| \le \frac{M|x - a|^{n+1}}{(n+1)!} \), \( M = \max|f^{(n+1)}| \) |
| Maclaurin (\(a = 0\)) | \( \xi = \theta x \) |
| \(n = 0\) | Lagrange's mean value theorem |
Try each one before opening the solution. More solved problems from this topic are in Differential Calculus.
\( f'''(x) = \frac{3}{8x^{5/2}} \Rightarrow f'''(4) = \frac{3}{256} \). So \( T_3 = 2 + \frac{x - 4}{4} - \frac{(x - 4)^2}{64} + \frac{(x - 4)^3}{512} \).
At \(x = 1\): \( R_n = \frac{e^\theta}{(n + 1)!} < \frac{3}{(n + 1)!} \). We need \( (n + 1)! > 3000 \): \( 7! = 5040 \), so \(n = 6\): \( e \approx 1 + 1 + \frac12 + \frac16 + \frac1{24} + \frac1{120} + \frac1{720} = 2.71806 \) (true: \(2.71828\)).
Maclaurin with \(n = 2\): \( \sin x = x + R_2 \), \( R_2 = \frac{x^3}{3!}\sin'''(\theta x) = -\frac{x^3}{6}\cos(\theta x) \), and \( |\cos| \le 1 \).
\( \cos x = 1 - \frac{x^2}{2} + \frac{x^4}{24} + o(x^4) \), so the limit is \( \frac{1}{24} \).
\( f(0) = 0 \), \( f' = 1 + \operatorname{tg}^2x \Rightarrow 1 \), \( f'' = 2\operatorname{tg}x(1 + \operatorname{tg}^2x) \Rightarrow 0 \), \( f'''(0) = 2 \). So \( \operatorname{tg}x \approx x + \frac{x^3}{3} \).
\( |R| \le \frac{1}{(2m + 2)!} < 10^{-5} \) needs \( (2m + 2)! > 10^5 \): \( 8! = 40320 \) is not enough, \( 10! \) is. So \(2m = 8\): \( \cos 1 \approx 1 - \frac12 + \frac1{24} - \frac1{720} + \frac1{40320} = 0.540303 \) (true: \(0.5403023\)).
With \(n = 1\): \( \sqrt{1 + x} = 1 + \frac x2 + \frac{f''(\theta x)}{2}x^2 \), where \( f''(t) = -\frac14(1 + t)^{-3/2} < 0 \). The remainder is \(\le 0\), so the curve lies below its tangent \(1 + \frac x2\) at \(x = 0\).
\( T_0(x) = f(a) \), and the Lagrange remainder is \( R_0 = (x - a)f'(\xi) \). So \( f(x) - f(a) = (x - a)f'(\xi) \), exactly Lagrange's theorem.
Taylor's formula turns any smooth function into a polynomial plus an error term you can control. The polynomial is built by matching derivatives at one point; the remainder looks like the next term, evaluated at an unknown intermediate point. That simple description is enough to compute values with certified accuracy, to resolve limits faster than L'Hôpital, to prove inequalities, and to justify every power series expansion. It is one of the central results of differential calculus, and it sits right on top of the mean value theorems it generalizes.
Related posts: the mean value theorems (the proof), higher derivatives (computing \(f^{(n)}\)), power series (the infinite version) and L'Hôpital's rule (an alternative for limits).