Taylor Series Explorer

Choose a function, a centre a and a degree n. The dashed polynomial matches f and its first n derivatives at a; the orange segment at x shows how far the two have drifted apart, and Lagrange's bound says how far they could have.

Taylor's formula
Lagrange's remainder
Series to know
Loading interactive simulation...

Lesson

The theory β€” Taylor Series Explorer

The Taylor polynomial of degree n of f about a is the polynomial with the same value and the same first n derivatives as f at a: Pn(x) = Ξ£ f(k)(a)(x βˆ’ a)k/k!, summed from k = 0 to n. About a = 0 it is also called a Maclaurin polynomial.

What each symbol means

a
the centre, where Pβ‚™ and f agree
n
the degree: how many derivatives are matched
Rβ‚™(x)
the remainder, f(x) βˆ’ Pβ‚™(x)

Where the formula comes from

  1. Match the value, then the slope. P0 = f(a) is the height at a. Adding fβ€²(a)(x βˆ’ a) gives P1, the tangent line of the derivative page.
  2. Why k! appears. Differentiate ck(x βˆ’ a)k k times and ckΒ·k! is left, while every other term is 0 at a. To match f(k)(a), the coefficient must be f(k)(a)/k!.
  3. Work it for sin x about 0. The derivatives at 0 cycle 0, 1, 0, βˆ’1, so only odd powers survive, with alternating signs.
  4. Bound the error. Lagrange's form of the remainder puts the (n + 1)th derivative at an unknown ΞΎ between a and x. Replace it by M, its largest size on that interval, and the bound needs nothing from f(x) itself.
  5. Build new series from old ones. Substitute into a known series, multiply two, or integrate one term by term, instead of differentiating again: eβˆ’xΒ² comes from eu with u = βˆ’xΒ².

The chord's miss on the derivative page was a Taylor term 🖖

On the derivative page the chord's slope missed the tangent's by about Β½fβ€³(x)Β·h. Expand f(x + h) = f(x) + fβ€²(x)h + Β½fβ€³(x)hΒ² + β‹―, subtract f(x) and divide by h: the chord's slope is fβ€²(x) + Β½fβ€³(x)h + β‹―, and the miss is the next term. The same expansion explains the Riemann sum page. Expand f about the middle of a strip and the fβ€² term is odd about that point, so it integrates to zero across the strip. The midpoint rule is left with an fβ€³ error of order hΒ³ per strip, while the left-endpoint rule keeps an fβ€² error of order hΒ².

Smooth everywhere, and still not equal to its series 🖖

Lagrange built his 1797 account of calculus on the assumption that every function equals its Taylor series. Cauchy's counterexample of 1823 is f(x) = eβˆ’1/xΒ², with f(0) = 0. Every derivative of it exists, and every one is 0 at x = 0, so its Taylor polynomial about 0 is 0 at every degree, while the function is positive at every x β‰  0. Adding terms never helps. A function with derivatives of every order is called smooth; one that equals its Taylor series near each point is called analytic, and the first does not imply the second.

TAYLOR SERIES β€” HOW FAR FROM THE CENTRE YOU CAN STILL TRUST IT

Which Taylor Case Are You In?

A Taylor polynomial matches a function's value and its first n derivatives at one point, and then drifts away as you move off. Two things decide how fast: how quickly the coefficients shrink, and whether the function has a singularity nearby. Adding terms helps inside the radius of convergence and does nothing at all outside it β€” and moving the centre is often worth more than adding terms.

Good near the centre, useless far from it ε ∝ (x − a)n+1
Factorials win β€” the series converges everywhere xn/n! → 0, R = ∞
A radius of convergence β€” beyond it, more terms do not help ln(1 + x): R = 1
Move the centre β€” cheaper than adding terms Δa ≠ 0, Δn = 0

01

Good near the centre, useless far from it

What you know: A low-degree expansion of a well-behaved function. Accurate close to the centre, and the error grows fast as you move away.

Series: ε ∝ (x − a)n+1

Worked example: sin x β‰ˆ x βˆ’ xΒ³/6 at x = 1 gives 0.8333 against the true 0.8415 β€” an error of 0.008. At x = 3 it gives βˆ’1.5 against 0.141

Open this case: sin x, degree 3
Good near the centre, useless far from it. The cubic tracks the sine for about a radian, then leaves in the wrong direction entirely. A low-degree expansion of a well-behaved function. Accurate close to the centre, and the error grows fast as you move away.
The cubic tracks the sine for about a radian, then leaves in the wrong direction entirely.

02

Factorials win β€” the series converges everywhere

What you know: The coefficients carry a factorial in the denominator, so they shrink faster than any power grows. The radius of convergence is infinite.

Series: xn/n! → 0, R = ∞

Worked example: eΛ£ β‰ˆ 1 + x + xΒ²/2 + xΒ³/6 + x⁴/24 + x⁡/120 at x = 1 gives 2.71667 against e = 2.71828: six terms, three correct digits

Open this case: eΛ£, degree 5
Factorials win β€” the series converges everywhere. Degree 5 already traces the exponential across the whole visible range. The coefficients carry a factorial in the denominator, so they shrink faster than any power grows. The radius of convergence is infinite.
Degree 5 already traces the exponential across the whole visible range.

03

A radius of convergence β€” beyond it, more terms do not help

What you know: The function has a singularity a finite distance from the centre. Inside that distance the series converges; outside it, it diverges no matter how many terms you take.

Series: ln(1 + x): R = 1

Worked example: ln(1 + x) with six terms at x = 0.8 gives 0.5701 against 0.5878 β€” still converging, slowly. At x = 1.2 the terms grow and the sum runs away

Open this case: ln(1 + x) near its edge
A radius of convergence β€” beyond it, more terms do not help. Inside the radius the polynomial tracks the curve; past it, it leaves and never comes back. The function has a singularity a finite distance from the centre. Inside that distance the series converges; outside it, it diverges no matter how many terms you take.
Inside the radius the polynomial tracks the curve; past it, it leaves and never comes back.

04

Move the centre β€” cheaper than adding terms

What you know: You need accuracy at some point far from where the series is centred. Re-expanding around a nearer point costs nothing extra in degree.

Series: Δa ≠ 0, Δn = 0

Worked example: Degree 4 for cos x at x = 2: centred at 0 it gives βˆ’0.333 against βˆ’0.416, centred at 1 it gives βˆ’0.4086 β€” an error eleven times smaller

Open this case: cos x about 1
Move the centre β€” cheaper than adding terms. Same degree, different centre: the expansion around 1 hugs the curve at x = 2. You need accuracy at some point far from where the series is centred. Re-expanding around a nearer point costs nothing extra in degree.
Same degree, different centre: the expansion around 1 hugs the curve at x = 2.

Problems solved in full

  1. Approximating sin 1 with the degree-3 Maclaurin polynomial and bounding the error 5 steps

    Approximate sin 1 with the degree-3 Maclaurin polynomial, and bound the error before looking up the true value. An error bound you can only compute once you know the answer is worth nothing.

    Open this problem in the tool

    1. Maclaurin needs the derivatives at 0, and sine cycles through them with period four. Two of the first four are zero, which is why the polynomial ends up so short.

    2. So P₃ has two terms, and the xΒ³/6 is the whole correction. It moves 1 down to 0.83333 β€” a cut of nearly 17%, which is already a hint that the next term will not be negligible either.

    3. This is the step that earns the section. The series for sine alternates with terms that shrink, so the truncation error is smaller than the first term left out. That term is x⁡/120, and computing it requires knowing nothing whatsoever about sin 1.

    4. Now check the promise. The true value is 0.84147, so the actual error is 0.0081377 β€” and it does sit under the 0.0083333 that was guaranteed in advance.

    5. The bound is tight, and you can see why. The error is the entire omitted tail, and the tail alternates as well: 1/5! overshoots, subtracting 1/7! overshoots the other way, and 1/9! brings it home. Three terms already reproduce the printed error digit for digit.

    Answer

    P₃(1) = 0.833333 against a true 0.841471, an error of 0.0081377. The order the numbers arrived in is the point: 1/120 = 0.0083333 was available before sin 1 was, and it overshot the real error by only 2.4%. An approximation that comes with a certificate like that is worth more than one that merely happens to be close. The page's Lagrange row says 0.035061 at degree 3, because it treats P₃ as a degree-3 polynomial; set the degree to 4, which for sine is the same polynomial, and Lagrange gives 1/120 too. Raise the degree to 5 and the same argument hands you 1/5040 (the Lagrange row shows it at degree 6, the same polynomial), three decimal places guaranteed before a single digit of the answer is computed.

  2. Estimating √e, with a bound found first 4 steps

    Use the degree-4 Maclaurin polynomial of eˣ to estimate √e, and bound the error without using the value of e0.5.

    Open this problem in the tool

    Show solution
    1. Every derivative of eΛ£ is eΛ£, which is 1 at 0, so every coefficient is 1/k!:

    2. At x = 0.5:

    3. Lagrange's bound needs M, the largest value of the fifth derivative eα΅— for t between 0 and 0.5. Without knowing e0.5, use e < 3, so e0.5 < √3 < 2:

    4. The page uses the exact M = e0.5, which gives a tighter bound, and then the true error, which sits inside both:

    Answer

    √e β‰ˆ 1.648438, with an error below 0.00052 guaranteed from e < 3 alone. The true error is 0.00028377. A bound found from a cruder M is still a bound; it only promises less.

  3. A Taylor polynomial about a point other than 0 4 steps

    Find the degree-2 Taylor polynomial of √x about 4, use it to estimate √4.1, and bound the error.

    Open this problem in the tool

    Show solution
    1. The derivatives at 4:

    2. Divide each by k!:

    3. At x = 4.1, x βˆ’ 4 = 0.1:

    4. The third derivative, (3/8)xβˆ’5/2, is largest at the left end of [4, 4.1], where it is 3/256:

    Answer

    √4.1 β‰ˆ 2.024844, with an error below 1.9531 Γ— 10⁻⁢. The true error is 1.9231 Γ— 10⁻⁢, close to the bound because the third derivative barely changes between 4 and 4.1. The expansion is about 4 because √x is easy to evaluate there; about 0, √x has no Taylor polynomial beyond degree 0, because it has no derivative there.

  4. A series by substitution, then integrated 4 steps

    Find the Maclaurin series of eβˆ’xΒ² up to x⁢, and use it to estimate the integral of eβˆ’xΒ² from 0 to 0.5.

    Open this problem in the tool

    Show solution
    1. Differentiating eβˆ’xΒ² six times is slow. Substitute u = βˆ’xΒ² into the series for eᡘ instead:

    2. Check it against the page at x = 0.5:

    3. Integrate term by term from 0 to 0.5:

    4. The terms alternate and shrink, so the error is below the first one left out, which comes from x⁸/4!:

    Answer

    The integral is about 0.461272, within 0.0000090. The true value is 0.461281. This integral has no formula in elementary functions, which is why a series, or a Riemann sum, is how it gets computed.

  5. A limit by series 2 steps

    Find the limit of (sin x βˆ’ x)/xΒ³ as x β†’ 0.

    Show solution
    1. Replace sin x by its series, and the x cancels:

    2. Divide each remaining term by xΒ³:

    Answer

    The limit is βˆ’1/6. L'HΓ΄pital's rule gets there too, after three rounds of differentiation. The series gives the answer at once, and also how fast the quotient approaches it: the next term is xΒ²/120.

  6. A high derivative read off a series 2 steps

    Find the fifth derivative of f(x) = xΒ²eΛ£ at x = 0.

    Open this problem in the tool

    Show solution
    1. Multiply the series for eΛ£ by xΒ²:

    2. The coefficient of x⁡ is f⁽⁡⁾(0)/5!, so:

    Answer

    f⁽⁡⁾(0) = 20. The product rule applied five times gets the same number with far more writing. The page's first row lists all six derivatives at 0: 0, 0, 2, 6, 12, 20.

  7. How many terms for six decimal places 3 steps

    How many terms of the Maclaurin series of eΛ£ are needed to compute e with an error below 0.0000005?

    Open this problem in the tool

    Show solution
    1. At x = 1 Lagrange's bound for degree n is M/(n + 1)!, with M the largest eα΅— on [0, 1], which is e < 3:

    2. Find the first n where that drops below 0.0000005:

    3. So n = 10, which is eleven terms counting the constant. The page at degree 10 gives:

    Answer

    Degree 10: eleven terms. By the bound, degree 9 is not enough (7.4909 Γ— 10⁻⁷), although its actual error, 3.0289 Γ— 10⁻⁷, would have done. The bound settles what can be promised in advance; that degree 9 is close enough nobody could have said before computing e.

Learning path

Why everything looks straight up close

References (1)
Further reading (2)