Taylor & Maclaurin Series

Your calculator finds sine and cosine, and engineers routinely swap a pendulum's swing or a lens's bend for a simpler stand-in, all with the same move: take a complicated function near one point and rebuild it from a few easy measurements. That rebuilt copy is a Taylor series, and it turns up all over physics, engineering and computing.

Here is perhaps the boldest idea in all of calculus. Stand at a single point on a curve and take measurements — but not just one. Measure the function's value there. Measure its slope. Measure how the slope is changing (the curvature), how the curvature is changing, and so on, derivative after derivative, all at that one point. Now walk away and try to rebuild the entire function from your notebook.

Astonishingly, for the best-behaved functions in mathematics, you can. The infinite list of numbers f(a), f'(a), f''(a), f'''(a), \dots is a complete genetic fingerprint: from it you can clone f — not just near the point, but sometimes across the whole real line. The cloning machine is a power series whose coefficients are built from those derivatives, and it is called the Taylor series of f at a. When the measuring point is a = 0 it has its own name: the Maclaurin series.

The plan is simple to state. A polynomial can be made to agree with f at a: match the value, then also the slope, then also the second derivative, the third, the fourth… Each extra matched derivative costs one more term, and each term hugs the curve a little longer before peeling away. Push the matching to infinity and — when the stars align — the polynomial becomes the function. Functions like e^x, \sin x and \cos x surrender their infinite fingerprints without a fight, and we will take all three by the end of this page.

Deriving the coefficient formula

Suppose the plan works — suppose f is a power series about a on some interval:

f(x) = \sum_{n=0}^{\infty} c_n (x - a)^n = c_0 + c_1(x-a) + c_2(x-a)^2 + c_3(x-a)^3 + \cdots.

Then the coefficients are not free for us to choose. We can hunt them down one at a time, using the fact that a power series may be differentiated term by term inside its interval of convergence. The trick is always the same: differentiate enough times to drag the coefficient you want into the constant seat, then set x = a to kill everything else.

Step 0 — read off c_0. Set x = a. Every term with a factor (x-a) dies, leaving only the constant:

f(a) = c_0.

Step 1 — differentiate once, then set x = a. Term-by-term differentiation gives

f'(x) = c_1 + 2c_2(x-a) + 3c_3(x-a)^2 + \cdots, \qquad f'(a) = c_1.

Step 2 — differentiate twice. Each differentiation pulls down the current exponent as a factor, so the c_2 term has been hit by 2 and then 1:

f''(x) = 2c_2 + (3\cdot 2)c_3(x-a) + \cdots, \qquad f''(a) = 2c_2 \ \Longrightarrow\ c_2 = \frac{f''(a)}{2}.

Step 3 — differentiate three times and watch a factorial crystallise: the (x-a)^3 term has been struck by 3, then 2, then 1:

f'''(x) = (3\cdot 2 \cdot 1)c_3 + \cdots, \qquad f'''(a) = 6\,c_3 \ \Longrightarrow\ c_3 = \frac{f'''(a)}{3!}.

Step 4 — the general pattern. Differentiating n times, the (x-a)^n term contributes n(n-1)\cdots 1 = n! times c_n, every lower term has been differentiated to death, and every higher term still carries a factor (x-a) that dies at x = a. Hence f^{(n)}(a) = n!\, c_n, so

\boxed{\,c_n = \frac{f^{(n)}(a)}{n!}\,}

The coefficients are dictated by the higher-order derivatives of f at the centre — that is the fingerprint. The factorial in the denominator is the price of repeated differentiation: to leave c_n intact after n derivatives have each multiplied it by a falling exponent, we must divide the damage back out. Assembling all the coefficients gives the Taylor series:

f(x) \ \sim \ \sum_{n=0}^{\infty} \frac{f^{(n)}(a)}{n!}\,(x-a)^n.

(The cautious symbol \sim means "has the series" — whether the series actually equals f(x) is a separate question, and the "Watch out!" box below shows it can fail in spectacular fashion.)

The three classics, built from scratch

The exponential e^x (Maclaurin, a = 0). This is the friendliest customer imaginable: every derivative of e^x is e^x again, so the fingerprint at 0 is the world's least imaginative list — f^{(n)}(0) = e^0 = 1 for all n. The formula hands us c_n = 1/n!:

e^x = \sum_{n=0}^{\infty} \frac{x^n}{n!} = 1 + x + \frac{x^2}{2!} + \frac{x^3}{3!} + \frac{x^4}{4!} + \cdots.

Sine. The derivatives of \sin x cycle with period four — \sin, \cos, -\sin, -\cos — so at 0 the fingerprint reads 0, 1, 0, -1, 0, 1, 0, -1, \dots forever. Every even-numbered derivative vanishes, so only odd powers survive, and the surviving signs alternate:

\sin x = \sum_{n=0}^{\infty} \frac{(-1)^n}{(2n+1)!}\,x^{2n+1} = x - \frac{x^3}{3!} + \frac{x^5}{5!} - \frac{x^7}{7!} + \cdots.

Notice how much personality the fingerprint carries: oddness of the function shows up as odd-only powers, and the wave-like flip-flopping shows up as alternating signs.

Cosine. Two routes, same answer. Either evaluate \cos's derivatives at 0 — the cycle reads 1, 0, -1, 0, \dots, so only even powers survive — or simply differentiate the sine series term by term (legal inside the interval of convergence):

\cos x = \sum_{n=0}^{\infty} \frac{(-1)^n}{(2n)!}\,x^{2n} = 1 - \frac{x^2}{2!} + \frac{x^4}{4!} - \frac{x^6}{6!} + \cdots.

All three series have radius of convergence R = \infty: the factorial in the denominator grows faster than any power x^n can fight back, crushing the terms to zero no matter how large x is. Better still, the leftover error (the "remainder") also dies, so each series genuinely equals its function on the whole real line.

If f is represented by a power series about a, its coefficients are forced to be

Each of these three converges to its function for all x \in \mathbb{R} (R = \infty).

Line up the three series and a jewel appears. Feed an imaginary argument ix into the exponential series and use i^2 = -1, i^3 = -i, i^4 = 1:

e^{ix} = \sum_{n=0}^{\infty}\frac{(ix)^n}{n!} = 1 + ix - \frac{x^2}{2!} - i\frac{x^3}{3!} + \frac{x^4}{4!} + \cdots.

Now sort the terms into those with no i (even powers) and those carrying one factor of i (odd powers):

e^{ix} = \underbrace{\left(1 - \frac{x^2}{2!} + \frac{x^4}{4!} - \cdots\right)}_{\cos x} + i\,\underbrace{\left(x - \frac{x^3}{3!} + \frac{x^5}{5!} - \cdots\right)}_{\sin x}.

The two groups are exactly the cosine and sine series we just built. Therefore

e^{ix} = \cos x + i \sin x,

Euler's formula — and at x = \pi the celebrated e^{i\pi} + 1 = 0, five of mathematics' most famous constants in one line. The deep link between exponential growth and rotation is not a coincidence; it is three Maclaurin series sitting on top of one another.

Put it to work: approximating with partial sums

A Taylor series is not just a pretty identity — chop it off after a few terms and it becomes a calculator. Let's actually compute something. What is e^{0.1}? Feed x = 0.1 into the exponential series, one term at a time, and watch the estimate lock on:

e^{0.1} = 1 + 0.1 + \frac{(0.1)^2}{2!} + \frac{(0.1)^3}{3!} + \cdots = 1 + 0.1 + 0.005 + 0.000167 + \cdots
Partial sumEstimateError vs. the truth
P_0 = 11.000000\approx 0.105
P_1 = 1 + 0.11.100000\approx 0.0052
P_2 = P_1 + 0.0051.105000\approx 0.00017
P_3 = P_2 + 0.0001671.105167\approx 0.0000043
P_4 = P_3 + 0.00000421.105171\approx 0.00000009

The truth is e^{0.1} = 1.1051709\ldots Each new term buys roughly two extra correct decimal places — the error shrinks by a factor of dozens per step, because each term is the previous one times the small number 0.1/n. Five terms of school arithmetic and we have matched an eight-digit calculator.

Once more with sine. Take \sin(0.5) (that's 0.5 radians, about 28.6°). The true value is 0.4794255\ldots:

Partial sumEstimateError
P_1 = 0.50.5000000\approx 0.021
P_3 = 0.5 - \dfrac{(0.5)^3}{3!}0.4791667\approx 0.00026
P_5 = P_3 + \dfrac{(0.5)^5}{5!}0.4794271\approx 0.0000016

Two non-trivial terms already give five correct decimals. Notice the bonus that alternating series hand us for free: because the terms alternate in sign and shrink, the true value is always trapped between consecutive partial sums, so the size of the first neglected term is a guaranteed ceiling on the error. When you drop the x^7/7! term you know your answer is within (0.5)^7/5040 \approx 0.0000016 — no faith required.

This is the whole game of numerical approximation: near the centre, a Taylor series converges ferociously fast, and you can budget exactly how many terms a target accuracy costs.

Watch the polynomial hug the curve

The faint curve is \sin x. The bold curve is its Maclaurin polynomial truncated at degree N, P_N(x) = \sum_{2k+1 \le N} (-1)^k x^{2k+1}/(2k+1)!. Start at N = 1: the "polynomial" is just the straight line y = x — the tangent line at the origin, and the reason physicists get away with \sin\theta \approx \theta for small angles.

Now raise N and watch the takeover. Degree 3 bends to follow the first curl of the wave; degree 7 captures a full arch; by degree 19 the polynomial shadows several complete oscillations before losing its grip. Every polynomial must eventually flee to \pm\infty — it has only finitely many wiggles in it — so each one peels off in the end. But the peeling point retreats further out every time you add terms: that is what "the series converges to \sin x everywhere" looks like in motion.

Watch closely near x = 0: even the low-degree polynomials are essentially perfect there. A Taylor polynomial's accuracy is a local currency — richest at the centre, devalued with distance. Approximating \sin(0.3) with P_3 is superb; approximating \sin(9) with it is a catastrophe you can see on the chart.

The big five — a pocket reference

Five Maclaurin series do most of the day-to-day work of mathematics, physics and engineering. The first three you have just built; the last two come from the geometric series and its integral, and — unlike the first three — they only work on a limited interval:

FunctionMaclaurin seriesValid for
e^x \displaystyle\sum_{n\ge 0} \frac{x^n}{n!} = 1 + x + \frac{x^2}{2!} + \cdots all x (R=\infty)
\sin x \displaystyle\sum_{n\ge 0} \frac{(-1)^n x^{2n+1}}{(2n+1)!} = x - \frac{x^3}{3!} + \cdots all x (R=\infty)
\cos x \displaystyle\sum_{n\ge 0} \frac{(-1)^n x^{2n}}{(2n)!} = 1 - \frac{x^2}{2!} + \cdots all x (R=\infty)
\dfrac{1}{1-x} \displaystyle\sum_{n\ge 0} x^n = 1 + x + x^2 + x^3 + \cdots |x| < 1 (R=1)
\ln(1+x) \displaystyle\sum_{n\ge 1} \frac{(-1)^{n+1} x^n}{n} = x - \frac{x^2}{2} + \frac{x^3}{3} - \cdots -1 < x \le 1 (R=1)

The last row is worth a double-take: at the very edge x = 1 the series still (barely) converges, giving the lovely \ln 2 = 1 - \tfrac12 + \tfrac13 - \tfrac14 + \cdots — though it converges so slowly you would need about a thousand terms for three decimal places. Radius of convergence is a hard wall: plug x = 2 into the geometric series and you get the gibberish 1 + 2 + 4 + 8 + \cdots, even though the function 1/(1-x) is perfectly happy at x=2 (it equals -1 there). The series is a portrait of the function painted from the centre — it simply cannot see past its own frame.

A Taylor series equals its function only where two things hold: the series converges, and the remainder tends to zero. Students (and, historically, some very good mathematicians) assume the fingerprint always identifies its owner. It doesn't. The infamous counterexample:

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

This function is perfectly smooth, and it flattens against the axis at the origin with such unearthly gentleness that every single derivative vanishes there: f(0) = f'(0) = f''(0) = \cdots = 0. Its Maclaurin series is therefore 0 + 0x + 0x^2 + \cdots = 0 — which converges beautifully, everywhere, to the zero function. But f is not the zero function: it is strictly positive at every x \neq 0. The series converges and is still wrong everywhere except the single point x = 0. Two functions — this one and the zero function — share an identical fingerprint at the origin yet are different functions.

Two practical morals. First: convergence alone proves nothing — equality needs the remainder R_N(x) = f(x) - P_N(x) to die as N \to \infty (for e^x, \sin and \cos it does, which is why we may write "=" for them). Second, more everyday: even when the series is honest, a truncated one is only trustworthy near the centre. Close to a a few terms are superb; far away the same few terms can be worse than useless — as the chart above cheerfully demonstrates.

Press \sin on a calculator and no little triangle is measured anywhere. What actually happens is pure Taylor-flavoured trickery, in two moves.

Move 1 — range reduction. Truncated series are only good near the centre, so the machine first uses symmetry (\sin repeats every 2\pi, and there are reflection identities) to fold your input into a tiny interval around 0, typically [-\pi/4, \pi/4]. Asking for \sin(1000) quietly becomes asking for the sine or cosine of something smaller than 0.8.

Move 2 — a short polynomial. On that tiny interval, a polynomial of degree about 13 — essentially the Maclaurin series with its coefficients nudged a hair (a so-called minimax polynomial) so the worst-case error is as small as possible — reproduces \sin to full double-precision accuracy: error under 10^{-16}. Seven multiplications and additions, done.

The same economics run everywhere performance matters. Game physics engines often keep just \sin\theta \approx \theta - \theta^3/6 for speed; the classic pendulum formula in physics is the even blunter one-term truncation \sin\theta \approx \theta; and vintage pocket calculators used a cousin technique called CORDIC that trades the multiplications for bit-shifts. Every transcendental value you have ever seen on a screen was a Taylor-style polynomial wearing a good suit.

See it explained