The Taylor series of a function is a power series that has the same values as the function on some interval. We studied Taylor series in Sections 10.8 of Stein's textbook. This lab shows how Mathematica works with Taylor series. Pages 216-222 in the Crooke/Ratcliffe Guidebook cover some of this material.
The last term, O[x]^9, is an asymptotic experssion. It merely indicates that the complete Taylor series consists of the preceding polynomial followed by terms all of which have x^9 as a factor.
Notice that the sine's Taylor polynomial only has terms with odd powers (1, 3, 5, 7, etc.). That is because the sine is an "odd" function: sin(-x) = - sin x. Its graph is symmetric about the origin, and so are the graphs of all its Taylor polynomials.
The Taylor polynomial of degree 1 is simply the line y = x
:[font = input; preserveAspect; ]
Plot[ {f[x],P[x]}, {x,-Pi,Pi} ];
:[font = text; inactive; preserveAspect; ]
These two functions, y = sin x and y = x, have the same Y-intercept (0) and the same slope (1) at x=0. In other words, P[x] is the best-fitting polynomial of degree 1.
It is the best-fitting (near x=0) polynomial of degree 3.
:[font = text; inactive; preserveAspect; ]
Here is the best fitting polynomial of degree 5
:[font = input; preserveAspect; ]
P[x_] = Normal[ Series[ f[x], {x,0,5} ] ]
:[font = input; preserveAspect; ]
Plot[ {f[x],P[x]}, {x,-Pi,Pi} ];
:[font = text; inactive; preserveAspect; ]
Notice, as the degree of the Taylor polynomial increases, the extent to which the polynomial and the sine curve agree expands.
:[font = text; inactive; preserveAspect; ]
Here is the Taylor polynomial of degree 7
:[font = input; preserveAspect; ]
P[x_] = Normal[ Series[ f[x], {x,0,7} ] ]
:[font = input; preserveAspect; ]
Plot[ {f[x],P[x]}, {x,-Pi,Pi} ];
:[font = text; inactive; preserveAspect; ]
These two graphs seem to coincide on almost the entire interval.
:[font = input; preserveAspect; ]
P[x_] = Normal[ Series[ f[x], {x,0,9} ] ]
:[font = input; preserveAspect; ]
Plot[ {f[x],P[x]}, {x,-Pi,Pi} ];
:[font = text; inactive; preserveAspect; ]
Now the two curves seem indistinguishable throughout the interval [-Pi,Pi]. Actually, P[x] = f[x] only at x=0. But they are so close at other x-values in this interval that their graphs cannot be distinguished at this resolution.
To get a better estimate on the extent to which the function and its polynomial agree, click on the graph, and then move the cursor (with the mouse) near the place where the curves separate, while holding down the Command key. You will see the coordinates of the cursor displayed at the lower right corner of the window. This way, you should be able to conclude that the two curves agree on the interval -1.7 £ x £ 1.7, approximately.
Compare each of the following functions with its Taylor polynomials centered at x=0. Determine the interval on which the function agrees with its 5th Taylor polynomial
Taylor's Theorem gives us a remainder term that allows us to estimate how far apart the function is from its Taylor polynomial at any x. The (Cauchy) formula for the remainder term is:
R = M x^(n+1)/(n+1)!
where M is a bound on the absolute value of the (n+1)st derivative of f on the given interval.
To apply the remainder formula, we first need to get a bound M on the absolute value of the (n+1)st derivative. In many case, that is very difficult, and in some cases impossible. However, for the sine function it is trivial: since -1 £ sin x £ 1 and -1 £ cos x £ 1 for all x, all dreivatives of the sine are bounded between -1 and 1. So the value M=1 is a valid bound. Thus, the remainder from using the nth Taylor polynomial to approximate the sine function at x is:
So, suppose now that we want to approximate the sine function by one of its Taylor polynomials, and we want the approximation to be correct to 8 decimal places for all x between -Pi and Pi. Which Taylor polynomials will give us that degree of accuracy?
This shows that, once n is greater than 18, the remainder R[n,x] will be less than 5*10^-9. Thus, if we use the 19th Taylor polynomial to approximate sin x, then our approximations will be correct to 8 decimal places for all x between -Pi and Pi.
Now we can verify our conclusion directly. Here is a table of value for f[x], P[x], and their difference, for values of x near Pi (where the difference will be the greatest)