Taylor Series

A Taylor Series is an expansion of a function into an infinite sum of terms, like these ones:

Taylor Series expansion As Sigma Notation
Taylor: e^x = 1 + x + x^2/2! + x^3/3! + ... Taylor: Sigma n=0 to infinity of (x^n)/n!
Taylor: sin x = x - (x^3)/3! + (x^5)/5! + ... Taylor: Sigma n=0 to infinity of [ (-1)^n / (2n+1)! ] times x^(2n+1)
Taylor: cos x = 1 - (x^2)/2! + (x^4)/4! - ... Taylor: Sigma n=0 to infinity of [ (-1)^n / (2n)! ] times x^(2n)
Taylor 1/(1-x) = 1 + x + x^2 + x^3 + ... Taylor: Sigma n=0 to infinity of x^n

(There are many more)


You can use the first few terms of a Taylor Series to get an approximate value for a function.

Here we show better and better approximations for cos(x). The red line is cos(x), the blue is the approximation (try plotting it yourself) :

1 − x2/2! taylor cosine graph 2
1 − x2/2! + x4/4! taylor cosine graph 4
1 − x2/2! + x4/4! − x6/6! taylor cosine graph 6
1 − x2/2! + x4/4! − x6/6! + x8/8! taylor cosine graph 8

(You can also see the Taylor Series in action at Euler's Formula for Complex Numbers.)

What is this Magic?

How can you turn a function into a series of power terms like this?

Well, it isn't really magic. First you say you want to have this:

f(x) = c0 + c1(x-a) + c2(x-a)2 + c3(x-a)3 + ...

Then choose a value "a", and work out the values c0 , c1 , c2 , ... etc

It is done using derivatives ...

Quick review: a derivative gives you the slope of a function at any point.

You must know the derivatives of your function f(x) and these basic derivative rules :

  • The derivative of a constant is 0
  • The derivative of x is 1
  • The derivative of xn is nxn-1 (Example: the derivative of x3 is 3x2)

We will use the little mark to mean "derivative of".

OK, let's start:

To get c0, choose x=a so all the (x-a) terms become zero, leaving you with:

f(a) = c0

So c0 = f(a)

To get c1, take the derivative of f(x):

f(x) = c1 + 2c2(x-a) + 3c3(x-a)2 + ...

With x=a all the (x-a) terms become zero:

f(a) = c1

So c1 = f(a)

To get c2, do the derivative again:

f(x) = 2c2 + 3×2×c3(x-a) + ...

With x=a all the (x-a) terms become zero:

f(a) = 2c2

So c2 = f(a)/2

In fact, a pattern is emerging. Each term is

  • the next higher derivative ...
  • ... divided by all the exponents so far multiplied together (for which we can use factorial notation, for example 3! = 3×2×1)

And we get:

f(x) = f(a) + f-(a)/1! times (x-a) + f--(a)/2! times (x-a)^2 + f---(a)/3! times (x-a)^3 + ...

Now we have a way of finding our own Taylor Series: keep taking derivatives and divide by n! each time.


Example: Taylor Series for cos(x)

And all we need to know is:

  • The derivative of cos(x) is -sin(x)
  • The derivative of sin(x) is cos(x)

Choose a=0:

  • c0 = f(0) = cos(0) = 1
  • c1 = f'(0)/1! = -sin(0) = 0
  • c2 = f''(0)/2! = -cos(0)/2! = -1/2!
  • c3 = f'''(0)/3! = sin(0)/3! = 0
  • c4 = f''''(0)/4! = cos(0)/4! = 1/4!
  • etc...

The odd terms are all zero, so we get:

cos(x) = 1 − x2/2! + x4/4! − ...

Try that for sin(x) yourself, it will help you to learn.

Or try it on another function of your choosing. The key thing is that you be able to take derivatives of your function f(x).


Note: A Maclaurin Series is a Taylor Series where a=0, so all the examples we have been using so far can also be called Maclaurin Series.