Search

Search papers and lessons

Taylor Series

Level 2 · 12 min read

A Taylor series rebuilds a smooth function near one point as a polynomial, using only its value and its derivatives there, and adding terms makes the match better.

On this page

  • Colour = topic mix
  • Calculus
  • Sign in to see your progress

TL;DR

A Taylor series approximates a complicated smooth function with a polynomial. You build the polynomial from the function's value and its derivatives at one chosen point, and near that point the polynomial tracks the function closely. Polynomials are easy to add, multiply, differentiate and integrate, so the trick turns hard questions into plain arithmetic.

Where you'll see it: inside calculators and numerical libraries that evaluate sin⁡\sin, exp⁡\exp and log⁡\log, in the linear approximations behind gradient descent, and in the error analysis of almost every numerical method.

Intuition

Zoom in on any smooth curve far enough and it looks like a straight line. That line is the tangent, and it is the best straight-line approximation at that point. It captures the value and the slope (the Derivative), but not how the curve bends. To capture the bend you need a parabola, which matches the curvature too. To capture the next wiggle you need a cubic, and so on. Each extra term fixes one more feature of the curve at the chosen point.

That is the whole idea. A Taylor polynomial is a stack of corrections, each one matching one more derivative. The more of the curve's behaviour you match, the closer the polynomial stays.

−2−1.5−1−0.500.511.52−202468xy
  • eˣ
  • degree 1
  • degree 2
  • degree 3
Each polynomial matches eˣ at x = 0 in value and in as many derivatives as its degree. Away from 0 the higher-degree polynomials stay close to eˣ for longer.

The math

Definition

Definition: Taylor series

For a function ff that is infinitely differentiable at a point aa, its Taylor series centred at aa is

∑n=0∞f(n)(a)n! (x−a)n=f(a)+f′(a)(x−a)+f′′(a)2!(x−a)2+⋯\sum_{n=0}^{\infty} \frac{f^{(n)}(a)}{n!}\,(x-a)^n = f(a) + f'(a)(x-a) + \frac{f''(a)}{2!}(x-a)^2 + \cdots

Here f(n)(a)f^{(n)}(a) is the nn-th derivative of ff evaluated at aa, n!n! is the factorial (n!=1⋅2⋅⋯⋅nn! = 1 \cdot 2 \cdot \cdots \cdot n, with 0!=10! = 1), and (x−a)(x-a) is the distance from the centre. When a=0a = 0 the series is called the Maclaurin series.

Where the coefficients come from

Suppose a polynomial p(x)=c0+c1(x−a)+c2(x−a)2+⋯p(x) = c_0 + c_1(x-a) + c_2(x-a)^2 + \cdots should match ff at aa in value and in every derivative. Evaluate at x=ax = a and every term except c0c_0 vanishes, so c0=f(a)c_0 = f(a). Differentiate once and set x=ax = a: p′(a)=c1p'(a) = c_1, so c1=f′(a)c_1 = f'(a). Differentiate twice: p′′(a)=2c2p''(a) = 2c_2, so c2=f′′(a)/2c_2 = f''(a)/2. In general the nn-th derivative of pp at aa equals n! cnn!\,c_n, which gives cn=f(n)(a)/n!c_n = f^{(n)}(a)/n!. The factorial appears because differentiating (x−a)n(x-a)^n a total of nn times gives n!n!.

Common series at a=0a = 0

ex=∑n=0∞xnn!=1+x+x22+x36+⋯sin⁡x=x−x33!+x55!−⋯11−x=1+x+x2+x3+⋯(∣x∣<1)\begin{aligned} e^x &= \sum_{n=0}^{\infty} \frac{x^n}{n!} = 1 + x + \frac{x^2}{2} + \frac{x^3}{6} + \cdots \\ \sin x &= x - \frac{x^3}{3!} + \frac{x^5}{5!} - \cdots \\ \frac{1}{1-x} &= 1 + x + x^2 + x^3 + \cdots \qquad (|x| \lt 1) \end{aligned}

How big is the error?

Truncating after degree nn leaves a remainder. Taylor's theorem says that, for some point ξ\xi between aa and xx,

Rn(x)=f(n+1)(ξ)(n+1)! (x−a)n+1.R_n(x) = \frac{f^{(n+1)}(\xi)}{(n+1)!}\,(x-a)^{n+1}.

Two things follow. The error shrinks like (x−a)n+1(x-a)^{n+1} as xx approaches aa, so the approximation is excellent close to aa and degrades farther away. And each extra term buys a factor of (x−a)/(n+1)(x-a)/(n+1), which is why the factorials make series converge quickly for small xx.

Worked examples

Example
Estimating e with a polynomial

Estimate e1e^1 (see the exponential function) using the series at a=0a = 0 with x=1x = 1. The exact value is e≈2.718282e \approx 2.718282.

  1. Degree 1: 1+1=21 + 1 = 2.
  2. Degree 2: 1+1+12=2.51 + 1 + \tfrac{1}{2} = 2.5.
  3. Degree 3: add 16≈0.16667\tfrac{1}{6} \approx 0.16667, giving 2.666672.66667.
  4. Degree 4: add 124≈0.04167\tfrac{1}{24} \approx 0.04167, giving 2.708332.70833.
  5. Degree 5: add 1120≈0.00833\tfrac{1}{120} \approx 0.00833, giving 2.716672.71667.

The error falls from 0.7180.718 to 0.00160.0016 over five terms. Each term is smaller than the last because the factorial in the denominator grows faster than the powers of 11 in the numerator.

Example
A square root without a calculator

Estimate 1.1\sqrt{1.1} using f(x)=1+xf(x) = \sqrt{1+x} at a=0a = 0, with x=0.1x = 0.1.

  1. Compute the first derivatives at 0: f(0)=1f(0) = 1, f′(0)=12f'(0) = \tfrac{1}{2}, f′′(0)=−14f''(0) = -\tfrac{1}{4}.
  2. The coefficients are f(0)=1f(0) = 1, then 12\tfrac{1}{2}, then −1/42!=−18\tfrac{-1/4}{2!} = -\tfrac{1}{8}.
  3. Degree 2 polynomial: 1+12(0.1)−18(0.1)2=1+0.05−0.00125=1.048751 + \tfrac{1}{2}(0.1) - \tfrac{1}{8}(0.1)^2 = 1 + 0.05 - 0.00125 = 1.04875.
  4. The true value is 1.1≈1.048809\sqrt{1.1} \approx 1.048809. The error is about 6×10−56 \times 10^{-5}.
  5. Interpretation: a short polynomial already lands within 6×10−56 \times 10^{-5} for a number near 1, which is why these expansions are used in hand calculation and in fast approximations.
Example
Sine near zero, and where it breaks

Estimate sin⁡(0.5)\sin(0.5) with the series sin⁡x≈x−x36+x5120\sin x \approx x - \tfrac{x^3}{6} + \tfrac{x^5}{120}.

  1. Degree 1: 0.50.5.
  2. Degree 3: 0.5−0.1256=0.5−0.020833=0.4791670.5 - \tfrac{0.125}{6} = 0.5 - 0.020833 = 0.479167.
  3. Degree 5: add 0.03125120=0.000260\tfrac{0.03125}{120} = 0.000260, giving 0.4794270.479427.
  4. The true value is sin⁡(0.5)=0.479426\sin(0.5) = 0.479426. The degree-5 estimate is accurate to about 10−610^{-6}.

Now try x=3x = 3, where the true value is sin⁡3≈0.14112\sin 3 \approx 0.14112. The degree-5 polynomial gives 3−4.5+2.025=0.5253 - 4.5 + 2.025 = 0.525. It is off by almost 0.380.38. The same polynomial that was excellent at 0.50.5 is poor at 33, because the remainder grows with (x−a)n+1(x-a)^{n+1}.

Tradeoffs and failure modes

A Taylor polynomial is exact at its centre and an approximation elsewhere. Choose it when you need accuracy near one point, and reach for something else when you need accuracy over a whole interval.

SituationProblemBetter choice
Accuracy needed far from aaError grows like (x−a)n+1(x-a)^{n+1}; high degree may not helpRe-expand around a closer point, or use range reduction (for example, reduce sin⁡x\sin x to a small angle first)
Accuracy needed on a whole intervalA Taylor polynomial is tuned to one point, not the intervalChebyshev or minimax polynomials, which spread the error evenly
Series outside its radius of convergence11−x\frac{1}{1-x} at x=2x = 2 gives 1+2+4+⋯1 + 2 + 4 + \cdots, which divergesStay inside the radius, or use a different expansion
Function not smooth at aa∣x∣\lvert x \rvert has no derivative at 00, so no Taylor series exists therePiecewise or smoothed approximations
Rational functions and ratiosSeries can be long and slow to convergePadé approximants, which use a ratio of polynomials

Two practical warnings. First, a series can converge for some xx and diverge for others. The set of xx where it converges is an interval around aa, and half its width is the radius of convergence, so always check it. Second, a convergent Taylor series need not equal the function it came from. The function e−1/x2e^{-1/x^2} (set to 00 at x=0x = 0) is infinitely differentiable, yet all its derivatives at 00 are 00, so its Taylor series at 00 is identically zero. For everyday functions like exe^x and sin⁡x\sin x the series does equal the function, but "infinitely differentiable" does not guarantee it.

History

The idea of matching a curve with a series is much older than the name. Mathematicians in the Kerala school, including Madhava of Sangamagrama around 1400 CE, found series for sin⁡\sin, cos⁡\cos and arctan⁡\arctan. In Europe, James Gregory and Isaac Newton were using infinite series for logarithms and other functions in the late 1600s.

The general method was published by Brook Taylor in 1715, in a book on the calculus of finite differences, Methodus incrementorum directa et inversa. He was looking for ways to expand functions as power series. Colin Maclaurin later used the case a=0a = 0 heavily in his 1742 treatise on fluxions, which is why that special case bears his name.

It caught on because it turned functions like sin⁡\sin, exp⁡\exp and log⁡\log into polynomials. Before electronic computers, tables of sin⁡\sin and log⁡\log were computed this way, and today's numerical libraries still evaluate most elementary functions with polynomial approximations derived from the same principle.

Check yourself

QuestionWhat is the coefficient of (x − a)³ in the Taylor series of f centred at a?Show answer

It is f′′′(a)/3!f'''(a) / 3!, which is f′′′(a)/6f'''(a)/6. The third derivative of ff at aa sets the cubic term, and dividing by 3!=63! = 6 cancels the factor produced by differentiating (x−a)3(x-a)^3 three times.

QuestionWrite the degree-2 Taylor polynomial of e^x at a = 0 and use it to estimate e^0.2.Show answer

The polynomial is 1+x+x221 + x + \tfrac{x^2}{2}. At x=0.2x = 0.2 it gives 1+0.2+0.02=1.221 + 0.2 + 0.02 = 1.22. The true value is e0.2≈1.2214e^{0.2} \approx 1.2214, so the error is about 0.00140.0014, roughly what the next term, x3/6≈0.0013x^3/6 \approx 0.0013, predicts.

QuestionWhy does the factorial appear in the denominator of every Taylor term?Show answer

Differentiating (x−a)n(x-a)^n a total of nn times gives n!n!, and that is the only term that is nonzero at aa after nn differentiations. So the nn-th derivative of the polynomial at aa is n!n! times its coefficient cnc_n. To make it equal f(n)(a)f^{(n)}(a), we set cn=f(n)(a)/n!c_n = f^{(n)}(a)/n!, and the factorial undoes that multiplication.

QuestionA calculator must evaluate cos(0.1) to six decimal places. Using the series cos x = 1 − x²/2 + x⁴/24 − x⁶/720 + ..., how many terms are needed?Show answer

Compute the terms at x=0.1x = 0.1: 11, then −0.005-0.005, then +0.0000041667+0.0000041667, then −0.0000000014-0.0000000014. The sum of the first three is 0.99500416670.9950041667, which rounds to 0.9950040.995004 at six decimals. The next term is about 1.4×10−91.4 \times 10^{-9}, far below the required precision. So three terms (up to the x4x^4 term) are enough, and the fourth term can be dropped.

Sources