Taylor Interpolation

Andy Long
Northern Kentucky University
longa@nku.edu
3/26/15

Let’s interpolate function f (and several of its derivatives) with a Taylor series polynomial:

f[x_]:=Sin[x]

We’ll expand around x=a, and look at an nth degree polynomial:

a=0;
n=9;

We want to create a function out of the Taylor series polynomial, and this works:

Normal[Series[f[x],{x,a,n}]]
HornerForm[Normal[Series[f[x],{x,a,n}]]]
P[n_,f_,a_,x_]:=HornerForm[Normal[Series[f[t],{t,a,n}]]]/.t->x

Now we’ll just plot f and p, to see how well we’re doing:

Plot[{f[x],P[n,f,a,x]},{x,0,Pi/2}]
Plot[f[x]-P[n,f,a,x],{x,0,Pi/2},PlotRange->{{0,Pi/2},{-3*10^-5,0}}]

We’ll expand around x=a, and look at an nth degree polynomial:

a=Pi/4;
n=6;

We want to create a function out of the Taylor series polynomial, and this works:

Normal[Series[f[x],{x,a,n}]]
P[n_,f_,a_,x_]:=Normal[Series[f[t],{t,a,n}]]/.t->x

Now we’ll just plot f and p, to see how well we’re doing:

Horner

Plot[{f[x],P[n,f,a,x]},{x,0,Pi/2}]
Plot[f[x]-P[n,f,a,x],{x,0,Pi/2},PlotRange->{{0,Pi/2},{-3*10^-5,3*10^-5}}]