Week 8 Discussion Notes

Table of Contents

Error Bound for Taylor Polynomial

Recall that the purpose of a Taylor polynomial is to approximate a function ff near some point aa (called the center of the polynomial). So naturally, we want to have a rough idea of how good the estimate is, which leads to the following result:

Theorem (error bound)

Let f(x)f\p{x} be differentiable (at least) n+1n+1 times, and let Tnf(x)T_nf\p{x} be the nn-th degree Taylor polynomial of ff centered at aa. Then

Tnf(x)f(x)K(n+1)!xan+1,\abs{T_nf\p{x} - f\p{x}} \leq \frac{K}{\p{n+1}!} \abs{x - a}^{n+1},

where KK is an upper bound for f(n+1)\abs{f^{\p{n+1}}} between xx and aa, i.e., on the interval [a,x]\br{a, x} or [x,a]\br{x, a}, depending on whether axa \leq x or xax \leq a.

Example 1.

Find nn such that

cos0.1Tn(0.1)107\abs{\cos{0.1} - T_n\p{0.1}} \leq 10^{-7}

where TnT_n is the nn-th degree Taylor polynomial of cosx\cos{x} centered at a=0a = 0.

Solution.

To use the error bound, we just need to figure out what to use for KK, meaning we need an upper bound for cos(n+1)(x)\cos^{\p{n+1}}\p{x} on the interval [0,0.1]\br{0, 0.1}. In this case, the derivatives of cosx\cos{x} are ±sinx\pm\sin{x} or ±cosx\pm\cos{x}, so no matter what nn is, we know

cos(n+1)(x)1.\abs{\cos^{\p{n+1}}\p{x}} \leq 1.

Thus, K=1K = 1 works (but anything larger than 11 could also work, e.g., you could use K=10K = 10 or 2020 if you wanted to). Plugging this into the error bound,

cos0.1Tn(0.1)0.1n+1(n+1)!\abs{\cos{0.1} - T_n\p{0.1}} \leq \frac{0.1^{n+1}}{\p{n+1}!}

and we want this to be less than 10710^{-7}. From here, you just need to plug in values for nn until you get something that works:

n0.1n+1(n+1)!15.00×10321.67×10434.17×10648.33×108\begin{array}{rcr} \hline \\[-2ex] n && \dfrac{0.1^{n+1}}{\p{n+1}!} \\[2.5ex]\hline \\[-2ex] 1 && 5.00 \times 10^{-3} \\ 2 && \approx 1.67 \times 10^{-4} \\ 3 && \approx 4.17 \times 10^{-6} \\ 4 && \approx 8.33 \times 10^{-8} \\[0.5ex]\hline \end{array}

So, the first nn that works is n=4\boxed{n = 4}. (You can also use any bigger values of nn.)

Example 2.

Let f(x)=lnxf\p{x} = \ln{x} and Tnf(x)T_nf\p{x} be the nn-th degree Taylor polynomial of ff centered at a=1a = 1. If c>1c > 1, show that

lncTn(c)c1n+1n+1.\abs{\ln{c} - T_n\p{c}} \leq \frac{\abs{c - 1}^{n+1}}{n+1}.
Solution.

As you can guess, we're going to want to use the error bound again, so as before, we need to find an upper bound KK for f(n+1)\abs{f^{\p{n+1}}} on the interval [1,c]\br{1, c}. For the first couple derivatives, we get

f(x)=1xf(x)=1x2f(x)=2x3f(4)(x)=32x4\begin{aligned} f'\p{x} &= \phantom{-}\frac{1}{x} \\ f''\p{x} &= -\frac{1}{x^2} \\ f'''\p{x} &= \phantom{-}\frac{2}{x^3} \\ f^{\p{4}}\p{x} &= -\frac{3 \cdot 2}{x^4} \\ &\,\,\,\vdots \end{aligned}

So, the pattern is

f(n)(x)=(1)n1(n1)!xn    f(n+1)(x)=n!xn+1.f^{\p{n}}\p{x} = \p{-1}^{n-1} \frac{\p{n-1}!}{x^n} \implies \abs{f^{\p{n+1}}\p{x}} = \frac{n!}{\abs{x}^{n+1}}.

To find KK, we need to find an upper bound for this function on the interval [1,c]\br{1, c}. To get something as big as possible, we can try to make the denominator as small as possible on this interval, i.e., x=1x = 1 should give us an upper bound:

f(n+1)(x)f(n+1)(1)=n!,\abs{f^{\p{n+1}}\p{x}} \leq \abs{f^{\p{n+1}}\p{1}} = n!,

so K=n!K = n! works. Thus, the error bound gives

lncTn(c)n!c1n+1(n+1)!=c1n+1n+1.\abs{\ln{c} - T_n\p{c}} \leq \frac{n!\abs{c - 1}^{n+1}}{\p{n+1}!} = \frac{\abs{c - 1}^{n+1}}{n + 1}.

Taylor Series

Definition

Let f(x)f\p{x} be infinitely differentiable at x=ax = a. Then its Taylor series centered at x=ax = a is

T(x)=n=0f(n)(a)n!(xa)n.T\p{x} = \sum_{n=0}^\infty \frac{f^{\p{n}}\p{a}}{n!}\p{x - a}^n.

Warning: It's important to distinguish ff from its Taylor series. Here's an important fact:

  1. Every infinitely differentiable function ff has a Taylor series (you can always make one using the formula in the definition).
  2. Not every function ff is represented by its Taylor series, i.e., the Taylor series might not always converge to ff itself.
Example 3.

Let

f(x)={e1/x2if x0,0if x=0.f\p{x} = \begin{cases} e^{-1/x^2} & \text{if } x \neq 0, \\ 0 & \text{if } x = 0. \end{cases}

This function has the property that f(n)(0)=0f^{\p{n}}\p{0} = 0, which means that its Taylor series centered at a=0a = 0 is

Tf(x)=n=00n!xn=0,Tf\p{x} = \sum_{n=0}^\infty \frac{0}{n!} x^n = 0,

i.e., TfTf converges to the constant function 00 everywhere. However, f(x)0f\p{x} \neq 0 anywhere except x=0x = 0.

f(x)f\p{x} is an example of a function with a Taylor series that converges everywhere, but agrees with f(x)f\p{x} at the center and nowhere else.

Despite this, Taylor series are still useful in a lot of cases. We already know a couple of functions that are represented by its Taylor series:

f(x)=T(x)11x=n=0xn=1+x+x2+x3+for x(1,1)ex=n=0xnn!=1+x+x22!+x33!+for xRsinx=n=0(1)nx2n+1(2n+1)!=xx33!+x55!x77!+for xRcosx=n=0(1)nx2n(2n)!=1x22!+x44!x66!+for xR\begin{array}{rcllll} \hline \\[-2ex] f\p{x} & = & T\p{x} \\[1ex] \hline \\[-2ex] \displaystyle\frac{1}{1 - x} & = & \displaystyle\sum_{n=0}^\infty x^n & = & \displaystyle 1 + x + x^2 + x^3 + \cdots & \text{for } x \in \p{-1, 1} \\[3ex] e^x & = & \displaystyle\sum_{n=0}^\infty \frac{x^n}{n!} & = & \displaystyle 1 + x + \frac{x^2}{2!} + \frac{x^3}{3!} + \cdots & \text{for } x \in \R \\[3ex] \sin{x} & = & \displaystyle\sum_{n=0}^\infty \p{-1}^n\frac{x^{2n+1}}{\p{2n+1}!} & = & \displaystyle x - \frac{x^3}{3!} + \frac{x^5}{5!} - \frac{x^7}{7!} + \cdots & \text{for } x \in \R \\[3ex] \cos{x} & = & \displaystyle\sum_{n=0}^\infty \p{-1}^n\frac{x^{2n}}{\p{2n}!} & = & \displaystyle 1 - \frac{x^2}{2!} + \frac{x^4}{4!} - \frac{x^6}{6!} + \cdots & \text{for } x \in \R \\[3ex]\hline \end{array}

It's good to have these off the top of your head since they can be useful for calculating series.

Example 4.

Calculate

1π2422!+π4444!π6466!+.1 - \frac{\pi^2}{4^2 \cdot 2!} + \frac{\pi^4}{4^4 \cdot 4!} - \frac{\pi^6}{4^6 \cdot 6!} + \cdots.
Solution.

When given a series with its terms written out, you should try to write it in sigma notation:

n=0(1)nπ2n42n(2n)!.\sum_{n=0}^\infty \p{-1}^n \frac{\pi^{2n}}{4^{2n} \cdot \p{2n}!}.

From here, you should hopefully recognize the Taylor series expansion for cosx\cos{x}. If you stare at it, you'll see that its the Taylor series with x=π2x = \frac{\pi}{2} plugged in:

1π2422!+π4444!π6466!+=n=0(1)nπ2n42n(2n)!=n=0(1)n(π4)2n(2n)!=cos(π4)=12.\begin{aligned} 1 - \frac{\pi^2}{4^2 \cdot 2!} + \frac{\pi^4}{4^4 \cdot 4!} - \frac{\pi^6}{4^6 \cdot 6!} + \cdots &= \sum_{n=0}^\infty \p{-1}^n \frac{\pi^{2n}}{4^{2n} \cdot \p{2n}!} \\ &= \sum_{n=0}^\infty \p{-1}^n \frac{\p{\frac{\pi}{4}}^{2n}}{\p{2n}!} \\ &= \cos\p{\frac{\pi}{4}} \\ &= \boxed{\frac{1}{\sqrt{2}}}. \end{aligned}
Example 5.

Calculate

n=22n+3n!.\sum_{n=2}^\infty \frac{2^{n+3}}{n!}.
Solution.

Hopefully, the power series expansion for exe^x stands out here. Let's try to rewrite the sum so it looks more like the series expansion:

n=22n+3n!=8n=22nn!.\sum_{n=2}^\infty \frac{2^{n+3}}{n!} = 8\sum_{n=2}^\infty \frac{2^n}{n!}.

Now it's almost like e2e^2, but the lower bound isn't correct, and this means that we're missing some terms. To make it more clear, we can write it like this:

n=22nn!=222!+233!+244!+e2=n=02nn!=1+2+222!+233!+244!+=1+2+n=22nn!.\begin{aligned} \sum_{n=2}^\infty \frac{2^n}{n!} &= \frac{2^2}{2!} + \frac{2^3}{3!} + \frac{2^4}{4!} + \cdots \\ e^2 = \sum_{n=0}^\infty \frac{2^n}{n!} &= 1 + 2 + \frac{2^2}{2!} + \frac{2^3}{3!} + \frac{2^4}{4!} + \cdots \\ &= 1 + 2 + \sum_{n=2}^\infty \frac{2^n}{n!}. \end{aligned}

Thus, if we add the first two terms, then we get e2e^2:

8n=22nn!=8((1+2)(1+2)+n=22nn!)=8(3+(1+2n=22nn!))=8(e23).\begin{aligned} 8\sum_{n=2}^\infty \frac{2^n}{n!} &= 8\p{\p{1 + 2} - \p{1 + 2} + \sum_{n=2}^\infty \frac{2^n}{n!}} \\ &= 8\p{-3 + \p{1 + 2 \sum_{n=2}^\infty \frac{2^n}{n!}}} \\ &= \boxed{8\p{e^2 - 3}}. \end{aligned}