Taylor Polynomial

Suppose that we have n-th degree polynomial p(x)=a0+a1(xa)+a2(xa)2++an1(xa)n1+an(xa)n{p}{\left({x}\right)}={a}_{{0}}+{a}_{{1}}{\left({x}-{a}\right)}+{a}_{{2}}{{\left({x}-{a}\right)}}^{{2}}+\ldots+{a}_{{{n}-{1}}}{{\left({x}-{a}\right)}}^{{{n}-{1}}}+{a}_{{n}}{{\left({x}-{a}\right)}}^{{n}}, where a,a0,a1,a2,,an{a},{a}_{{0}},{a}_{{1}},{a}_{{2}},\ldots,{a}_{{n}} are constants.

Now, differentiate this polynomial n{n} times:

p(x)=a1+2a2(xa)+3a3(xa)2++(n1)an1(xa)n2+nan(xa)n1{p}'{\left({x}\right)}={a}_{{1}}+{2}\cdot{a}_{{2}}{\left({x}-{a}\right)}+{3}\cdot{a}_{{3}}{{\left({x}-{a}\right)}}^{{2}}+\ldots+{\left({n}-{1}\right)}\cdot{a}_{{{n}-{1}}}{{\left({x}-{a}\right)}}^{{{n}-{2}}}+{n}\cdot{a}_{{n}}{{\left({x}-{a}\right)}}^{{{n}-{1}}},

p(x)=12a2+23a3(xa)++(n2)(n1)an1(xa)n3+(n1)nan(xa)n2{p}''{\left({x}\right)}={1}\cdot{2}\cdot{a}_{{2}}+{2}\cdot{3}\cdot{a}_{{3}}{\left({x}-{a}\right)}+\ldots+{\left({n}-{2}\right)}{\left({n}-{1}\right)}{a}_{{{n}-{1}}}{{\left({x}-{a}\right)}}^{{{n}-{3}}}+{\left({n}-{1}\right)}{n}{a}_{{n}}{{\left({x}-{a}\right)}}^{{{n}-{2}}},

p(x)=123a3++(n3)(n2)(n1)an1(xa)n4+(n2)(n1)nan(xa)n3{p}'''{\left({x}\right)}={1}\cdot{2}\cdot{3}\cdot{a}_{{3}}+\ldots+{\left({n}-{3}\right)}{\left({n}-{2}\right)}{\left({n}-{1}\right)}{a}_{{{n}-{1}}}{{\left({x}-{a}\right)}}^{{{n}-{4}}}+{\left({n}-{2}\right)}{\left({n}-{1}\right)}{n}{a}_{{n}}{{\left({x}-{a}\right)}}^{{{n}-{3}}},

\ldots\ldots\ldots\ldots\ldots\ldots\ldots\ldots\ldots\ldots

p(n)(x)=123nan{{p}}^{{{\left({n}\right)}}}{\left({x}\right)}={1}\cdot{2}\cdot{3}\cdot\ldots\cdot{n}\cdot{a}_{{n}}.

If we now plug a{a} instead of x{x} in polynomial and all its derivatives we will obtain that

p(a)=a0{p}{\left({a}\right)}={a}_{{0}}, p(a)=a1{p}'{\left({a}\right)}={a}_{{1}}, p(a)=12a2{p}''{\left({a}\right)}={1}\cdot{2}\cdot{a}_{{2}}, p(a)=123a3{p}'''{\left({a}\right)}={1}\cdot{2}\cdot{3}\cdot{a}_{{3}}, ..., p(n)(a)=123nan{{p}}^{{{\left({n}\right)}}}{\left({a}\right)}={1}\cdot{2}\cdot{3}\cdot\ldots\cdot{n}\cdot{a}_{{n}}.

Since factorial of number is n!=123n{n}!={1}\cdot{2}\cdot{3}\cdot\ldots\cdot{n} then

a0=p(a){a}_{{0}}={p}{\left({a}\right)}, a1=p(a)1!{a}_{{1}}=\frac{{{p}'{\left({a}\right)}}}{{{1}!}}, a2=p(a)2!{a}_{{2}}=\frac{{{p}''{\left({a}\right)}}}{{{2}!}}, ..., an=p(n)(a)n!{a}_{{n}}=\frac{{{{p}}^{{{\left({n}\right)}}}{\left({a}\right)}}}{{{n}!}}.

If we now substitute expressions for constants into polynomial we will obtain Taylor Fomula.

Taylor Formula for Polynomials. Polynomialp(x)=p(a)+p(a)1!(xa)+p(a)2!(xa)2++p(n1)(a)(n1)!(xa)n1+p(n)(a)n!(xa)n{p}{\left({x}\right)}={p}{\left({a}\right)}+\frac{{{p}'{\left({a}\right)}}}{{{1}!}}{\left({x}-{a}\right)}+\frac{{{p}''{\left({a}\right)}}}{{{2}!}}{{\left({x}-{a}\right)}}^{{2}}+\ldots+\frac{{{{p}}^{{{\left({n}-{1}\right)}}}{\left({a}\right)}}}{{{\left({n}-{1}\right)}!}}{{\left({x}-{a}\right)}}^{{{n}-{1}}}+\frac{{{{p}}^{{{\left({n}\right)}}}{\left({a}\right)}}}{{{n}!}}{{\left({x}-{a}\right)}}^{{n}}. is called taylor polynomial at x=a{x}={a}.

With the help of Taylor formula we can write any polynomial in terms of (xa){\left({x}-{a}\right)}.

Example 1. Write polynomial p(x)=x3+3x22x+1{p}{\left({x}\right)}={{x}}^{{3}}+{3}{{x}}^{{2}}-{2}{x}+{1} in terms of (x2){\left({x}-{2}\right)}.

Here a=2{a}={2}.

We have that p(x)=3x2+6x2{p}'{\left({x}\right)}={3}{{x}}^{{2}}+{6}{x}-{2}, p(x)=6x+6{p}''{\left({x}\right)}={6}{x}+{6}, p(x)=6{p}'''{\left({x}\right)}={6}. All higher-order derivatives will equal 0.

Now, p(2)=23+32223+1=17{p}{\left({2}\right)}={{2}}^{{3}}+{3}\cdot{{2}}^{{2}}-{2}\cdot{3}+{1}={17}, p(2)=322+622=22{p}'{\left({2}\right)}={3}\cdot{{2}}^{{2}}+{6}\cdot{2}-{2}={22}, p(2)=62+6=18{p}''{\left({2}\right)}={6}\cdot{2}+{6}={18}, p(2)=6{p}'''{\left({2}\right)}={6}.

So,

p(x)=17+221!(x2)+182!(x2)2+63!(x2)3=17+22(x2)+9(x2)2+(x2)3{p}{\left({x}\right)}={17}+\frac{{{22}}}{{{1}!}}{\left({x}-{2}\right)}+\frac{{{18}}}{{{2}!}}{{\left({x}-{2}\right)}}^{{2}}+\frac{{{6}}}{{{3}!}}{{\left({x}-{2}\right)}}^{{3}}={17}+{22}{\left({x}-{2}\right)}+{9}{{\left({x}-{2}\right)}}^{{2}}+{{\left({x}-{2}\right)}}^{{3}}.

So, equivalently polynomial p(x)=x3+3x22x+1{p}{\left({x}\right)}={{x}}^{{3}}+{3}{{x}}^{{2}}-{2}{x}+{1} can be written as p(x)=(x2)3+9(x2)2+22(x2)+17{p}{\left({x}\right)}={{\left({x}-{2}\right)}}^{{3}}+{9}{{\left({x}-{2}\right)}}^{{2}}+{22}{\left({x}-{2}\right)}+{17}.

Thus, Taylor formula for polynomials allows us to rewrite any polynomial in terms of (xa){\left({x}-{a}\right)}.

Now, let's see how we can use this idea for any differentiable functions.

Suppose that function y=f(x){y}={f{{\left({x}\right)}}} has finite derivatives up to n-th order at point a{a}.

Taylor Formula for any Function. For function y=f(x){y}={f{{\left({x}\right)}}} n-th degree Taylor polynomial at point x=a{x}={a} is Tn(x)=f(a)+f(a)1!(xa)+f(a)2!(xa)2++f(n1)(a)(n1)!(xa)n1+f(n)(a)n!(xa)n{T}_{{n}}{\left({x}\right)}={f{{\left({a}\right)}}}+\frac{{{f{'}}{\left({a}\right)}}}{{{1}!}}{\left({x}-{a}\right)}+\frac{{{f{''}}{\left({a}\right)}}}{{{2}!}}{{\left({x}-{a}\right)}}^{{2}}+\ldots+\frac{{{{f}}^{{{\left({n}-{1}\right)}}}{\left({a}\right)}}}{{{\left({n}-{1}\right)}!}}{{\left({x}-{a}\right)}}^{{{n}-{1}}}+\frac{{{{f}}^{{{\left({n}\right)}}}{\left({a}\right)}}}{{{n}!}}{{\left({x}-{a}\right)}}^{{n}}.

Of course, Tn(x)f(x){T}_{{n}}{\left({x}\right)}\ne{f{{\left({x}\right)}}}, but as appeared Tn(x){T}_{{n}}{\left({x}\right)} is a very good approximation for f(x){f{{\left({x}\right)}}} when xa{x}\to{a}. And the higher n{n} (order of polynomial) the better approximation.

Fact. Tn(x)f(x){T}_{{n}}{\left({x}\right)}\approx{f{{\left({x}\right)}}} as xa{x}\to{a}.

This fact allows us to approximate function by polynomial near point x=a{x}={a} with any precision we want, by taking high degree polynomial.

Example 2. Find first, third and fifth degree polynomials for function f(x)=sin(x){f{{\left({x}\right)}}}={\sin{{\left({x}\right)}}} near taylor polynomialx=0{x}={0}.

Here a=0{a}={0}.

To find fifth degree polynomial we need derivatives up to fifth order.

We have that f(x)=cos(x){f{'}}{\left({x}\right)}={\cos{{\left({x}\right)}}}, f(x)=sin(x){f{''}}{\left({x}\right)}=-{\sin{{\left({x}\right)}}}, f(x)=cos(x){f{'''}}{\left({x}\right)}=-{\cos{{\left({x}\right)}}}, f(4)(x)=sin(x){{f}}^{{{\left({4}\right)}}}{\left({x}\right)}={\sin{{\left({x}\right)}}}, f(5)(x)=cos(x).{{f}}^{{{\left({5}\right)}}}{\left({x}\right)}={\cos{{\left({x}\right)}}}.

Now, f(0)=0{f{{\left({0}\right)}}}={0}, f(0)=1{f{'}}{\left({0}\right)}={1}, f(0)=0{f{''}}{\left({0}\right)}={0}, f(0)=1{f{'''}}{\left({0}\right)}=-{1}, f(4)(0)=0{{f}}^{{{\left({4}\right)}}}{\left({0}\right)}={0}, f(5)(0)=1{{f}}^{{{\left({5}\right)}}}{\left({0}\right)}={1}.

First degree taylor polynomial is T1(x)=f(0)+f(0)1!(x0)=0+11x=x{T}_{{1}}{\left({x}\right)}={f{{\left({0}\right)}}}+\frac{{{f{'}}{\left({0}\right)}}}{{{1}!}}{\left({x}-{0}\right)}={0}+\frac{{1}}{{1}}{x}={x}.

Third degree taylor polynomial is T3(x)=f(0)+f(0)1!(x0)+f(0)2!(x0)2+f(0)3!(x0)3=0+11x+02x2+16x3=xx36{T}_{{3}}{\left({x}\right)}={f{{\left({0}\right)}}}+\frac{{{f{'}}{\left({0}\right)}}}{{{1}!}}{\left({x}-{0}\right)}+\frac{{{f{''}}{\left({0}\right)}}}{{{2}!}}{{\left({x}-{0}\right)}}^{{2}}+\frac{{{f{'''}}{\left({0}\right)}}}{{{3}!}}{{\left({x}-{0}\right)}}^{{3}}={0}+\frac{{1}}{{1}}{x}+\frac{{0}}{{{2}}}{{x}}^{{2}}+\frac{{-{1}}}{{{6}}}{{x}}^{{3}}={x}-\frac{{{{x}}^{{3}}}}{{6}}.

Fifth degree taylor polynomial is T5(x)=f(0)+f(0)1!(x0)+f(0)2!(x0)2+f(0)3!(x0)3+f(4)(0)4!(x0)4+f(5)(0)5!(x0)5={T}_{{5}}{\left({x}\right)}={f{{\left({0}\right)}}}+\frac{{{f{'}}{\left({0}\right)}}}{{{1}!}}{\left({x}-{0}\right)}+\frac{{{f{''}}{\left({0}\right)}}}{{{2}!}}{{\left({x}-{0}\right)}}^{{2}}+\frac{{{f{'''}}{\left({0}\right)}}}{{{3}!}}{{\left({x}-{0}\right)}}^{{3}}+\frac{{{{f}}^{{{\left({4}\right)}}}{\left({0}\right)}}}{{{4}!}}{{\left({x}-{0}\right)}}^{{4}}+\frac{{{{f}}^{{{\left({5}\right)}}}{\left({0}\right)}}}{{{5}!}}{{\left({x}-{0}\right)}}^{{5}}=

=0+11x+02x2+16x3+04!x4+1120x5=xx36+x5120={0}+\frac{{1}}{{1}}{x}+\frac{{0}}{{{2}}}{{x}}^{{2}}+\frac{{-{1}}}{{{6}}}{{x}}^{{3}}+\frac{{0}}{{{4}!}}{{x}}^{{4}}+\frac{{1}}{{{120}}}{{x}}^{{5}}={x}-\frac{{{{x}}^{{3}}}}{{6}}+\frac{{{{x}}^{{5}}}}{{{120}}}.

So,

T1(x)=x{T}_{{1}}{\left({x}\right)}={x}, T3(x)=xx36{T}_{{3}}{\left({x}\right)}={x}-\frac{{{{x}}^{{3}}}}{{6}}, T5(x)=xx36+x5120{T}_{{5}}{\left({x}\right)}={x}-\frac{{{{x}}^{{3}}}}{{6}}+\frac{{{{x}}^{{5}}}}{{120}}.

Remember, the higher degree of polynomial, the better precision. Figure illustrates this. Note, that approximation good only near point of expansion, in this case a=0{a}={0}.