# How to use Taylor Polynomials to Approximate a Function

Taylor polynomials can be used to approximate a function around any value for a differentiable function. Taylor polynomials look a little ugly, but if you break them down into small steps, it’s actually a fast way to approximate a function.

Taylor polynomials can be used to approximate any differentiable function.

Sample problem: Use Taylor polynomials to approximate the function cos(x) around the point x=2.
Step 1: Evaluate the function for the first part of the Taylor polynomial:

p(x) = f(c) o! = cos(2)

Step 2: Evaluate the function for the second part of the Taylor polynomial (adding it to the first part from Step 1):

p(x) = cos(2) + f'(c) 1!(x-c) = cos(2) – sin(2)(x-2)

Step 3: Evaluate the function for the third part of the Taylor polynomial (adding it to the first and second parts from Step 2):

p(x) = cos(2) – sin(2)(x-2) + f”(c)2!(x-c)2 = cos(2) – sin(2)(x-2) – cos(2) 2(x-2)2
Step 4: Evaluate the function for the fourth part of the Taylor polynomial (adding it to the first, second and third parts from Step 3):

p(x) = cos(2) – sin(2)(x-2) + f”'(c)3!(x-c)3 = cos(2) – sin(2)(x-2) – cos(2) 2(x-2)2sin(2)6 (x-2)3

Step 5: Continue evaluating more pieces of the Taylor polynomial, graphing the function periodically to see how well it represents your polynomial.

Graph of the Taylor approximation for cos(x) near x=2 after four iterations.

Tip: Technically, you could go on forever with iterations of the Taylor polynomial, but usually five or six iterations is sufficient for a good approximation

------------------------------------------------------------------------------

If you prefer an online interactive environment to learn R and statistics, this free R Tutorial by Datacamp is a great way to get started. If you're are somewhat comfortable with R and are interested in going deeper into Statistics, try this Statistics with R track.