$\DeclareMathOperator{\asin}{asin}$ $\DeclareMathOperator{\acos}{acos}$ $\DeclareMathOperator{\atan}{atan}$ $\DeclareMathOperator{\mod}{mod}$
 < Previous Section Home Next Section >

# Section 10.2 Polynomial Approximations, Taylor Series, and Convergence at a Moment

In Section 10.1, we:.

• Made increasingly strong assumptions about the behavior over $\Delta x$-intervals of an accumulation function f's higher-order rate of change functions ...
• This led to approximating rf over $\Delta x$-intervals with polynomial functions of increasing orders ...
• Which allowed us to approximate f over $\Delta x$-intervals with the integral of a polynomial function.
• We also found bounds on our approximations' errors. The error bound for the quadratic method over the interval $[a,x]$ is $$\left|\int_a^xr_f(t)dt-A_\mathrm{quad}(a,x,\Delta x)\right|\le \left(\left(\frac{x-a}{180}\right) \left({\mathrm{max}\atop{a\le t \le x}} \left|\dfrac{d^4}{dt^4}r_f(t)\right|\right)\right)(\Delta x)^4$$
• These bounds tell us the worst error our approximations could have for any value of t in $[a,x]$.

Figure 10.2.1 shows a table of values like we saw in Section 10.1.

• The first column contains values of n.
• The second column contains values of $\Delta x=1/2^n$.
• The third column contains values of $A_\mathrm{quad}(2,15,\Delta x)$.
• The fourth column contains values of $$\left(\frac{15-2}{180}\right)176250(\Delta x)^4$$where $176250=\max\left|\dfrac{d^4}{dx^4}r_f(x)\right|$ for $2 \le x \le 15$.

Figure 10.2.1. Table of values for $n$, $\Delta x=1/2^n$, $A_\mathrm{quad}(2,15,\Delta x)$, and $\left(\frac{15-2}{180}\right)176250(\Delta x)^4$
where $176250=\max\left|\dfrac{d^4}{dx^4}r_f(x)\right|$ for $2 \le x \le 15$.

Figure 10.2.1 gives information about how values of $A_\mathrm{quad}(2,15,\Delta x)$ behave as $\Delta x$ becomes smaller.

We can make other observations about rf and f in Figure 10.2.1.

### Observation 1

The first observation is about maximum error of $A_\mathrm{quad}(a,x,\Delta x)$.

1. $r_f(x)=\sin(3\cos(5x))$. $\cos(5x)$ is periodic with period $\frac{2\pi}{5}$, so $r_f(x)$ is periodic with period $\frac{2\pi}{5}\approx 1.257$.
2. The maximum value of $\left|\frac{d^4}{dx^4}r_f(x)\right|$ is 176250 for all values of x, $1\le x \le 15$, an interval longer than 1.257. So 176250 is the maximum value of $\left|\frac{d^4}{dx^4}r_f(x)\right|$ for all values of x in the domain of rf.
3. The maximum value of $\left|\int_1^x r_f(t) dt - A_\mathrm{quad}(1,x,\Delta x)\right|$ for a given value of $\Delta x$ is $k \left|x-1\right|$ for all values of x, where $k=979.1667\left(\Delta x \right)^4$.
4. Generalization: Given an exact rate of change function rg, if $\left|\frac{d^4}{dx^4}r_g(x)\right|\le K$ for all values of x, then $$\left|\int_a^x r_g(t) dt - A_\mathrm{quad}(a,x,\Delta x)\right|\le M\left|x-a\right|,$$ where $M=\dfrac{K}{180}(\Delta x)^4$.
5. Put another way, if a rate of change function's 4th-order rate of change function is bounded over its domain, then the maximum absolute error of $A_\mathrm{quad}$ over that domain is proportional to $\left|x-a\right|$ for all values of x and a in the domain of $r_g$.

Reflection 10.2.1. Given $r_f(x)=\sin(3\cos(5x))$ What is the bound on maximum value of $\left|\int_5^{100} r_f(x) dx - A_\mathrm{quad}(5,100,0.02)\right|$?

Reflection 10.2.2. Suppose $\left|r_g^{(4)}(x)\right|\le 503.21$ for all values of x in its domain. Suppose also $A_\mathrm{quad}(0,b,0.02)$ has a maximum absolute approximation error of 0.00003 for $0\le x\le b$.

What is the largest value of $\Delta x$ that will ensure $$\left|\int_0^{500b} r_g(t)dt-A_\mathrm{quad}(0,500b,\Delta x)\right|\le 0.00003$$ for all values of x, $0\le x \le 500b$?

### Observation 2

The second observation is that our focus was largely on computing approximations to net accumulation. In approximating values of a net accumulation function f, however, we also approximated values of $r_f(x)$ for all values of x!

We approximated values of $r_f(x)$ with a polynomial of degree 0 (locally constant approximations of rf), degree 1 (locally linear approximations of rf), or degree 2 (locally quadratic approximations of rf).

Polynomial approximations of $r_f(x)$ for values of x gave us easily computable approximations to values of accumulation functions we could not compute directly.

However, there is a kink when we consider our quadratic approximation of an accumulation's rate of change function. We assumed we could compute any value of the rate of change function at any value of its domain.

Practically speaking, we were correct. GC computed values of sine, cosine, exponential and logarithmic functions for us. Someone figured a way to make computers capable to do these calculations and we used that capability. When $\sin(x)$ was our rate of change function, we had GC compute $\sin(\mathrm{left}((x))$, $\sin(\mathrm{mid}(x)$, and $\sin(\mathrm{right}(x))$ to generate our quadratic approximation of $\sin(x)$ over a $\Delta x$-interval.

In other words, we assumed we could calculate any value of the rate of change function for any value in its domain in our approximation of the rate of change function itself.

There was a time in human history when no one knew how to approximate values of non-algebraic functions like sine, cosine, exponential, and log. It is important we understand how this obstacle was overcome.

### Observation 3

The third observation is about our general method of making stronger assumptions about the behavior of higher order rate of change functions for an accumulation function in order to make more accurate approximations of net accumulation with a given value of $\Delta x$.

1. When we assumed $r_f(x)$ is essentially constant over sufficiently small intervals we needed just one value of $r_f$ in a $\Delta x$-interval to approximate $r_f(x)$ over that interval. We then integrated a polynomial of degree 0 to compute approximate variations in $f(x)$, rf's accumulation function, over each $\Delta x$-interval. The polynomial needed to pass through one point on the graph of $y=r_f(x)$ in each $\Delta x$-interval.
2. When we assumed $r_f^{(2)}(x)$ is essentially constant over sufficiently small intervals we needed two values of $r_f$ in a $\Delta x$-interval to approximate $r_f(x)$ over that interval. We then integrated a polynomial of degree 1 to compute approximate variations in $f(x)$ over each $\Delta x$-interval. The polynomial needed to pass through two points on the graph of $y=r_f(x)$ in each $\Delta x$-interval.
3. When we assumed $r_f^{(3)}(x)$ is essentially constant over sufficiently small intervals we needed three values of $r_f(x)$ in a $\Delta x$-interval to approximate $r_f(x)$ over that interval. We then integrated a polynomial of degree 2 to compute approximate variations in $f(x)$ over each $\Delta x$-interval. The polynomial needed to pass through three points on the graph of $y=r_f(x)$ in each $\Delta x$-interval.

In each of Observations 1-3, our approximation method was possible because we found algebraic simplifications of integrals over $\Delta x$-intervals that used values of $r_f$ as coefficients in our 0th-degree (constant), 1st-degree (linear), or 2nd-degree polynomial approximation of $r_f(x)$ over a $\Delta x$-interval.

But the algebra became more complicated as the degree of our polynomial approximations of rf increased.

Extending this general method to approximate variations in f by assuming $r_f^{(n)}(x)$ is essentially constant over $\Delta x$-intervals would require us to find a $(n-1)$-degree polynomial that passes through $(n-1)$ points on the graph of $y=r_f(x)$ in each $\Delta x$-interval.

It is possible, in principle, to find a polynomial of degree n passing through n distinct points in the plane. The method employs what is called polynomial interpolation, a topic beyond the scope of a calculus textbook. As an aside, the quadratic approximations to rate of change functions in Figures 10.1.14 and 10.1.15 were generated using polynomial interpolation.

Brook Taylor, building on earlier work by Barrow and Newton, took a different approach to approximating values of $r_f(x)$. He used polynomial functions to approximate a rate of change function, but his method for calculating coefficients of polynomial approximations to rf is more straighforward than polynomial interpolation.

The remainder of this section focuses on Taylor's method and its applications.

## Taylor Polynomial Approximations

Suppose your programmable calculator has buttons for the variable x and for 0 - 9, +, -, *, $\div$, and $x^n$ for integers n. It also can graph $y=\cos(x)$ and other standard functions, but it cannot report values of these functions.

How might you calculate approximations of $\cos(x)$ for $-\pi\le x \le \pi$?

### A Graphical Approach

Let's start with a graph of $y=\cos(x),\,-\pi \le x \le \pi$.

Figure 10.2.2. Graph of $y=\cos(x),\,-\pi \le x \le \pi$.

We are looking for a polynomial function of the form $p(x)=c_n x^n+c_{n-1} x^{n-1}+ \cdots +c_1x + c_0$ that gives a good approximation of $\cos(x)$ for every value of x, $-\pi\le x\le \pi$.

Focus on the graph around $x=0$. This part of the graph resembles $y=1-x^2$. Try it. (See Figure 10.2.3).

Figure 10.2.3. Graphs of $y=\cos(x),\,-\pi \le x \le \pi$ and $y=1-x^2$.

The graph of $y=1-x^2$ is close to $y=\cos(x)$ for values of x near 0, but $x^2$ becomes large too quickly for $\left| x \right|$ away from 0 and hence, as an approximation of $\cos(x)$, $1-x^2$ decreases too rapidly for $\left| x \right|$ away from 0.

Try $1-x^2/2$. The graph should decrease less rapidly (Figure 10.2.4).

Figure 10.2.4. Graphs of $y=\cos(x),\,-\pi \le x \le \pi$ and $y=1-x^2/2$.

Figure 10.2.4 shows a close approximation of $y=1-x^2/2$ to $y=\cos(x)$ for $\left| x \right|\lt 1$, but the graph of $y=\cos(x)$ changes concavity around $\left| x \right|=\pi/2$ whereas $y=1-x^2/2$ does not.

We need to add another term that causes the graph of our polynomial approximation to begin turning up around $\left| x \right|=\pi/2$.

We cannot add an $x^3$ term. That would make the right side bend up but the left side bend down more than it does. The additional term must add a positive amount for both positive and negative values of x. So try adding $x^4/c$ where c is large enough to add little for small values of $\left| x \right|\approx 1$. Try adding $x^4/10$ (see Figure 10.2.5).

Figure 10.2.5. Graphs of $y=\cos(x),\,-\pi \le x \le \pi$ and $y=1-x^2/2+x^4/10$.

Values of $x^4/10$ are still too large away from 0. They add too much to $1-x^2/2$. We need to add a smaller multiple of $x^4$.

Some experimentation shows $x^4/28$ seems to work (see Figure 10.2.6.)

Figure 10.2.6. Graphs of $y=\cos(x),\,-\pi \le x \le \pi$ and $y=1-x^2/2+x^4/28$.

Reflection 10.2.3. Open this GC file.
• Use the k-slider to adjust the coefficient of $-x^6$ so that the graph of $y=p(x)$ approximates the graph of $y=\cos(x),\,-\pi \le x \le \pi$ as closely as possible.
• Adjust the a-slider to compare values of $p(a)$ with values of $cos(a)$ for $-\pi \le a \le \pi$.

Reflection 10.2.4. Use the same style of graphical reasoning for building a polynomial approximation of $\cos(x)$ to build a polynomial approximation of $\sin(x),\, -\pi\le x \le \pi$.

One way to check our polynomial approximation of $\cos(x)$ is to draw on our knowledge of properties of $\cos(x)$, such as $\dfrac{d}{dx}\cos(x)=-\sin(x)$.

If $p(x)=1-\dfrac{x^2}{2}+\dfrac{x^4}{28}-\dfrac{x^6}{800}$ is our approximation of $\cos(x)$, then the graph of \begin{align} y&=\dfrac{d}{dx}p(x)\\[1ex]&=-x+\dfrac{4}{28}x^3-\dfrac{6}{800}x^5\end{align} should resemble the graph of $y=-\sin(x)$, the derivative of $\cos(x)$, in a neighborhood of $x=0$. See Figure 10.2.7.

Figure 10.2.7. Graphs of $y=-\sin(x),\,-\pi \le x \le \pi$ and $y=\dfrac{d}{dx}p(x)$.

Figure 10.2.7 shows the graphs of $y=-\sin(x)$ and $y=-x+\frac{4}{28}x^3-\frac{6}{800}x^5$. The two do resemble each other in the neighborhood of $x=0$.

### A Systematic Approach

Our graphical approach to approximating $\cos(x)$ worked to some extent, but our unsystematic search for additional terms and coefficients does not guarantee a best approximation of rf.

A more systematic approach has its seeds in an observation we made about our approximation of $f(x)=\cos(x)$. It was that if $p(x)$ approximates $f(x)$, then the graph of $y=\dfrac{d}{dx}p(x)$ should approximate the graph of $y=-\sin(x)$ because \begin{align} \frac{d}{dx}f(x)&=\frac{d}{dx}\cos(x)\\[1ex] &=-\sin(x). \end{align}

More generally, we want p, the polynomial function approximating f, to satisfy two conditions for values of x near $x=a$:
1. We want $p(a)=f(a)$.
2. We want $r_p^{(k)}(a)$, the kth-order rate of change function of p, $k\in\{1,2,\dots\,n\}$ evaluated at $x=a$, to agree with $r_f^{(k)}(a)$, the kth-order rate of change function of f evaluated at $x=a$.

Let $f(x)=\cos(x)$ be the function we wish to approximate and let a be a value in the domain of f.

Let $$p_n(x)=c_n(x-a)^n+c_{n-1}(x-a)^{n-1}+c_{n-2}(x-a)^{n-2}+\cdots + c_2(x-a)^2+c_1(x-a)+c_0$$ be the $n^{th}$-degree polynomial that approximates f for values of x near a. Our central question is, "What are the values of $c_n,\,c_{n-1},\,\cdots,c_2,\, c_1$, and $c_0$ that make $p_n$ satisfy the two conditions given above?"

$p_n(a)=0+0+\cdots +0+c_0$.

Let $c_0=f(a)$.

Then $p_n(a)=f(a)$. Condition #1 is satisfied when $c_0$ is defined as $c_0=f(a)$.

\begin{align} r_{(p_n)}^{(1)}(x)&=\frac{d}{dx}p_n(x)\\[1ex] &=nc_n(x-a)^{n-1}+(n-1)c_{n-1}(x-a)^{n-2}+\cdots +3c_3(x-a)^2+2c_2(x-a) + c_1\\[1ex]\end{align}.

So, $r_{(p_n)}^{(1)}(a)=c_1$.

Let $c_1=r_f(a)$.

Then $r_{(p_n)}^{(1)}(x)=r_f^{(1)}(x)$. The 1st-order rate of change function for $p_n$ and f agree for values of x near $x=a$ when $c_1$ and $c_0$ are defined as above. Condition #2 is satisfied for $k=1$.

\begin{align} r_{(p_n)}^{(2)}(x)&=\frac{d}{dx}r_{(p_n)}^{(1)}(x))\\[1ex] &=n(n-1)c_n(x-a)^{n-2}+(n-1)(n-2)c_{n-1}(x-a)^{n-2}+\cdots + (3\cdot 2)(x-a) + 2c_2\\[1ex]\end{align}.

So, $r_{(p_n)}^{(2)}(a)=2c_2$.

Let $c_2=\dfrac{r_f^{(2)}(a)}{2}$.

Then $r_{(p_n)}^{(2)}(x)=r_f^{(2)}(x)$. The 2nd-order rate of change function for $p_n$ and f agree for values of x near $x=a$ when $c_2$, $c_1$, and $c_0$ are defined as above. Condition #2 is satisfied for $k=2$.

\begin{align} r_{(p_n)}^{(3)}(x)&=\frac{d}{dx}r_{(p_n)}^{(2)}(x))\\[1ex] &=n(n-1)(n-2)c_n(x-a)^{n-3}+(n-1)(n-2)(n-3)c_{n-1}(x-a)^{n-3}+\cdots +(4\cdot 3\cdot 2)(x-a) + (3\cdot 2) c_3\\[1ex]\end{align}.

So, $r_{(p_n)}^{(3)}(a)=(3\cdot2)c_3$.

Let $c_3=\dfrac{r_f^{(3)}(a)}{3\cdot 2}$.

Then $r_{(p_n)}^{(3)}(x)=r_f^{(3)}(x)$. The 3rd-order rate of change function for $p_n$ and f agree for values of x near $x=a$ when $c_3$, $c_2$, $c_1$, and $c_0$ are defined as above. Condition #2 is satisfied for $k=3$.

\begin{align} r_{(p_n)}^{(4)}(x)&=\frac{d}{dx}r_{(p_n)}^{(3)}(x))\\[1ex] &=n(n-1)(n-2)(n-3)c_n(x-a)^{n-4}+(n-1)(n-2)(n-3)(n-4)c_{n-1}(x-a)^{n-4}+\\ &\qquad \cdots +(5\cdot 4\cdot 3\cdot 2)(x-a) + (4\cdot 3\cdot 2)c_3\\[1ex]\end{align}.

So, $r_{(p_n)}^{(4)}(a)=(4\cdot 3\cdot2)c_4$.

Let $c_4=\dfrac{r_f^{(4)}(a)}{4\cdot 3\cdot 2}$.

Then $r_{(p_n)}^{(4)}(x)=r_f^{(4)}(x)$. The 4th-order rate of change function for $p_n$ and f agree for values of x near $x=a$ when $c_4$, $c_3$, $c_2$, $c_1$, and $c_0$ are defined as above. Condition #2 is satisfied for $k=4$.

We can generalize this pattern: For a function f and values of x near a, $r_{(p_n)}^{(m)}$, the mth-order rate of change function for $p_n$, agrees with $r_f^{(m)}$, the mthorder rate of change function for f, when $$c_k=\dfrac{r_f^{(k)}(a)}{k(k-1)(k-2)\cdots 2\cdot 1}$$ for $k=0$ to $k=m$. Take note: $r_f^{(0)}(x)=f(x)$.

Using factorial notation, and recalling that $0!=1$, $$r_{(p_n)}^{(m)}(x)=r_f^{(m)}(x)\text{ when }c_k=\dfrac{r_f^{(k)}(a)}{k!}$$in the definiton of $p_n$. Fortunately for us, GC understands factorial notation.

In other words, the mth-order rate of change function for f agrees with the mth-order rate of change function for $p_n$ when the coefficient of $(x-a)^k$ is as stated above.

The final form of $p_n$ as a function whose values approximate $f(x)$ when x is near a is therefore $$\color{red}{\text{(Eq. 10.2.1)}}\qquad p_{n}(x)=f(a)+r_f^{(1)}(a)(x-a)+\frac{r_f^{(2)}(a)}{2!}(x-a)^2+\frac{r_f^{(3)}(a)}{3!}(x-a)^3+\cdots +\frac{r_f^{(n)}(a)}{n!}(x-a)^n$$

A polynomial in the form of Equation 10.2.1 is called a Taylor polynomial, after Brook Taylor.

We now return to the problem of approximating values of $\cos(x),\, -\pi\le x \le \pi$. We first think of approximating $\cos(x)$ with $a=0$. The value $a=0$ is conventient because $\cos(0)=1$ and $\sin(0)=0$.

To use a 10th-degree polynomial to approximate $\cos(x)$, we need $$\frac{d^k}{dx^k}\cos(x)$$ for $k=0$ to $k=10$, each evaluated at $a=0$, to compute $c_k$ for $k=0$ to $k=10$.

The table in Figure 10.2.8 gives all the information we need. The table also shows a clear pattern. By convention, $r_f^{(0)}(x)=f(x)$.

Figure 10.2.8. Rate of change functions for cos(x) of order $k\in\{0,1,2, ..., 10\}$.

The 10th-degree Taylor polynomial approximation for $f(x)=\cos(x)$ for $a=0$ and $-\pi\le x \le \pi$ is \begin{align} p_{10}(x)&=1+\frac{0x}{1!}-\frac{1x^2}{2!}+\frac{0x^3}{3!}+\frac{1x^4}{4!}+\frac{0x^5}{5!}-\frac{1x^6}{6!}+\frac{0x^7}{7!}+\frac{1x^8}{8!}+\frac{0x^9}{9!}-\frac{1x^{10}}{10!}\\[1ex] &=1-\frac{x^2}{2!}+\frac{x^4}{4!}-\frac{x^6}{6!}+\frac{x^8}{8!}-\frac{x^{10}}{10!}\end{align}

Reflection 10.2.5. Do this now in GC:
• Enter the definition of p10.
• Enter $y=\cos(x)$ in a new line.
• Enter $y=p_{10}(x)$ in another line. Press Enter.
• Scale your axes so you see $-8\le x \le 8$.
• At what values of x, approximately, does the graph of $y=p_{10}(x)$ begin to depart significantly from the graph of $y=\cos(x)$?
• Why does the graph of $y=p_{10}(x)$ depart from the graph of $y=\cos(x)$ in the way it does?
• Calculate: $p_{10}(\pi)$, $\cos(\pi)$, and $\left|\dfrac{\cos(\pi)-p_{10}(\pi)}{\cos(\pi)}\right|$. Interpret the quotient.

In Reflection 10.2.5 you determined that the relative error of $p_{10}(\pi)$ is approximately 0.0018, or 18/100 of 1%. You can compute $\cos(x),\, -\pi \le x \le \pi$ to a high degree of accuracy using just the 0 - 9, +, -, *, and $x^n$ keys on your calculator.

Figure 10.2.9 illustrates the improvement in $p_n$'s approximation of $\cos(x)$ as the value of n increases.

Figure 10.2.9. Graphs of $y=p_n(x)$ in relation to $y=\cos(x)$ as the value of n increases from 0 to 22.

## Use Summation Notation to Define pn

First, let's generalize our notation to make easier use of GC. Instead of denoting a nth-order polynomial as $p_n(x)$, we will denote it as $p(x,n)$.

The definition of $p(x,10)$ as $$p(x,10)=1-\frac{x^2}{2!}+\frac{x^4}{4!}-\frac{x^6}{6!}+\frac{x^8}{8!}-\frac{x^{10}}{10!}$$ is cumberson to write and cumbersome to enter into GC. Indeed, the higher the order of a Taylor polynomial approximation, the more cumbersome to write its definition fully.

The use of summation notation to define a Taylor polynomial approximation to a rate of change function will be useful in the same way as using summation notation made it possible to write the general definition of an approximate accumulation function.

The hard part of using summation notation is to define the general term appropriately. Figure 10.2.9 contains the general term for the Taylor polynomial approximation to $\cos(x-a)$ with $a=0$. The general term is $$\frac{x^{2k}}{(2k)!}\qquad k=0,\,1,\,\dots,\,n$$

Figure 10.2.10 shows how to use summation notation in GC to define $p_n$.

Figure 10.2.10. Defining $p(x,n)$ in GC.

Notice two things about Figure 10.2.10

• We incorporated n as a parameter in the definition of p. This is for convenience, as you will see later.
• The graph is incorrect!! Why? Because successive terms do not alternate sign.

Reflection 10.2.6. Expand $p(x,4)$ into an explicit sum, where $p(x,n)=\sum\limits_{k=0}^n \dfrac{x^{2k}}{(2k)!}$. Notice that successive terms do not change sign.

Figure 10.2.11 shows how to make successive terms alternate sign. It uses the property that

• $(-1)^\text{even integer}=1$
• $(-1)^\text{odd integer}=-1$.

So, $(-1)^k=1$ when k is even; $(-1)^k=-1$ when k is odd. Multiply the general term by $(-1)^k$.

Figure 10.2.11. Use $(-1)^k$ to make successive terms alternate signs.

Reflection 10.2.7.
1. Expand $p(x,6)$ into an explicit sum, where $p(x,n)=\sum\limits_{k=0}^n (-1)^k\dfrac{x^{2k}}{(2k)!}$. Evaluate $(-1)^k$ when writing each term.
2. Download this file. What is the smallest value of n so that $p(15,n)$ gives an approximation within $1\times 10^{-8}$ of $\cos(15)$?
3. Why do you suppose GC stops reporting values of $p(15,q)$ for values of q after a certain point?

### What about values of $p(x,n)$ for values of x larger than $\pi$ or smaller than $-\pi$?

Your graph of $y=p(x,10)$ in Reflection 10.2.5 showed the graph departing greatly from the graph of $y=\cos(x)$ for $\left| x \right|>\pi$. Figure 10.2.9 shows the graph of $y=p(x,n)$ eventually departs from the graph of $y=\cos(x)$ no matter the value of n.

How, then, can we use $p(x,10)$, or even $p(x,20)$, to approximate $\cos(x)$ for all values of x?

The function we define to approximate $\cos(x)$ for all values of x relies on two properties of the cosine function:

• cosine is periodic with period $2\pi$.
• $\cos(x-\pi)=-\cos(x)$ for all values of x.

The cosine function is periodic with period $2\pi$. This is because an angle measure of $x-2\pi n$ is equivalent to an angle measure of x. It islike going back n full revolutions on a circle. You end where you begin.

For $x\ge 0$, the value of $\left\lfloor \dfrac{x}{2\pi}\right\rfloor$ gives the number of intervals of length $2\pi$ between 0 and x.

We can therefore reduce all positive values of x to an equivalent value between 0 and $2\pi$ by computing $x-2\pi\left\lfloor\dfrac{x}{2\pi}\right\rfloor$. Define the function $m_{2\pi}$ as $$m_{2\pi}(x)=x-2\pi\left\lfloor\frac{x}{2\pi}\right\rfloor.$$

The function $m_{2\pi}$ will reduce any non-negative value of x to an equivalent value between 0 and $2\pi$.

The value of $\cos\left(m_{2\pi}(x)-\pi\right)$ will be the same as the value of $-\cos(x)$.

We will start to use the name of our target function as a subscript. In GC, type the target function's name as a subscript by typing, for example,

p ctrl-L \cos\ $\rightarrow$ ctrl-9 x , n =

to get the partial statement "$p_{\cos}(x,n)=$".

We can therefore redefine $p_{\cos}$ as \begin{align} \color{red}{\text{(Eq. 10.2.2)}}\qquad p_{\cos}(x,n)&=-p\left(\left(m_{2\pi}(x)-\pi\right),n\right)\\[1ex] \text{where}\qquad p(x,n)&=\sum\limits_{k=0}^n (-1)^{k+1}\frac{x^{2k}}{2k!}\\[1ex] \text{and}\qquad m_{2\pi}(x)&=x-2\pi\left\lfloor\frac{x}{2\pi}\right\rfloor \end{align}

$p_{\cos}(x,n)$ as defined in Equation 10.1.2 will approximate the value of $\cos(x)$ for $x\ge 0$ by evaluating $p_{\cos}(x,n)$ at a value of $x$ between $-\pi$ and $\pi$.

The end result, as illustrated in the right side of Figure 10.2.12, is that approximations of $\cos(x)$ by $p_{\cos}(x,n)$ are as good for all values of x as for values of x in the interval $-\pi \le x \le \pi$. The left side of Figure 10.2.12 shows this is not the case for $p(x,n)$.

Figure 10.2.12. Behaviors of $y=p(x,n)$ and $p_{\cos}(x,n)$ as the value of n increases. There is always a "tail" in $y=p(x,n)$ that departs from $y=\cos(x)$, whereas the graph of $y=p_{\cos}(x,n)$ is indistinguishable from $y=\cos(x)$ at this scale for $n\gt 4$.

Reflection 10.2.8. Define p, and $p_{\cos}$ as given above. Compare the graphs of $y=p(x,10)$, $y=p_{\cos}(x,10$, and $y=\cos(x)$. (1) Type ctrl-L \cos\ to get $p_{\cos}$. (2) Scale your horizontal axis to see $-20\le x \le 20$. You might need to hide the graph of $y=\cos(x)$ to see the graph of $y=p_{\cos}(x,10)$.

Reflection 10.2.9. We stated the condition, "For $x\ge 0$" as a basis for defining $m_{2\pi}$. Yet, as your graphs in Reflection 10.2.6 show, $p(x)=-p_{10}\left(m_{2\pi}(x)-\pi\right)$ also works for negative values of x. Why?

### Why did we use "(x – a)" in our Taylor polynomial approximation of f?

Equation 10.2.1 uses powers of $(x-a)$. This is for two reasons:

1. The term $(x-a)$ allows us to focus on any value of x as the one for which we use $p(x)$ to approximate $f(x)$. The value of a provides a "center" for our approximations.
2. The term $(x-a)$ has a very convenient consequence: The coefficients of $\dfrac{x^k}{k!}$ involve $r_f^{(k)}(a)$.

If we choose the value of a so that $f(a)$ and $r_f^{(k)}(a)$ have known values, we avoid the circular problem of needing a way to compute values of $f(x)$ and its rate of change functions at $x=a$ in order to define a polynomial that approximates $f(x)$ around $x=a$.

Reflection 10.2.10. Let $a=1$ in the Taylor polynomial approximation to $\cos(x)$. What problem do you encounter regarding approximating values of $\cos(x)$ for values of x near $x=1$? Remember! The only buttons on your calculator are x, 0 - 9, +, -, $\div$, *, and $x^n$ for integers n.

## Exercise Set 10.2.1

Understanding Equation 10.2.1.

1. What is $c_{17}$ in $p(x,25)$ when $f(x)=\sin(x)$ and $a=0$?
2. Let f be defined as $f(x)=1(x-5)^{23}+2(x-5)^{22}+ \cdots + 22(x-5)^2 + 23(x-5) + 24$.
1. Use the method of Taylor polynomial approximation with $a=5$ to derive a Taylor polynomial approximation of f.
2. Explain why the method of Taylor polynomial approximation with $a=5$ applied to f produces f itself as its Taylor polynomial approximation.
3. What would be a conventient value of a in a Taylor polynomial approximation of $f(x)=\sin(x)$? Why?
4. What would be a conventient value of a in a Taylor polynomial approximation of $f(x)=e^x$? Why?
5. What would be a conventient value of a in a Taylor polynomial approximation of $f(x)=\ln(x)$? Why?
6. Applying Equation 10.2.1

7. Make 4 blank tables with headings labeled as in the table for cosine. Leave the second column blank until you fill in the table. Make it with 20 rows. Feel free to cross out a number under "k", write "k", and write an expression that defines the kth term in column.
1. Complete the table with $f(x)=\sin(x)$ using $a=\pi/2$. Write the definition of $p(x,20)$, omitting terms that are 0. Compare the graph of your Taylor polynomial approximation with $y=f(x)$.

Outside of what interval does the approximation's graph depart dramatically from $y=f(x)$?
2. Complete the table with $f(x)=\sin(x)$ using $a=0$. Write the definition of $p(x,20)$, omitting terms that are 0. Compare the graph of your Taylor polynomial approximation with $y=f(x)$.

Outside of what interval does the approximation's graph depart dramatically from $y=f(x)$?
3. Parts (a) and (b) both approximated $f(x)=\sin(x)$. Do their graphs agree everywhere? Partially? Why?
4. Complete the table with $f(x)=e^x$ using the value of a you chose in #4. Write the definition of $p(x,20)$. Compare the graph of your Taylor polynomial approximation with $y=f(x)$.

Outside of what interval does the approximation's graph depart dramatically from $y=f(x)$?
5. Complete the table with $f(x)=\ln(x)$ using the value of a you chose in #5. Write the definition of $p(x,20)$, omitting terms that are 0. Compare the graph of your Taylor polynomial approximation with $y=f(x)$.

Outside of what interval does the approximation's graph depart dramatically from $y=f(x)$?
8. Practice with summation notation

9. Lacie entered the definition of $p_{\cos}$ into GC like this: $$p_{\cos}(x,n)=\sum\limits_{k=0}^n(-1)^{k+1}\frac{x^{2k}}{2k!}$$ Her graph was nothing like she expected. What was Lacie's error?
10. In GC: Use summation notation to define $p(x,n)$ for the Taylor polynomial approximation you defined in 6a. Confirm your definition by graphing both $p(x,10)$ and your target function.
11. In GC: Use summation notation to define $p(x,n)$ for the Taylor polynomial approximation you defined in 6b. Confirm your definition by graphing both $p(x,10)$ and your target function.
12. In GC: Use summation notation to define $p(x,n)$ for the Taylor polynomial approximation you defined in 6d. Confirm your definition by graphing both $p(x,10)$ and your target function.
13. In GC: Use summation notation to define $p(x,n)$ for the Taylor polynomial approximation you defined in 6e. Confirm your definition by graphing both $p(x,10)$ and your target function.
14. Connections

15. You defined a polynomial function in each of 6a, 6b, 6d, 6e. You can consider each of them as an exact accumulation function. In that regard:
1. Define the rate of change function for the polynomial you made in 6a. You get another polynomial function. What function does this polynomial function approximate? Use GC to test your claim.
2. Define the rate of change function for the polynomial you made in 6b. You get another polynomial function. What function does this polynomial function approximate? Use GC to test your claim.
3. Define the rate of change function for the polynomial you made in 6d. You get another polynomial function. What function does this polynomial function approximate? Use GC to test your claim.
4. Define the rate of change function for the polynomial you made in 6e. You get another polynomial function. What function does this polynomial function approximate? Use GC to test your claim.
16. Use the definition of $m_{2\pi}$ to define $p_{\sin}$ so that $p_{\sin}(x,n)$, for some value of n, approximates $\sin(x)$ within an accuracy of 0.000001 for all values of x. Test your approximation in GC.
17. You defined a polynomial function in each of 6a, 6b, 6d, 6e. You can consider each of them as an exact rate of change function. In that regard:
1. Define the accumulation function for the polynomial you made in 6a. You get another polynomial function. What function does this polynomial function approximate? Use GC to test your claim.
2. Define the accumulation function for the polynomial you made in 6b. You get another polynomial function. What function does this polynomial function approximate? Use GC to test your claim.
3. Define the accumulation function for the polynomial you made in 6d. You get another polynomial function. What function does this polynomial function approximate? Use GC to test your claim.
4. Define the accumulation function for the polynomial you made in 6e. You get another polynomial function. What function does this polynomial function approximate? Use GC to test your claim.
18. Use your prior work in this exercise set to define a function that approximates $\tan(x)$.

Graph your function and $y=\tan(x)$ in GC. Use a slider to determine over what subinterval of $(-\pi,\,\pi)$, approximately, your approximations have a relative error less than 0.1%. Recall that $\tan(x)=\dfrac{\sin(x)}{\cos(x)}$.
19. Define polynomials $p_a$, $p_b$, etc. that will approximate each of a-d, respectively, to any degree n. Test your polynomial by graphing it and its target function in GC.
1. $f(x)=\sin\left(x^2\right)$. Notice: $\sin\left(x^2\right)$ is a composite function.
2. $g(x)=x\cos(x)$
3. $h(x)=x e^{\cos x}$
4. $j(x)=1+\left(e^x\right)^2$
20. In Section 10.1 we approximated an (unknown) exact accumulation functon by making assumptions of the form,
"Suppose the accumulation function has an nth-order rate of change function that is essentially constant over $\Delta x$-intervals."
How are the methods in 10.1 similar to and different from the method of Taylor polynomial approximation developed in this section?

## Improving Approximations over Wider Domains

In Exercise Set 10.2.1 you determined a Taylor polynomial approximation for $e^x$ with $a=0$:

\begin{align} p_\text{exp}(x,n)&=1+x+\frac{x^2}{2}+\frac{x^3}{6}+\frac{x^4}{12}+\cdots+\frac{x^n}{n!}\\[1ex] &=\sum\limits_{k=0}^n \frac{x^k}{k!} \end{align}

Figure 10.2.13 shows the behavior of $y=p_\text{exp}(x,m)$ as the value of m increases from 0 to 20.

Figure 10.2.13. Approximation of $r_f(x)=e^x$ by $p_\text{exp} (x,m)=\sum\limits_{k=0}^m\dfrac{x^k}{k!}$.

Figure 10.2.13 illustrates an important consideration regarding Taylor polynomial approximations:

For some functions (e.g., $f(x)=e^x$), given two values $x_0$ and $x_1$, a higher-degree approximation is required to approximate the function at $x_1$ at the same level of accuracy as at $x_0$.

The table in Figure 10.2.14 illustrates the point just made, but illustrates it numerically. Before discussing the table's entries it will be worthwhile to remind yourself of scientific notation.

• E-14 means $\times 10^{-14}$, or times one hundred-trillionth
• E-12 means $\times 10^{-12}$, or times one trillionth
• E-09 means $\times 10^{-9}$, or times one billionth
• E+09 means $\times 10^9$, or times one billion
• E+12 means $\times 10^{12}$, or times one trillion
• E+14 means $\times 10^{14}$, or times one hundered trillion

The table's first two columns give values of x and values of ex to 3 significant digits. The 3rd and 6th columns give values of $p_\text{exp}(x,25)$ and $p_\text{exp}(x,50)$, respectively, to 3 significant digits, where $p_\text{exp}(x,n)=\sum\limits_{k=0}^n\dfrac{x^k}{k!}$.

The 4th column gives the absolute error of $p_\text{exp}(x,25)$; the 7th column gives the absolute error of $p_\text{exp}(x,50)$.

The 5th column gives the relative error of $p_\text{exp}(x,25)$; the 8th column gives the relative error of $p_\text{exp}(x,50)$. The GC file used to generate this table is here.

Figure 10.2.14. Table of values of ex and Taylor polynomial approximations of ex.

### Observations from Figure 10.2.14

Comparing $p_\text{exp}(x,25)$ to ex

• Absolute error for $e^5$ compared to $p_\text{exp}(5,25)$ is one-billionth, whereas for $x=10$ it is 0.3. For $x=25$ absolute error is about 10 billion, and for $x=35$ the error is about 1000 trillion.
• Relative error for $x=5$ is about three hundred-billionths; relative error for $x=35$ is about 0.95, or 95% (meaning, the approximate value is approximately 5% of the actual value).
• For any value of n and $x\gt 1$, aproximations of $e^x$ by $p_\text{exp}(x,n)$ become less accurate as the value of x becomes larger.
• Well, this last bullet is only partiallly true: y=ex eventually overtakes any polynomial, so at some point as x grows larger, ex starts becoming closer to pexp(x, n), eventually overtaking pexp(x, n)--no matter how large the value of n.

Reflection 10.2.11. Make comparisons of $p_\text{exp}(x,50)$ and ex similar to the comparisons of $p_\text{exp}(x,25)$ and ex.

Historically, Taylor polynomial approximations were a breakthrough for astronemers, natural philosophers (physicists), and mathematicians. They could approximate values of common non-algebraic functions using the first few terms of a Taylor polynomial.

Advances in numerical analysis brought methods superior to Taylor polynomials. These have been crystalized into standards set by the Institute of Electrical and Electronics Engineers (IEEE). The CORDIC method was a foundational advance for performing approximations on digital devices.

GC does not use Taylor polynomials. It uses IEEE routines for approximating values of non-algebraic functions. It will nevertheless be instructive for us to explore ways to improve Taylor polynomial approximations.

### Ways to Improve Taylor Polynomial Approximations of ex and ln(x).

We saw earlier that we could improve approximations of $\cos(x)$ for large vaues of x by employing periodicity to our advantage. We defined $m_{2\pi}$ to transform any value of x to an equivalent value between 0 and $2\pi$ and used the fact that $\cos(x-\pi)=-\cos(x)$.

We then redefined $p_{\cos}$ as \begin{align}p_{\cos}(x,n)&=-p(m_{2\pi}(x)-\pi,n)\\[1ex] \text{where}\qquad p(x,n)&=\sum\limits_{k=0}^n (-1)^{k+1}\dfrac{x^{2k}}{(2k)!}\\[1ex] \text{and}\qquad m_{2\pi}(x)&=x-2\pi \left\lfloor \frac{x}{2\pi}\right\rfloor \end{align}.

We can use similar trickery to improve appoximations of $e^x$ and $\ln(x)$ for large values of x, but not by transforming the value of x. Rather, we will transform the value of a, the center of an approximation, to improve approximations of $e^x$ and $\ln(x)$ for values of x that standard Taylor polynomials approximate poorly.

Better approximations of ex

For $e^x$ we will leverage the fact that $\frac{d^k}{dx^k}e^x=e^x$ for $k=1,\, 2,\, \dots$ . So the kth term in any Taylor polynomial approximation of $e^x$ around $x=a$ will be $\dfrac{e^a}{k!}(x-a)^k.$

Figure 10.2.15 illustrates how the selection of a value of a affects the graph of $y=p_\text{exp}(x,n)$.

Figure 10.2.15

• The graph of $y=p_\text{exp}(x,n)$ is most accurate around $x=a$.
• As the value of a increases, the graph of $y=p_\text{exp}(x,n)$ becomes more accurate to the right and less accurate to the left.

From the first bullet we can say $p(x,n,a)$ is most accurate for values of x near the value of a.

Our "trick" then is to use the integer nearest x from the left as our value of a, for every value of x. See Equation 10.2.3, below. $$\color{red}{\text{(Eq. 10.2.3)}}\qquad p_\text{exp}(x,n)=\sum\limits_{k=0}^n \frac{e^{\lfloor x \rfloor}}{k!}(x-\lfloor x \rfloor)^k$$

1. Use the axis scaling buttons (independently) to search graphically for intervals over which $p_\text{exp}(x,20)$ gives poor approximations of $y=e^x$.
2. Use the b slider to search for values of $e^x$ which are approximated poorly by $p_\text{exp}(x,20)$.
3. Reduce the value of n and repeat #1 and #2.

Given that we must work with our restricted calculator, you might reasonably wonder about the legality of using $e^{\lfloor x \rfloor}$ in Equation 10.2.3. Think of it this way:

• e is a number. We can approximate it to any number of decimal places. Indeed, e has been approximated to 185 billion decimal places.
• We have an $x^n$ button for integers n on our restricted calculator.
• $\lfloor x \rfloor$ is an integer.

It is therefore legal to use $e^{\lfloor x \rfloor}$ in our definition of $p_\text{exp}$ in Equation 10.2.3.

Better approximations of ln(x)

We know $\frac{d}{dx}\ln(x)=x^{-1}$. The kth-order rate of change functions for $\ln(x)$ for $k=1,\,2,\,\dots,n$ are therefore

$x^{-1}$    (-1)x-2    (-2)(-1)x-3    (-3)(-2)(-1)x-4   ...    $(-1)^{k+1}(k-1)!\, x^{-k}$

The Taylor polynomial for $\ln(x)$ centered at $x=a$ is therefore \begin{align} p_{\ln}(x,n)&=\ln(a)+\sum\limits_{k=1}^n (-1)^{k+1} \frac{a^{-k}}{k!} (k-1)!\,(x-a)^k\\[1ex] &=\ln(a)+\sum\limits_{k=1}^n (-1)^{k+1} \frac{a^{-k}}{k}(x-a)^k \end{align}

The accuracy of a Taylor polynomial approximation of $\ln(x)$ will therefore depend on judicious selection of the value of a.

First, we must pick a value of a for which we know $\ln(a)$. Since $\ln\left(e^c\right)=c$, powers of e work well.

Figure 10.2.16 shows the effect on Taylor approximations of $\ln(x)$ with $a=e^0,\,e^1,\,\dots,\,e^4$.

Figure 10.2.16. Taylor approximations of $\ln(x)$ using values of $e^k$ as values of a.

Figure 10.2.16 shows that as the value of x increases, we want to use a higher power of e as our value of a.

• What role does the value of c play in the Taylor polynomial $p_{\ln}$?
• What role does $e^c$ play in the Taylor polynomial $p_{\ln}$?
• Play with the c slider. Why does the graph of $y=p_{\ln}(x,100)$ change as it does?

However, we need to devise a way to select powers of e algorithmically. The strategy used here will build on Figure 10.2.16. We start with a value of x and -4 as a value of m, then

1. Check whether $x\le e^{-4}$. If yes, output $e^{-4}$.
2. Check whether $x \ge e^{29}$. If yes, output $e^{30}$.
3. Check whether $x \le e^m$. If yes, this is the first value of m that makes $e^m\ge x$. Output $e^m$.
4. Otherwise, increase the value of m by one and do 1-4 again.

We will define the function $a(x,m)$ to carry out steps 1-4 above.

The value of $a(x,m)$ will be, within defined range of possibilities, the least power of e that is greater than or equal to the value of x. We will use the value of $a(x,m)$ as the center (value of a) in the Taylor polynomial for each value of x. $$a(x,m)=\cases{ e^{-4} \qquad \text{if }x\le e^{-4}\\[1ex] e^{30} \qquad \text{if }x\ge e^{29}\\[1ex] e^m \qquad \text{if }e^m \ge x\\[1ex] a(x,m+1) }$$

For any value of x, $a(x,-4)$ will produce the least value of $e^m,\,-4\le m\le 30$, greater than or equal to x. The value -4 for m in $a(x,-4)$ is just to give m an initial value in the search for $e^m\ge x$. You msy use any integer as the intial value of m, and you msy use any integer for the upper value of $e^m$.

1. Use the table of values of N and $e^N$ to do by hand the steps to compute $a(15,-4)$.
2. Why must you move the p-slider more each time to get the next higher value of $a(p,-4)$?
3. At what exact values of p does $a(p,-4)$ change value?

Our generalized Taylor polynomial for $\ln(x)$ is $$\color{red}{\text{(Eq. 10.2.4)}}\qquad p_{\ln}(x,n)=\ln(a(x,-4))+\sum\limits_{k=1}^n (-1)^{k+1}\frac{a(x,-4)^{-k}}{k}(x-a(x,-4))^k$$

You might wonder about using $\ln(a(x,-4))$ in the definition of $p_{\ln}$. It simply produces an integer value. How? The value of $a(x,-4)$ is a power of e, so $\ln(a(x,-4))$ is an integer (the exponent in the power of e).

If you are uncomfortable using $\ln(a(x,-4))$ in the definition of $p_{\ln}$, replace $\ln(a(x,-4))$ with $b(x,-4)$ where b is defined as

$$b(x,m)=\cases{ -4 \qquad \text{if }x\le e^{-4}\\[1ex] 30 \qquad \text{if }x\ge e^{29}\\[1ex] m \qquad \text{if }e^m \ge x\\[1ex] b(x,m+1) }$$

The value of $b(x,-4)$ is the exponent of e that $\ln(a(x,-4))$ produces.

You can increase the range of accuracy of $p_{\ln}$ for wider domains by changing the first two lines in the definitions of functions a and b. However, you will quickly exceed the capability of a 64-bit computer or calculator to make accurate calculations.

Reflection 10.2.15. Download and open this file. Use the q-slider. At what values of q is absolute error of $p_{\ln}(q,20)$ least? Greatest? Why?

## Coming Full Circle: Accumulation from Rate and Rate from Accumulation

A Taylor polynomial of degree n allows us to approximate any function f around $x=a$ for which $r_f^{(k)}(a)$ exists, $k\in\{0,1,\dots,n\}$.

Suppose $p_f(x,n)$ is a Taylor polynomial that approximates f around $x=a$. Then it seems reasonable to think that

• $r_p(x,n)=\frac{d}{dx}p_f(x,n)$ approximates $r_f(x)$ for values of x sufficiently near $x=a$.
• if f is an exact rate of change function for an accumulation function g, then $A(x,n)=\int_a^x p_f(t,n)dt$ approximates $\int_a^x f(t)dt=g(x)-g(a)$ for values of x sufficiently near $x=a$.

In other words,

• if f is an exact accumulation function, we can approximate its exact rate of change function $r_f$ by differentiating $p_f(x,n)$ term by term.
• if f is an exact rate of change function for an accumulation function g, we can approximate net change in g from $t=a$ to $t=x$ by integrating $p_f(t,n)$ term by term.

(More ...)

## Convergence and Radius of Convergence

We will now address three issues that sat unacknowledged before our eyes.

1. When can we be assured that Taylor approximations actually approximate the function values we intend?
2. When can we tell ahead of time that meeting a specific accuracy level in approximating a function at one value of x ensures the same accuracy for all values of x?
3. How might we quantify approximation error? That is, can we say, "We know for sure that error in this approximation is no larger than this value E."

(More ...)

We will see later that, in many cases, we can determine the degree of a Taylor polynomial approximation required to achieve a given accuracy level.

(More ...)

 < Previous Section Home Next Section >