8.4 Taylor Polynomials

In Section 4.1, we used the linearization \(L(x)\) to approximate a function \(f(x)\) near a point \(x = a\): \[ L(x) = f(a) + f'(a)(x - a) \]

image
English mathematician Brook Taylor (1685–1731) made important contributions to calculus and physics, as well as to the theory of linear perspective used in drawing.

We refer to \(L(x)\) as a “first-order” approximation to \(f(x)\) at \(x=a\) because \(f(x)\) and \(L(x)\) have the same value and the same first derivative at \(x=a\) (Figure 8.33): \[ L(a) = f(a),\qquad L'(a) = f'(a) \]

A first-order approximation is useful only in a small interval around \(x = a\). In this section we learn how to achieve greater accuracy over larger intervals using the higher-order approximations (Figure 8.34).

image
Figure 8.33: The linear approximation \(L(x)\) is a first-order approximation to \(f(x)\).
image
Figure 8.34: A second-order approximation is more accurate over a larger interval.

In what follows, assume that \(f(x)\) is defined on an open interval \(I\) and that all higher derivatives \(f^{(k)}(x)\) exist on \(I\). Let \(a\in I\). We say that two functions \(f(x)\) and \(g(x)\) agree to order n at \(x=a\) if their derivatives up to order \(n\) at \(x=a\) are equal: \[ f(a)=g(a),\quad f^{\prime }(a)=g^{\prime }(a),\quad f^{\prime \prime }(a)=g^{\prime \prime }(a),\quad\ldots ,\quad f^{(n)}(a)=g^{(n)}(a) \]

We also say that \(g(x)\) “approximates \(f(x)\) to order \(n\)” at \(x=a\).

Define the \(n\)th Taylor polynomial centered at \(x=a\) as follows: \[ \boxed{\bbox[#FAF8ED,5pt]{ T_{n}(x)=f(a)+\frac{f^{\prime }(a)}{1!}(x-a) +\frac{f^{\prime \prime }(a)}{2!}(x-a)^{2}+\cdots +\frac{f^{(n)}(a)}{n!}(x-a)^{n} }} \]

The first few Taylor polynomials are \[ \begin {eqnarray} T_{0}(x) &=&f(a)\notag \\ T_{1}(x) &=&f(a)+f^{\prime }(a)(x-a)\notag \end {eqnarray}\]

489

\[ \begin {eqnarray} T_{2}(x) &=&f(a)+f^{\prime }(a)(x-a)+\frac{1}{2}f^{\prime \prime }(a)(x-a)^{2}\notag \\ T_{3}(x) &=&f(a)+f^{\prime }(a)(x-a)+\frac{1}{2}f^{\prime \prime }(a)(x-a)^2+\frac{1}{6}f^{\prime \prime \prime }(a)(x-a)^3 \notag\end {eqnarray}\]

Note that \(T_{1}(x)\) is the linearization of \(f(x)\) at \(a\). Note also that \(T_{n}(x)\) is obtained from \(T_{n-1}(x)\) by adding on a term of degree \(n\): \[\boxed{\bbox[#FAF8ED,5pt]{ T_n(x) = T_{n-1}(x) + \frac{f^{(n)}(a)}{n!}(x-a)^{n} }}\]

The next theorem justifies our definition of \(T_n(x)\).

Reminder

\(k\)-factorial is the number \(k! = k(k-1)(k-2)\cdots (2)(1)\). Thus, \[ \begin{align*} 1!=1,\quad 2!=(2)1 = 2\\ 3!=(3)(2)1 =6 \end{align*} \]

By convention, we define \(0! = 1\).

THEOREM 1

The polynomial \(T_n(x)\) centered at \(a\) agrees with \(f(x)\) to order \(n\) at \(x = a\), and it is the only polynomial of degree at most \(n\) with this property.

The verification of Theorem 1 is left to the exercises (Exercises 70-71), but we'll illustrate the idea by checking that \(T_2(x)\) agrees with \(f(x)\) to order \(n=2\). \[ \begin{eqnarray*} T_{2}(x)&=&f(a)+f^{\prime }(a)(x-a)+\frac{1}{2}f^{\prime \prime }(a)(x-a)^{2}, & T_{2}(a)&=&f(a) \\ T_{2}^{\prime }(x)&=&f^{\prime }(a)+f^{\prime \prime }(a)(x-a), & T_{2}^{\prime }(a)&=&f^{\prime }(a) \\ T_{2}^{\prime \prime }(x)&=&f^{\prime \prime }(a), & T_{2}^{\prime \prime}(a)&=&f^{\prime \prime }(a \end{eqnarray*} \]

This shows that the value and the derivatives of order up to \(n=2\) at \(x=a\) are equal. Before proceeding to the examples, we write \(T_n(x)\) in summation notation: \[\boxed{\bbox[#FAF8ED,5pt]{ T_{n}(x)=\sum_{j=0}^{n} \frac{f^{(j)}(a)}{j!}\ (x-a)^{j} }}\]

By convention, we regard \(f(x)\) as the zeroeth derivative, and thus \(f^{(0)}(x)\) is \(f(x)\) itself. When \(a=0\), \(T_n(x)\) is also called the \(n\)th Maclaurin polynomial.

EXAMPLE 1 Maclaurin Polynomials for \(e^x\)

Plot the third and fourth Maclaurin polynomials for \(f(x)=e^x\). Compare with the linear approximation.

Solution All higher derivatives coincide with \(f(x)\) itself: \(f^{(k)}(x) = e^x\). Therefore, \[ f(0) = f'(0) = f''(0) = f'''(0) = f^{(4)}(0) = e^0 = 1 \]

The third Maclaurin polynomial (the case \(a = 0\)) is \[ T_3(x) = f(0) + f'(0)x + \frac12f''(0)x^2 + \frac1{3!}f'''(0)x^3 = 1 + x + \frac12x^2+\frac16x^3\\\]

We obtain \(T_4(x)\) by adding the term of degree 4 to \(T_3(x)\): \[ T_4(x) = T_3(x) + \frac1{4!}f^{(4)}(0)x^4 = 1 + x + \frac12x^2+\frac16x^3 + \frac1{24}x^4 \]

Figure 8.35 shows that \(T_3\) and \(T_4\) approximate \(f(x) = e^x\) much more closely than the linear approximation \(T_1(x)\) on an interval around \(a=0\). Higher-degree Taylor polynomials would provide even better approximations on larger intervals.

image
Figure 8.35: Maclaurin polynomials for \(f(x)=e^x\).

490

EXAMPLE 2 Computing Taylor Polynomials

Compute the Taylor polynomial \(T_4(x)\) centered at \(a=3\) for \(f(x)=\sqrt{x+1}\).

Solution First evaluate the derivatives up to degree 4 at \(a=3\): \[ \begin{eqnarray*} f(x) &=& (x+1)^{1/2}, \quad\quad\quad\quad& f(3)&=&2 \\[3pt] f^{\prime }(x) &=&\frac{1}{2}(x+1)^{-1/2}, & f^{\prime }(3)&=&\frac{1}{4} \\[3pt] f''(x) &=& -\frac{1}{4}(x+1)^{-3/2}, & f''(3)&=&-\frac{1}{32} \\[3pt] f'''(x) &=&\frac{3}{8}(x+1)^{-5/2}, & f'''(3)&=& \frac{3}{256} \\[3pt] f^{(4)}(x) &=& -\frac{15}{16}(x+1)^{-7/2}, & f^{(4)}(3)&=& -\frac{15}{2048} \end{eqnarray*} \]

Then compute the coefficients \(\frac{f^{(j)}(3)}{j!}\): \[ \begin{alignat*}{3} &\textrm{Constant term}&& = f(3) = 2 \\ &\textrm{Coefficient of $(x-3)$}&& = f'(3)=\frac14\\ &\textrm{Coefficient of $(x-3)^2$}&& = \frac{f''(3)}{2!} = -\frac{1}{32}\cdot\frac1{2!}=-\frac1{64}\\[3pt] &\textrm{Coefficient of $(x-3)^3$}&& = \frac{f'''(3)}{3!} = \frac{3}{256}\cdot\frac1{3!} = \frac1{512}\\[3pt] &\textrm{Coefficient of $(x-3)^4$}&& = \frac{f^{(4)}(3)}{4!} =- \frac{15}{2048}\cdot\frac1{4!} = -\frac{5}{16{,}384} \end{alignat*} \]

The first term \(f(a)\) in the Taylor polynomial \(T_n(x)\) is called the constant term.

The Taylor polynomial \(T_4(x)\) centered at \(a=3\) is (see Figure 8.36): \[ T_{4}(x) =2+\frac{1}{4}\left( x-3\right) -\frac{1}{64}\left( x-3\right) ^{2}+\frac{1}{512}\left( x-3\right) ^{3}-\frac{5}{16{,}384}\left( x-3\right) ^{4}\]

image
Figure 8.36: Graph of \(f(x)=\sqrt{x+1}\) and \(T_4(x)\) centered at \(x=3\).

EXAMPLE 3 Finding a General Formula for \(T_n\)

Find the Taylor polynomials \(T_n(x)\) of \(f(x) = \ln x\) centered at \(a=1\).

Solution For \(f(x) = \ln x\), the constant term of \(T_n(x)\) at \(a = 1\) is zero because \(f(1)=\ln 1 =0\). Next, we compute the derivatives: \[ f'(x)=x^{-1},\qquad f''(x) = -x^{-2}, \qquad f'''(x)=2x^{-3},\qquad f^{(4)}(x)=-3\cdot 2x^{-4} \]

After computing several derivatives of \(f(x) = \ln x\), we begin to discern the pattern. For many functions of interest, however, the derivatives follow no simple pattern and there is no convenient formula for the general Taylor polynomial.

Similarly, \(f^{(5)}(x) = 4\cdot 3\cdot 2x^{-5}\). The general pattern is that \(f^{(k)}(x)\) is a multiple of \(x^{-k}\), with a coefficient \(\pm (k-1)!\) that alternates in sign: \[ f^{(k)}(x) = (-1)^{k-1}(k-1)!\,x^{-k}\tag{1}\]

The coefficient of \((x-1)^k\) in \(T_n(x)\) is \[ \frac{f^{(k)}(1)}{k!} = \frac{(-1)^{k-1}(k-1)!}{k!} = \frac{(-1)^{k-1}}{k}\qquad (\textrm{for \(k\ge 1\)}) \]

491

Thus, the coefficients for \(k\ge 1\) form a sequence \(1, -\frac12, \frac13, -\frac14,\ldots,\) and \[ T_n(x) = (x-1)-\frac12(x-1)^2+\frac13(x-1)^3-\cdots + (-1)^{n-1}\frac1n(x-1)^n \]

Taylor polynomials for \(\ln x\) at \(a=1\): \[\begin {eqnarray} T_1(x) &=& (x-1)\notag\\ T_2(x) &=& (x-1)-\frac12(x-1)^2\notag\\ T_3(x) &=& (x-1)-\frac12(x-1)^2+\frac13(x-1)^3\notag \end {eqnarray} \]

EXAMPLE 4 Cosine

Find the Maclaurin polynomials of \(f(x)=\cos x\).

Solution The derivatives form a repeating pattern of period 4: \[ \begin{alignat*}{3} f(x) &= \cos x,\qquad f^{\prime }(x) &= -\sin x,&\qquad f^{\prime \prime }&(x) = -\cos x,\qquad f^{\prime \prime \prime }(x)=\sin x,\\ f^{(4)}(x) &= \cos x,\qquad f^{(5)}(x)\, &= -\sin x,&\qquad\cdots & \end{alignat*} \]

In general, \(f^{(j+4)}(x)=f^{(j)}(x)\). The derivatives at \(x=0\) also form a pattern:

\(f(0)\) \(f'(0)\) \(f''(0)\) \(f'''(0)\) \(f^{(4)}(0)\) \(f^{(5)}(0)\) \(f^{(6)}(0)\) \(f^{(7)}(0)\) \(\cdots\)
1 0 \(-1\) 0 1 0 \(-1\) 0 \(\cdots\)

Therefore, the coefficients of the odd powers \(x^{2k+1}\) are zero, and the coefficients of the even powers \(x^{2k}\) alternate in sign with value \((-1)^k/(2k)!\): \[\begin {eqnarray} T_0(x) &=& T_1(x)= 1,\qquad T_2(x) = T_3(x) = 1 -\frac{1}{2!}x^2\notag\\ T_4(x) &=& T_5(x) = 1-\frac{x^2}{2} + \frac{x^4}{4!}\notag\\ T_{2n}(x) &=& T_{2n+1}(x) = 1-\frac{1}{2}x^{2}+\frac{1}{4!}x^{4}-\frac{1}{6!}x^{6}+\cdots +(-1)^{n}\frac{1}{(2n)!}x^{2n} \notag\end {eqnarray} \]

image
Scottish mathematician Colin Maclaurin (1698-1746) was a professor in Edinburgh. Newton was so impressed by his work that he once offered to pay part of Maclaurin's salary.

Figure 8.37 shows that as \(n\) increases, \(T_n(x)\) approximates \(f(x) = \cos x\) well over larger and larger intervals, but outside this interval, the approximation fails.

image
Figure 8.37: Maclaurin polynomials for \(f(x)=\cos x\). The graph of \(f(x)\) is shown as a dashed curve.

492

EXAMPLE 5 How far is the horizon?

Valerie is at the beach, looking out over the ocean (Figure 8.38). How far can she see? Use Maclaurin polynomials to estimate the distance \(d\), assuming that Valerie's eye level is \(h = 1.7\) m above ground. What if she looks out from a window where her eye level is \(20\) m?

image
Figure 8.38: View from the beach
image
Figure 8.39: Valerie can see a distance \(d = R\theta\), the length of arc \(AH\).

Solution Let \(R\) be the radius of the earth. Figure 8.39 shows that Valerie can see a distance \(d = R\theta\), the length of the circular arc \(AH\) in Figure 8.39. We have \[ \cos\theta = \frac{R}{R+h} \]

This calculation ignores the bending of light (called refraction) as it passes through the atmosphere. Refraction typically increases \(d\) by around \(10\%\), although the actual effect is complex and varies with atmospheric temperature.

Our key observation is that \(\theta\) is close to zero (both \(\theta\) and \(h\) are much smaller than shown in the figure), so we lose very little accuracy if we replace \(\cos\theta\) by its second Maclaurin polynomial \(T_2(\theta) = 1-\frac12\theta^2\), as computed in Example 4: \[ 1-\frac12\theta^2 \approx \frac{R}{R+h}\quad\Rightarrow\quad \theta^2 \approx 2 - \frac{2R}{R+h}\quad\Rightarrow\quad \theta \approx \sqrt{\frac{2h}{R+h}} \]

Furthermore, \(h\) is very small relative to \(R\), so we may replace \(R+h\) by \(R\) to obtain \[ d=R\theta \approx R\sqrt{\frac{2h}{R}}= \sqrt{2Rh} \]

The earth's radius is approximately \(R \approx 6.37 \times 10^6\) m, so \[ d=\sqrt{2Rh} \approx \sqrt{2(6.37 \times 10^6)h} \approx 3569\sqrt{h} \mbox{m} \]

In particular, we see that \(d\) is proportional to \(\sqrt{h}\).

If Valerie's eye level is \(h=1.7 \mbox{m}\), then \(d\approx3569\sqrt{1.7}\approx4653 \mbox{m}\), or roughly 4.7 km. If \(h=20 \mbox{m}\), then \(d\approx 3569\sqrt{20}\approx 15.96 \mbox{m}\), or nearly 16 km.

The Error Bound

To use Taylor polynomials effectively, we need a way to estimate the size of the error. This is provided by the next theorem, which shows that the size of this error depends on the size of the \((n+1)\)st derivative.

A proof of Theorem 2 is presented at the end of this section.

THEOREM 2 Error Bound

Assume that \(f^{(n + 1)}(x)\) exists and is continuous. Let \(K\) be a number such that \(|f^{(n+1)}(u)|\le K\) for all \(u\) between \(a\) and \(x\). Then \[ \boxed{\bbox[#FAF8ED,5pt]{|f(x) - T_n(x)| \le K\frac{|x-a|^{n+1}}{(n+1)!} }} \]

where \(T_n(x)\) is the \(n\)th Taylor polynomial centered at \(x=a\).

493

EXAMPLE 6 Using the Error Bound

Apply the error bound to \[|\ln 1.2 - T_3(1.2)|\] where \(T_3(x)\) is the third Taylor polynomial for \(f(x) = \ln x\) at \(a=1\). Check your result with a calculator.

Solution

Step 1. Find a value of \(K\).

To use the error bound with \(n=3\), we must find a value of \(K\) such that \(|f^{(4)}(u)|\le K\) for all \(u\) between \(a=1\) and \(x=1.2\). As we computed in Example 3, \(f^{(4)}(x) = - 6x^{-4}\). The absolute value \(|f^{(4)}(x)|\) is decreasing for \(x>0\), so its maximum value on \([1,1.2]\) is \(|f^{(4)}(1)| = 6\). Therefore, we may take \(K=6\).

Step 2. Apply the error bound. \[ |\ln 1.2 - T_3(1.2)| \le K\frac{\left| x-a\right|^{n+1}}{(n+1)!} = 6 \frac{\left| 1.2-1\right|^{4}}{4!} \approx 0.0004 \]

Step 3. Check the result.

Recall from Example 3 that \[ T_3(x) = (x-1)-\frac12(x-1)^2+\frac13(x-1)^3 \]

The following values from a calculator confirm that the error is at most \(0.0004\): \[ |\ln 1.2 - T_3(1.2)| \approx |0.182667 - 0.182322| \approx 0.00035<0.0004 \]

Observe in Figure 8.40 that \(\ln x\) and \(T_3(x)\) are indistinguishable near \(x=1.2\).

image
Figure 8.40: \(\ln x\) and \(T_3(x)\) are indistinguishable near \(x=1.2\).

EXAMPLE 7 Approximating with a Given Accuracy

Let \(T_n(x)\) be the \(n\)th Maclaurin polynomial for \(f(x) = \cos x\). Find a value of \(n\) such that \[ |\cos 0.2 - T_{n}(0.2)| < 10^{-5} \]

Solution

Step 1. Find a value of \(K\).

Since \(|f^{(n)}(x)|\) is \(|\cos x|\) or \(|\sin x|\), depending on whether \(n\) is even or odd, we have \(|f^{(n)}(u)|\le 1\) for all \(u\). Thus, we may apply the error bound with \(K=1\).

Step 2. Find a value of \(n\).

To use the error bound, it is not necessary to find the smallest possible value of \(K\). In this example, we take \(K=1\). This works for all \(n\), but for odd \(n\) we could have used the smaller value \(K=\sin 0.2 \approx 0.2\).

The error bound gives us \[ |\cos 0.2 - T_{n}(0.2)|\le K\frac{\left| 0.2-0\right| ^{n+1}}{(n+1)!}=\frac{\left| 0.2\right| ^{n+1}}{(n+1)!} \]

To make the error less than \(10^{-5}\), we must choose \(n\) so that \[ \frac{| 0.2| ^{n+1}}{(n+1)!}<10^{-5} \]

It's not possible to solve this inequality for \(n\), but we can find a suitable \(n\) by checking several values:

\(n\) \(2\) \(3\) \(4\)
\(\frac{|0.2| ^{n+1}}{(n+1)!}\) \(\dfrac{0.2^{3}}{3!}\approx 0.0013\) \(\dfrac{0.2^4}{4!}\approx 6.67 \times 10^{-5}\) \(\dfrac{0.2^5}{5!}\approx 2.67\times 10^{-6}<10^{-5}\)

We see that the error is less than \(10^{-5}\) for \(n=4\).

494

The rest of this section is devoted to a proof of the error bound (Theorem 2). Define the nth remainder: \[ \boxed{\bbox[#FAF8ED,5pt]{R_{n}(x)=f(x)-T_{n}(x)}} \]

The error in \(T_n(x)\) is the absolute value \(|R_n(x)|\). As a first step in proving the error bound, we show that \(R_n(x)\) can be represented as an integral.

Taylor's Theorem

Assume that \(f^{(n+1)}(x)\) exists and is continuous. Then \[ \boxed{\bbox[#FAF8ED,5pt]{R_{n}(x)=\frac{1}{n!}\int_{a}^{x}(x-u)^{n}f^{(n+1)}(u)\, du}}\tag{2} \]

Proof

Set \[ I_{n}(x) =\frac{1}{n!}\int_{a}^{x}(x-u)^{n}f^{(n+1)}(u)\, du \]

Our goal is to show that \(R_{n}(x)=I_{n}(x)\). For \(n=0\), \(R_0(x) = f(x)-f(a)\) and the desired result is just a restatement of the Fundamental Theorem of Calculus: \[ I_{0}(x)=\int_{a}^{x}f^{\prime }(u)\, du=f(x)-f(a)=R_{0}(x) \]

To prove the formula for \(n>0\), we apply Integration by Parts to \(I_n(x)\) with \[ h(u)=\frac{1}{n!}(x-u)^n,\qquad g(u)=f^{(n)}(u) \]

Exercise 64 reviews this proof for the special case \(n=2\).

Then \(g'(u) = f^{(n+1)}(u)\), and so \[\begin {eqnarray} I_n(x) &=&\int_{a}^{x}h(u)\,g^{\prime }(u)\, du = h(u)g(u)\bigg|_{a}^{x}-\int_{a}^{x}h^{\prime }(u)g(u)\,du \notag\\ &=& \frac{1}{n!}(x-u)^{n}f^{(n)}(u)\bigg|_{a}^{x}-\frac{1}{n!} \int_{a}^{x}(-n)(x-u)^{n-1}f^{(n)}(u)\, du \notag\\ &=&-\frac{1}{n!}(x-a)^{n}f^{(n)}(a) + I_{n-1}(x)\notag \end {eqnarray} \]

This can be rewritten as \[ I_{n-1}(x) =\frac{f^{(n)}(a)}{n!}(x-a)^{n}+I_{n}(x) \]

Now apply this relation \(n\) times, noting that \(I_0(x) = f(x) - f(a)\): \[ \begin {eqnarray} f(x) &=&f(a)+I_{0}(x) \notag\\ &=&f(a)+\frac{f^{^{\prime }}(a)}{1!}(x-a) +I_{1}(x) \notag\\ &=&f(a)+\frac{f^{^{\prime }}(a)}{1!}(x-a) +\frac{f^{\prime \prime }(a)}{2!}(x-a)^{2}+I_{2}(x) \notag\\ &\vdots & \notag\\ &=&f(a)+\frac{f^{^{\prime }}(a)}{1!}(x-a) +\cdots + \frac{f^{(n)}(a)}{n!}(x-a)^{n}+I_{n}(x)\notag \end {eqnarray} \]

This shows that \(f(x)=T_{n}(x)+I_{n}(x)\) and hence \(I_{n}(x)=R_{n}(x)\), as desired.

495

Now we can prove Theorem 2. Assume first that \(x\ge a\). Then, \[ \begin {eqnarray} \left|f(x) - T_n(x)\right| = \left| R_{n}(x)\right| &=& \left| \frac{1}{n!} \int_{a}^{x}(x-u)^{n}f^{(n+1)}(u)\,du\right| \notag\\ &\le &\frac{1}{n!}\int_{a}^{x}\left|(x-u)^{n}f^{(n+1)}(u)\right|\,du\tag{3}\\ &\le &\frac{K}{n!} \int_a^x|x-u|^{n}\,du\tag {4}\\ &=& \frac{K}{n!} \frac{-(x-u)^{n+1}}{n+1}\bigg|_{u=a}^{x} =K\frac{\left| x-a\right| ^{n+1}}{(n+1)!}\notag\end {eqnarray} \]

In Eq.(3), we use the inequality \[ \left\vert \int_a^b f(x)\, dx\right\vert \le\int_a^b |f(x)|\, dx \]

which is valid for all integrable functions.

Note that the absolute value is not needed in Eq. (4) because \(x - u \ge 0\) for \(a \le u \le x\). If \(x \le a\), we must interchange the upper and lower limits of the integral in Eq. (3) and Eq. (4).

8.4.1 Summary