Section8.6Quantifying the accuracy of approximations
Motivating Questions
For an infinite series that converges, how much accuracy do we lose when we truncate the series after a finite number of terms to approximate its value with a finite sum? Said differently, to get a good approximation with a finite sum, how many terms are enough?
What is an alternating series and how can we determine whether or not it converges? How do the partial sums of a converging alternating series accurately estimate its exact sum?
This section is all about understanding precisely how accurate certain approximations are. Through Taylor series, we now know that we can represent certain functions and their values exactly through infinite sums. For example, we know that for any value of \(x\text{,}\)
Mathematicians have devised other clever and efficient methods for computing values of transcendental functions, such as \(\sin(1)\) and \(\ln(2)\text{.}\) For example, a method known as CORDIC (that remarkably doesn’t even use multiplication) is employed by many calculating devices to compute values of trigonometric functions, such as \(\sin(1)\text{.}\)
that a calculator or computer can respond to the human prompt “\(e^{-1/2}\)”. Note that the right-hand side of the equation only uses addition and multiplication, and that the special number \(e\) makes no appearance on the right. A natural question is: how does a calculator or computer know that the decimal value it returns is as accurate as the decimal representation it displays?
For instance, if we decide to estimate the exact value of \(e^{-1/2}\) using the first \(5\) terms of this infinite sum, it turns out to be possible to use both the fact that we chose “\(5\)” and properties of \(f(x) = e^x\) to quantify the maximum error in the estimate
It also turns out to be possible to determine how many terms are needed in order to find an approximation that meets a desired level of accuracy. These questions and issues are what this section is about.
As we have seen, most of the infinite series that arise (such as the one in Equation (8.6.1)) are not geometric. But since geometric series are among the easiest infinite series to understand and evaluate, we use a geometric series as the starting point for our analysis of approximation errors. In Preview Activity 8.6.1, we investigate an example of a convergent geometric series and explore certain patterns that arise when we compare partial sums the exact sum of the series.
Recall that the \(n\)th partial sum, \(S_n\text{,}\) is the sum of the first \(n\) terms of the infinite geometric series \(S\text{.}\) This means that
Note that the exact fractional values of \(S_1\text{,}\)\(S_2\text{,}\)\(\ldots\text{,}\)\(S_6\text{,}\) have been recorded below along with their decimal representations. Your task is to use this information to do some related computations that help us understand the behavior of the series and its partial sums.
First, by computing the differences between \(S_n\) and \(S\) for several different values of \(n\) (recalling that \(S = \frac{5}{9} = 0.\overline{5}\)), fill in the first column of blank spaces provided below. Then, by viewing the series \(S = 1 - \frac{4}{5} + \frac{16}{25} - \cdots + (-1)^{n-1} \left( \frac{4}{5} \right)^{n-1} + \cdots\) as being in the form \(S = a_0 + a_1 + a_2 + \cdots\text{,}\) fill in the last column of blank spaces.
What do you notice about the differences between \(S_n\) and \(S\) as the value of \(n\) increases? There are at least two important things you can say.
What do you notice about how the differences between \(S_n\) and \(S\) compare to the value of \(a_n\text{?}\) There are at least two important things you can say.
which is related to the well-known error function, \(\erf(x)\text{.}\) While we are unable to find an elementary algebraic antiderivative of \(e^{-x^2}\text{,}\) if we use the Taylor series
Like the geometric series \(\sum_{k=0}^{\infty} (-1)^k \left( \frac{4}{5} \right)^k \) that we encountered in Preview Activity 8.6.1, the infinite series in Equation (8.6.2) is an example of an alternating series of real numbers. It turns out to be straightforward to determine whether or not an alternating series converges and to estimate the value of a convergent alternating series.
In Preview Activity 8.6.1, we investigated the partial sums, \(S_n\text{,}\) of the convergent alternating geometric series \(S = \sum_{k=0}^{\infty} (-1)^k \left( \frac{4}{5} \right)^k\text{,}\) whose sum is \(S = \frac{5}{9}\text{.}\) For instance, \(S_3\) is the sum of the first \(3\) terms of the infinite series.
If we plot the partial sums as ordered pairs of the form \((n,S_n)\text{,}\) as shown in Figure 8.6.2, we see important patterns in how the partial sums both approach and differ from the exact value of the infinite sum.
Figure8.6.2.Plotting the partial sums \(S_1\text{,}\)\(S_2\text{,}\)\(\ldots\text{,}\)\(S_8\text{.}\) The dashed horizontal line represents the exact sum of the infinite series, \(S = \frac{5}{9}\text{.}\)
In both our work in the Preview Activity and in Figure 8.6.2, we see how consecutive partial sums oscillate back and forth above and below the exact sum of the infinite series, \(\frac{5}{9}\text{,}\) and moreover how the absolute difference between \(S\) and \(S_n\) decreases as \(n\) increases.
The quantity \(|S - S_n|\) is the error in the partial sum approximation of the infinite series; we can study how this error compares to terms in the series itself. For instance,
Remember that \(S_5\) is the partial sum of the first \(5\) terms of the series, and likewise \(S_6\) is simply the sum of the first \(6\) terms. This means that \(\left| S_6 - S_5 \right|\) is the absolute value of the \(6^{\text{th}}\) term of the series, or \(\left| S_6 - S_5 \right| = \left( \frac{4}{5} \right)^5 = 0.32768\text{.}\) Combining (8.6.3) and (8.6.4), we have
Making this argument for an arbitrary value of \(n\) shows that the next term in the alternating sum always provides a bound on the error that arises from a given partial sum.
Our work with the geometric series \(S = \sum_{k=0}^{\infty} (-1)^k \left( \frac{4}{5} \right)^k\) suggests two general results that are true for any alternating series.
If we were to compute the partial sums \(S_n\) of any alternating series whose terms decrease to zero and plot the points \((n,S_n)\) as we did in Figure 8.6.2, we would see a similar picture: the partial sums alternate above and below the value to which the infinite alternating series converges. In addition, because the terms go to zero, the amount a given partial sum deviates from the total sum is at most the next term in the series. This result is formally stated as the Alternating Series Estimation Theorem.
If the alternating series \(S = \sum_{k=0}^{\infty} (-1)^{k}a_k\) has positive terms \(a_k\) that decrease to zero as \(k \to \infty\text{,}\) and \(S_n = \sum_{k=0}^{n-1} (-1)^{k}a_k\) is the \(n\)th partial sum of the alternating series, then
Again, this result simply says: if we use a partial sum to estimate the exact sum of a convergent alternating infinite series, the absolute error of the approximation is less than the next term in the series.
so the \(100^{\text{th}}\) partial sum is within \(0.0099\) of the exact value of the series. In addition, it turns out that \(S_{100} \approx 0.688172\) and \(S = \ln(2) \approx 0.69314\text{,}\) so we see that the actual difference between \(S_{100}\) and \(S\) is
Use the fact that \(\sin(x) = x - \frac{1}{3!}x^3 + \frac{1}{5!}x^5 - \cdots\) to estimate \(\sin(1)\) to within \(0.0001\text{.}\) Do so without entering “\(\sin(1)\)” on a computational device. After you find your estimate, enter “\(\sin(1)\)” on a computational device and compare the results.
Use this series representation to estimate \(\int_0^1 e^{-x^2} \, dx\) to within \(0.0001\text{.}\) Then, compare what a computational device reports when you use it to estimate the definite integral.
Find the Taylor series for \(\cos(x^2)\) and then use the Taylor series and to estimate the value of \(\int_0^1 \cos(x^2) \, dx\) to within \(0.0001\text{.}\) Compare your result to what a computational device reports when you use it to estimate the definite integral.
Explain why the series \(1 - \frac{1}{2} \cdot 1^2 + \frac{1}{3} \cdot 1^3 - \cdots + (-1)^{n-1} \frac{1}{n} \cdot 1^n + \cdots\) must converge and estimate its sum to within \(0.01\text{.}\) What is the exact sum of this series?
Subsection8.6.3Error Approximations for Taylor Polynomials
In the same way that the next term in an alternating series reveals the maximum error of a finite approximation, it turns out that a quantity related to the next term in a Taylor series determines the maximum error found in a Taylor polynomial approximation. This will enable us to know the degree of the Taylor polynomial that is needed in order to achieve a given accuracy tolerance on a chosen interval.
Throughout what follows, we assume that \(f(x)\) is a function with at least \(n+1\) derivatives at \(a = 0\text{,}\) and let \(T_n(x)\) be its degree \(n\) Taylor polynomial centered at \(a = 0\text{.}\) We define the error function of the degree \(n\) approximation, \(E_n(x)\text{,}\) by
Our overall goal is to understand how much error there is in the approximation \(f(c) \approx T_n(c)\) for some fixed value of \(c\text{;}\) in other words, we’d like to know the maximum possible value of \(| E_n(c) |\text{.}\)
This leads us to maximize the error function, \(E_n(x)\text{,}\) on the interval \([0,c]\text{.}\) We observe several important properties of \(E_n(x)\text{:}\)
\(E_n(0) = E_n'(0) = E_n''(0) = \cdots = E_n^{(n)}(0) = 0\text{,}\) since \(E_n(x) = f(x) - T_n(x)\) and \(f\) and \(T_n\) share the same function value and same first \(n\) derivative values at \(a = 0\text{;}\)
Taking Inequality (8.6.5), writing it in the form \(-M \lt E^{(n+1)}_n(t) \leq M\text{,}\) and integrating all three terms in the inequality from \(t = 0\) to \(t = x\) and doing so \(n+1\) times, it can be shown that
\begin{equation*}
-M \frac{x^{n+1}}{(n+1)!} \leq E_n(x) \leq M \frac{x^{n+1}}{(n+1)!}
\end{equation*}
It follows that
\begin{equation*}
| E_n(x) | \leq M \frac{|x|^{n+1}}{(n+1)!} \leq M \frac{|c|^{n+1}}{(n+1)!}
\end{equation*}
since \(|c|\) is the maximum value of \(|x|\) on the interval \(0 \leq x \leq c\text{.}\)
A similar argument works if we center the Taylor polynomial approximation at any real number \(a\) and leads to the following result, known as the Lagrange Error Bound.
Let \(f\) be a continuous function with \(n+1\) continuous derivatives. Suppose that \(M\) is a positive real number such that \(\left|f^{(n+1)}(x)\right| \le M\) on the interval \([a, c]\text{.}\) If \(T_n(x)\) is the degree \(n\) Taylor polynomial for \(f(x)\) centered at \(x=a\text{,}\) then
The Lagrange Error Bound shows that the total error in the degree \(n\) Taylor polynomial approximation is determined by a combination of:
the maximum value of the \((n+1)^{\text{st}}\) derivative of \(f\) on the interval of interest (which is a measure of how much polynomial approximation is being missed by using the degree \(n\) approximation);
and the degree \(n\) of the approximation, captured in two parts of the term \(\frac{|c-a|^{n+1}}{(n+1)!}\) (which makes sense since we’ve learned that the higher the degree, the better the approximation).
In practice, the quantity \(M \frac{|c-a|^{n+1}}{(n+1)!}\) provides a straightforward way to find a bound on the maximum error of a polynomial approximation of a non-polynomial function.
Determine the maximum error possible when using the degree \(10\) Taylor polynomial centered at \(a = 0\) for \(\sin(x)\) to approximate the value of \(\sin(2)\text{.}\)
To approximate the value of \(\sin(2)\) using the degree \(10\) Taylor polynomial, we will use \(f(x) = \sin(x)\text{,}\)\(c = 2\text{,}\)\(a=0\text{,}\) and \(n = 10\) in the Lagrange Error Bound formula. We also need to find a value for \(M\) so that \(\left|f^{(11)}(x)\right| \le M\) on the interval \([0,2]\text{.}\)
Since the derivatives of \(f(x) = \sin(x)\) are all one of \(\pm \sin(x)\) or \(\pm \cos(x)\text{,}\) and the maximum absolute values of these functions on any interval is \(1\text{,}\) we have
with an actual difference of about \(0.0000500159\text{.}\) Note that the computer algebra system itself is using a related approach (possibly with more terms) to generate the fact that \(\sin(2) \approx 0.9092974268\) in such a way that every decimal the computer reports is accurate.
Use the degree \(10\) Taylor polynomial (centered at \(a = 0\)) of \(f(x) = e^x\) to estimate the value of \(e^2\text{.}\) What is the maximum error of your estimate, according to the Lagrange Error Bound? How does this compare to the actual error between \(e^2\) and \(T_{10}(2)\) as reported by a computer algebra system?
Use a degree \(n\) Taylor polynomial (centered at \(a = 0\)) of \(f(x) = \cos(x)\) to estimate the value of \(\cos(1)\) within an accuracy of \(0.00000001\text{.}\) According to the Lagrange Error Bound, what value of \(n\) is needed to achieve this accuracy? What is the resulting approximate value of \(\cos(1)\text{?}\)
If we want to estimate \(f(0.5) = \ln(1.5)\) to within an accuracy of \(0.0001\text{,}\) what value of \(n\) is needed to achieve this accuracy from computing \(T_n(0.5)\text{,}\) according to the Lagrange Error Bound?
If we approximate an infinite series with one of its partial sums, we can often quantify the maximum error present in the truncated sum. Two ways the error can be measured are through the Alternating Series Estimation Theorem (if the original series is alternating) and through the Lagrange Error Bound (if the original series can be viewed as a Taylor series).
where \(a_k \gt 0\) for all values of \(k\text{.}\) Any alternating series whose terms \(a_k\) approach zero as \(k \to \infty\) is guaranteed to converge. Moreover, the Alternating Series Estimation Theorem tells us that we can estimate the exact value of a converging alternating series by using a partial sum, and the error of that approximation is at most the next term in the series. That is,
The Lagrange Error Bound quantifies the accuracy when we a Taylor polynomial to approximate a function. Specifically, if \(T_n(x)\) is the degree \(n\) order Taylor polynomial for \(f\) centered at \(x=a\) and if \(\left|f^{(n+1)}(x)\right| \leq M\) for some real number \(M\) on the interval \([a, c]\text{,}\) then
how many terms do you have to compute in order for your approximation (your partial sum) to be within 0.0000001 from the convergent value of that series?
Note: The answer you derive here should be the partial sum of an appropriate series (the number of terms determined by an error estimate). This number is not necessarily the correct value of the integral truncated to the correct number of decimal places.
Note: The answer you derive here should be the partial sum of an appropriate series (the number of terms determined by an error estimate). This number is not necessarily the correct value of the integral truncated to the correct number of decimal places.
Observe that your result in (a) is an alternating series. Estimate the value of that alternating series to within \(0.01\text{.}\) How many terms of the series are needed to do so?
How are your results in (a) and (c) connected? What famous number can we now estimate using an alternating series? How many terms of the series were needed to ensure the first two digits of the famous number are accurate?