Reading:  

Calculus


Using Taylor Series to Approximate Functions

Using Taylor Series to Approximate Functions

Sam is conducting an experiment. He's interested in the rate of decay of a banana that he left in his lunch box at the end of last term. He decides to use the exponential decay function

B(t)=2e0.5t
to model the amount of banana left after t days. He plans to compare the mass of banana remaining with the values given by his function each day. However, he has lost his calculator, and wants to find a way to calculate the values of his function with pen and paper.

Luckily, we can approximate functions like ex using Taylor series. Taylor series can be thought of as polynomials with an infinite number of terms. To approximate function values, we just evaluate the sum of the first few terms of the Taylor series. For nicely behaved functions, taking more terms of the Taylor series will give a better approximation.

Example:

The Taylor series of y=ex is

ex=1+x+x22!+x33!+
Taylor's theorem tells us that the function y=ex is equal to the infinite sum 1+x+x22!+x33!+ for all values of x. Recall that n! is equal to n×(n1)×(n2)××1.

Let's try some approximations of ex at x=1 using this Taylor series. We should expect that the values will eventually match up with e=2.71828.

Number of Terms Part of Taylor Series Value at x=1
1 1 1
2 1+x 2
3 1+x+x22! 2.5
4 1+x+x22!+x33! 2.66667
5 1+x+x22!+x33!+x44! 2.70833

You can see that the approximations are getting closer and closer to e=2.71828.

Commonly Used Taylor Series

Functions like sinx and cosx are commonly used in signal processing, so it's important to be able to approximate them. Here is a list of a few commonly used functions, and their Taylor series.

Function Taylor Series Taylor Series in Summation Notation
ex 1+x+x22!+x33!+ n=0xnn!
ex 1x+x22!x33!+ n=0(1)nn!xn
sinx xx33!+x55! n=0(1)n(2n+1)!x2n+1
cosx 1x22!+x44! n=0(1)n(2n)!x2n
11x for \(|x| 1+x+x2+x3+ n=0xn

Of course, these are only a few of the many possible Taylor series that can be used to approximate functions.

Looking at the Approximations Graphically

As I said earlier, you can use the first few terms of the Taylor Series of a function to approximate it. If you take more terms, and the function behaves properly, you get a better approximation.

Let's see this in action on the graph of y=sinx. At each step, the red graph is the graph of sinx and the blue graph is the graph of the Taylor Series approximation.

x
Using Taylor Series to Approximate Functions
xx33!
Using Taylor Series to Approximate Functions
xx33!+x55!
Using Taylor Series to Approximate Functions
xx33!+x55!x77!
Using Taylor Series to Approximate Functions

How do we find these polynomials?

This idea was thought up by some very clever people: a Scottish mathematician, James Gregory, and an English mathematician, Brook Taylor, back in the 18th Century. There's nothing very mysterious about finding Taylor series, just a number of steps to follow:

  1. Decide you'd like to find a series to approximate your function: f(a)=c0+c1(xa)+c2(xa)2+.
  2. Choose a value of a.
  3. Use derivatives to work out the values of c0,c1,c2,.
See, there's nothing to it! Well, maybe we need to do a bit of work. Let's have a look at the procedure in more detail:

To find c0, set x=a. Then our infinite series approximation collapses to

f(a)=c0
because all the terms involving (xa) vanish.

Now, we need to find c1. We take the derivative of both sides of our infinite series approximation:

f(x)=c1+2c2(xa)+3c3(xa)2+
Next, we plug in x=a. All those pesky terms with (xa) in them will vanish, and we'll be left with
f(a)=c1

To find c2, we need to take the derivative again:

f(x)=2c2(xa)+3×2c3(xa)+
Setting x=a yields
f(a)=2c2
so that
c2=f(a)2.

We should start to see a pattern now. The coefficient cn is found by

  • taking the nth derivative f(n)(a) and
  • dividing it by the product of the powers of all the preceding terms (i.e. n!=n×(n1)××2×1).
So the Taylor series is
f(x)=f(a)+f(a)1!(xa)+f(a)2!(xa)2+f(a)3!(xa)3+
and we have a way of building our very own Taylor series:
We find the nth term by taking the n th derivative, evaluating it at a, dividing it by n!, and multiplying it by (xa)n.

Example: The Taylor Series for sin(x)

Let's start with

f(x)=f(a)+f(a)1!(xa)+f(a)2!(xa)2+f(a)3!(xa)3+
and fill in the blanks. We need to find lots of derivatives of sin(x). That's actually much easier than it sounds because the derivative of sinx is cosx and the derivative of cosx is sinx, so the derivatives we need go through a cycle:
  • f(x)=cosx
  • f(x)=sinx
  • f(x)=cosx
  • f(iv)(x)=sinx
and we start all over again...
So, our series looks like:
f(x)=sin(a)+cos(a)1!(xa)sin(a)2!(xa)2cos(a)3!(xa)3+sin(a)4!(xa)4+
Now we need to choose a value for a. A commonly chosen value is a=0. This would give sin(0)=0 and cos(0)=1, so it's a good choice. Let's see what this does to our series:
f(x)=11!x13!x3+15!x5

Do you notice how all the terms with even powers of x have vanished? This is good because sin(x) is an odd function, so we'd expect its polynomial approximations to include only odd powers of x. Take a look at the article on odd and even functions if you feel like you need a refresher on these important types of functions.

Stuff for you to do:

Why not have a go at finding the Taylor Series of cosx and ex? It will help you to fix these ideas in your head.

Historical Note:

Taylor Series with a=0 are often called Maclaurin Series after the Scottish mathematician, Colin Maclaurin who did a great deal of work with them in the 18th Century.

Oh, and what about Sam? He can use a few terms of the Taylor Series for ex and multiply them by 2. He can then plug in x=d2 to approximate the amount of his banana that's left on day d. However, both his mum and I agree that it's better to eat the banana in the first place or, at the very least, to throw it out as soon as it goes mouldy.

Description

Calculus is the branch of mathematics that deals with the finding and properties of derivatives and integrals of functions, by methods originally based on the summation of infinitesimal differences. The two main types are differential calculus and integral calculus.

 



Environment

It is considered a good practice to take notes and revise what you learnt and practice it.

Audience

Grade 9+ Students

Learning Objectives

Familiarize yourself with Calculus topics such as Limits, Functions, Differentiability etc

Author: Subject Coach
Added on: 23rd Nov 2017

You must be logged in as Student to ask a Question.

None just yet!