Skip to main content

Section 2.3 The error in using a Taylor polynomial

In this subsection, we will discuss how to approximate the error in using a Taylor polynomial to approximate a function. We will use the remainder theorem to bound the error term \(R_n(x)\text{.}\)
Suppose we want to approximate \(f(x)\) using the Taylor polynomial of degree \(n\) at \(x=a\text{.}\) The error in this approximation is given by \(R_n(x) = f(x) - p_n(x)\text{.}\) By the remainder theorem, we have:
\begin{equation*} R_n(x) = \frac{f^{(n+1)}(c)}{(n+1)!} (x-a)^{n+1} \end{equation*}
To bound the error term, we need to find an upper bound for \(|f^{(n+1)}(c)|\) on the interval between \(a\) and \(x\text{.}\)

Example 2.8. Approximating \(e^x\) using a Taylor polynomial.

Approximate \(e^{0.5}\) using the Taylor polynomial of degree 2 at \(x=0\text{.}\) Find an upper bound for the error in this approximation.
Solution.
We will approximate \(f(x) = e^x\) using the Taylor polynomial of degree 2 at \(x=0\text{:}\)
\begin{equation*} p_2(x) = 1 + x + \frac{x^2}{2} \end{equation*}
We want to approximate \(e^{0.5}\text{.}\) The error term is given by:
\begin{equation*} R_2(0.5) = \frac{f^{(3)}(c)}{3!} (0.5)^3 \end{equation*}
Since \(f^{(3)}(x) = e^x\text{,}\) we have:
\begin{equation*} |R_2(0.5)| \leq \frac{e^{0.5}}{6} (0.5)^3 \end{equation*}
Therefore, the error in approximating \(e^{0.5}\) using the Taylor polynomial of degree 2 is bounded by:
\begin{equation*} |R_2(0.5)| \leq \frac{e^{0.5}}{6} (0.125) \approx 0.03435 \end{equation*}
In fact, if we compute the actual value of \(e^{0.5}\) and compare it with the approximation given by \(p_2(0.5)\text{,}\) we find that the actual error is \(e^{0.5} - p_2(0.5) \approx 0.02372\text{,}\) which is indeed less than the upper bound we calculated.
The red curve is the graph of \(f(x) = e^x\) and the blue curve is the graph of the Taylor polynomial \(p_2(x)\text{.}\) The exact value of \(e^{0.5}\) is represented by the red point and the approximation given by \(p_2(0.5)\) is represented by the blue point. The vertical distance between the two points represents the error in the approximation. Note that the error is less than the upper bound we calculated, i.e., \(0.03435\text{.}\)
The red curve is the graph of \(f(x) = e^x\) and the blue curve is the graph of the Taylor polynomial \(p_2(x)\text{.}\) The exact value of \(e^{0.5}\) is represented by the red point and the approximation given by \(p_2(0.5)\) is represented by the blue point. The vertical distance between the two points represents the error in the approximation. Note that the error is less than the upper bound we calculated, i.e., \(0.03435\text{.}\)

Example 2.9. Given a desired error bound, find values of \(x\) for which the approximation is guaranteed to be valid.

Assume that we use the Taylor polynomial of degree 3 at \(x=0\) to approximate \(\sin(x)\text{.}\) For approximately what values of \(x\) can you replace \(\sin(x)\) by such a Taylor polynomial with an error of magnitude no greater than \(4 \times 10^{-3}\text{?}\)
Solution.
The Taylor polynomial of degree 3 at \(x=0\) for \(\sin(x)\) is given by:
\begin{equation*} p_3(x) = x - \frac{x^3}{6} \end{equation*}
Since \(p_3(x) = p_4(x)\text{,}\) the error term is given by:
\begin{equation*} R_4(x) = \frac{f^{(5)}(c)}{5!} x^5 \end{equation*}
Since \(f^{(5)}(x) = \cos(x)\text{,}\) we have:
\begin{equation*} |R_4(x)| \leq \frac{|x|^5}{120} \end{equation*}
We want to find the values of \(x\) such that:
\begin{equation*} \frac{|x|^5}{120} \leq 4 \times 10^{-3} \end{equation*}
This gives us:
\begin{equation*} |x|^5 \leq 0.48 \end{equation*}
Taking the fifth root, we get:
\begin{equation*} |x| \leq 0.86347 \end{equation*}
Therefore, we can replace \(\sin(x)\) by the Taylor polynomial of degree 3 at \(x=0\) with an error of magnitude no greater than \(4 \times 10^{-3}\) for \(|x| \leq 0.86347\text{.}\)
The red curve is the graph of \(f(x) = \sin(x)\) and the blue curve is the graph of the Taylor polynomial \(p_3(x)= x - \frac{x^3}{6}\text{.}\) Use the slider to change the value of \(x\) and see how the error changes for different values of \(x\text{.}\) Note that for the slider values have been limited to fit the page.
Use the slider to change the value of \(x_0\) and see how the error changes. Note that for \(|x_0| \leq 0.86347\text{,}\) the error is less than \(4 \times 10^{-3}\text{.}\)

Example 2.10. Finding the value of \(n\) such that the error is less than a given tolerance.

Find the smallest value of \(n\) for which the polynomial approximation for \(\sin(x)\) is accurate to \(Β±0.005\) for values of \(x\) in the interval \([-\pi/2, \pi/2]\text{.}\)
Solution.
The Taylor polynomial of degree \(n\) at \(x=0\) for \(\sin(x)\) is given by:
\begin{equation*} p_n(x) = \sum_{k=0}^{n} \frac{(-1)^k}{(2k+1)!} x^{2k+1} \end{equation*}
The error term is given by:
\begin{equation*} R_n(x) = \frac{f^{(n+1)}(c)}{(n+1)!} x^{n+1} \end{equation*}
Since \(f^{(n+1)}(x)\) is either \(\cos(x)\) or \(\sin(x)\text{,}\) we have:
\begin{equation*} |R_n(x)| \leq \frac{|x|^{n+1}}{(n+1)!} \end{equation*}
We want to find the smallest value of \(n\) such that:
\begin{equation*} \frac{|x|^{n+1}}{(n+1)!} \leq 0.005 \end{equation*}
Since \(|x| \leq \pi/2\) for \(x \in [-\pi/2, \pi/2]\text{,}\) and approximating \(\pi/2 \approx 2\text{,}\) we have:
\begin{equation*} \frac{|x|^{n+1}}{(n+1)!} \lt \frac{2^{n+1}}{(n+1)!} \end{equation*}
Therefore, we want to find the smallest value of \(n\) such that:
\begin{equation*} \frac{2^{n+1}}{(n+1)!} \lt 0.005 \end{equation*}
We can check the values of \(n\) starting from \(n=0\) until we find the smallest value of \(n\) that satisfies the inequality. After checking, we find that the smallest value of \(n\) that satisfies the inequality is \(n=8\text{.}\)
You have attempted of activities on this page.