Plotwise graphing calculator

Learn › Degree level

Taylor series: approximating sin x with polynomials

Polynomials are the easiest functions to work with: you only ever add and multiply. A Taylor series builds a polynomial that imitates a harder function. This page builds one for sin x and shows how good the imitation is.

What you need first

  • How to differentiate sin x, cos x and powers of x.
  • Factorials: 3! means 3 × 2 × 1 = 6, and 5! = 120.
  • The shape of the sine graph.

What you will be able to do

  • Explain where each term of a Maclaurin series comes from.
  • Write down the series for sin x.
  • Bound the error of a Taylor polynomial.
  • Say what radius of convergence means.

The idea: match the function at one point

We want a polynomial that behaves like sin x near x = 0. Build it one requirement at a time.

  1. Match the value. sin 0 = 0, so the polynomial should be 0 at x = 0.
  2. Match the slope. The derivative of sin x is cos x, and cos 0 = 1. The simplest polynomial with value 0 and slope 1 at the origin is x. That is the first approximation: near zero, sin x ≈ x.
  3. Match the bending. The second derivative is −sin x, which is 0 at the origin, so no x² term is needed.
  4. Match the third derivative. It is −cos x, which is −1 at the origin. Adding the term −x³/6 does this without disturbing what we already matched.

Carry on and you get more terms. Each one matches one more derivative at the origin.

Why the factorials appear

Differentiate xⁿ once and you get nxⁿ⁻¹. Do it n times and you are left with n × (n − 1) × … × 1 = n!. So if you want the nth derivative of your polynomial to equal some number, you must divide the xⁿ term by n! to cancel that factor. This gives the general formula, called the Maclaurin series:

f(x) = f(0) + f′(0)x + f″(0)x²/2! + f‴(0)x³/3! + …

For sin x the derivatives at 0 cycle through 0, 1, 0, −1, so only odd powers survive:

sin x = x − x³/3! + x⁵/5! − x⁷/7! + …

Key words

Maclaurin series
A Taylor series built around the point x = 0.
Taylor polynomial
What you get by stopping the series after a certain power. Also called a partial sum.
Remainder
The gap between the true function and a Taylor polynomial.
Radius of convergence
How far from the centre the series keeps working.
Blue is sin x. Orange, green, dark red and violet are the polynomials of degree 1, 3, 5 and 7. Click a coloured dot to hide or show a curve. Open in the full calculator

Try it yourself

For each step, make a prediction before you move anything. Then check it.

  1. Hide every curve except blue and orange (the straight line y = x). Over what range of x would you say the line is a good match?

    What you should see

    Only close to the origin. By x = 1 the line is at 1 while sin 1 is about 0.84, an error of about 0.16.

  2. Show the green curve, which adds the x³ term. Predict whether it stays close for longer.

    What you should see

    It does. It stays close until about x = 2, where the error is about 0.24.

  3. Show the dark red and violet curves too. What pattern do you see?

    What you should see

    Each extra term keeps the polynomial close for roughly one more unit of x. The degree-7 curve is hard to tell from sin x between −π and π.

  4. Follow any of the polynomials far to the right.

    What you should see

    It eventually runs off the top or bottom of the screen. Every polynomial does this, while sin x stays between −1 and 1. A finite polynomial can only imitate sin x on a limited range.

How good is the approximation?

"Looks close" is not enough for real work. The Lagrange form of the remainder gives a guaranteed limit on the error. If Pn is the polynomial up to xⁿ, then

f(x) − Pn(x) = f(n+1)(ξ) xn+1 / (n + 1)!

for some number ξ between 0 and x. In words: the error looks like the next term of the series, with the derivative taken at some unknown point.

We do not know ξ, but for sin x we do not need to. Every derivative of sin x is ± sin or ± cos, so it is never bigger than 1 in size. That gives a clean bound:

|sin x − Pn(x)| ≤ |x|n+1 / (n + 1)!

Worked example

Bound the error of the degree-7 polynomial at x = 1 and at x = π.

  1. Choose n carefully. The x⁸ term of the series is zero, so the degree-7 polynomial is also the degree-8 polynomial. Using n = 8 gives a tighter bound: |error| ≤ |x|⁹ / 9!.
  2. At x = 1. 1⁹ / 9! = 1 / 362880, about 0.0000028. The polynomial gives sin 1 correct to five decimal places.
  3. At x = π. π⁹ / 9! is about 0.082. So the polynomial is within 0.082 of the true value, which is sin π = 0.

The polynomial actually gives −0.0752 at x = π, comfortably inside the bound. You can read that value from the graph by pointing at the violet curve at x = π.

Does it work for every x?

For any fixed x, the bound |x|n+1 / (n + 1)! shrinks to zero as n grows, because a factorial eventually beats any power. So if you are willing to take enough terms, the series gives sin x as accurately as you like, for every real x. We say its radius of convergence is infinite.

A series that stops working

Not every series is so obliging. Compare

ln(1 + x) = x − x²/2 + x³/3 − x⁴/4 + …

This converges only for x between −1 and 1 (and at x = 1 itself). Its radius of convergence is 1. Plot the partial sums and you see it at once: inside that interval they settle onto the curve, and beyond x = 1 each extra term makes things worse.

Open the ln(1 + x) partial sums in the calculator

The function itself is perfectly well behaved at x = 2. What limits the series is the trouble at x = −1, where ln(1 + x) blows up. That point is 1 unit from the centre, and a power series cannot converge further out than its nearest trouble spot.

Check yourself

Try each one on paper before you open the answer. Getting one wrong is useful: it shows you which part to reread.

  1. Write the first three non-zero terms of the Maclaurin series for cos x.

    Show the answer

    1 − x²/2! + x⁴/4!. The derivatives of cos x at 0 cycle through 1, 0, −1, 0, so only even powers survive.

  2. Estimate sin(0.1) using the first two terms of the series.

    Show the answer

    0.1 − 0.1³/6 = 0.1 − 0.000167 = 0.099833. The true value is 0.0998334, so two terms already give six correct decimal places.

  3. Why does the series for sin x contain only odd powers?

    Show the answer

    Because sin x is an odd function: sin(−x) = −sin x. Even powers of x do not change sign when x does, so they cannot appear.

What to remember