Evaluate the following function using as many significant figures as required to get a final result of 4 digits accuracy

1.3k Views Asked by At

I need to evaluate $$ f_5(0.2) = 5! \left[ e^{0.2} - \left( 1 + (0.2) +\frac{(0.2)^2}{2!}+\frac{(0.2)^3}{3!} + \frac{(0.2)^4}{4!} +\frac{(0.2)^5}{5!} \right) \right] $$ using as many as required significant figures as necessary to obtain 4 decimal places accuracy in the final result.

So, I know how to do the required calculations, but I don´t know how justify the initial significant figures required to get the desired result.

I know that inside squared brackets I have the difference of between $e^{0.2}$ and an approximation $(e^{0.2})^*$, so as expected their difference will near to zero and some cancellation will occurs.

I use 12 decimal figures accuracy with rounding and I get

\begin{eqnarray*} f_5(0.2) &=& 5! \left[ e^{0.2} - \left( 1 + (0.2) +\frac{(0.2)^2}{2!}+\frac{(0.2)^3}{3!} + \frac{(0.2)^4}{4!} +\frac{(0.2)^5}{5!} \right) \right]\\ &\approx& 5! \left[ e^{0.2} - \left( 0.12\times10^{1} +\frac{(0.2)^2}{2!}+\frac{(0.2)^3}{3!} + \frac{(0.2)^4}{4!} +\frac{(0.2)^5}{5!} \right) \right]\\ &\approx& 5! \left[ e^{0.2} - \left( 0.122\times10^{1} + \frac{(0.2)^3}{3!} + \frac{(0.2)^4}{4!} +\frac{(0.2)^5}{5!} \right) \right]\\ &\approx& 5! \left[ e^{0.2} - \left( 0.122\times10^{1} + 0.133333333333\times10^{-2} + \frac{(0.2)^4}{4!} +\frac{(0.2)^5}{5!} \right) \right]\\ &\approx& 5! \left[ e^{0.2} - \left( 0.122133333333\times10^{1} + \frac{(0.2)^4}{4!} +\frac{(0.2)^5}{5!} \right) \right]\\ &\approx& 5! \left[ e^{0.2} - \left( 0.122133333333\times10^{1} + 0.666666666667\times10^{-4} +\frac{(0.2)^5}{5!} \right) \right]\\ &\approx& 5! \left[ e^{0.2} - \left( 0.122140000000\times10^{1} +\frac{(0.2)^5}{5!} \right) \right]\\ &\approx& 5! \left[ e^{0.2} - \left( 0.122140000000\times10^{1} + 0.266666666667\times10^{-5} \right) \right]\\ &\approx& 5! \left[ e^{0.2} - 0.122140266667\times10^{1} \right]\\ &\approx& 120 \left[ 0.122140275816\times10^{1} - 0.122140266667\times10^{1} \right]\\ &\approx& 120 \left[ 0.914900000000\times10^{-7} \right]\\ &\approx& 0.109700000000\times10^{-4}\\ \end{eqnarray*} Assuming the fact that $f_5(0.2)\approx 0.0000109792...$ is the "correct" result using Wolfram alpha I think that using 12 significant figures is the right answer.

So, my questions are:

  1. Is really 12 significant figures the right answer?
  2. If yes, how can I justify that fact?

Thanks.

NOTE1: I can´t use an alternate formula for the calculation, so no re-expression is allow.

NOTE2: Please note the fact that its a numerical methods/analysis problem, so I need to warranty/demostrate that if a I use $m$ significant figures, using rounding in each step then I will get $f_5(0.2)$ with 4 decimal places accuracy.

2

There are 2 best solutions below

2
On

You have shown that using 12 digits does get you enough accuracy, but you can get away with less.

Hint: Using Taylor series, you have $e^x = \displaystyle\sum_{n=0}^{\infty}\dfrac{x^n}{n!} = 1+x+\dfrac{x^2}{2!}+\dfrac{x^3}{3!}+\dfrac{x^4}{4!}+\dfrac{x^5}{5!}+\sum_{n=6}^{\infty}\dfrac{x^n}{n!}$.

Therefore, $f_5(x) = 5!\displaystyle\sum_{n=6}^{\infty}\dfrac{x^n}{n!}$, and thus, $f_5(0.2) = 5!\displaystyle\sum_{n=6}^{\infty}\dfrac{(0.2)^n}{n!}$.

If you truncate that sum at $n = m$, then the remaining terms sum to at most $5!\displaystyle\sum_{n=m+1}^{\infty}\dfrac{(0.2)^n}{n!} \le 5!\displaystyle\sum_{n=m+1}^{\infty}\dfrac{(0.2)^n}{m!} = \dfrac{5!}{m!} \cdot \dfrac{(0.2)^{m+1}}{1-0.2}$.

Now, how big does $m$ need to be to ensure that this gets you 4 sig figs of accuracy?

1
On

You are currently finding the Taylor series for $e^x$. The way it works is that it gives you an approximation by finding the derivatives of the function and using them to express the function as a power series. (if you don't yet know what a taylor or maclaurin series is, i recommend Khan or MIT OCW; Khan is slightly better)

(note: for a mathier kind of answer, see patrickjmt and his conversation on Taylor's remainder theorem here. Just keep in mind that the remainder is the same thing as the error. here is Khan's attempt to answer this question. The rest of this answer will be intuition)

There are two basic kinds: the kinds that alternate in terms of sign, and those that don't. For either, the term after the last is less than the error for all other terms. This is because the terms keep getting smaller and smaller as the series continues.

For example, take the infinite series expansion of 1:

$$\frac{1}{2}+\frac{1}{4}+\frac{1}{8}+\frac{1}{16}+\frac{1}{32}+\frac{1}{64}+\frac{1}{128}+...$$

This works because each term gets us closer and closer to the answer. For example, if we only took 1 term, the error would be no greater than 1/2 (which we know is true) because the rest only adds up to (but never reaches) 1. For the first two terms, the total is 3/4, and we know the error is never going to be more than 1/4 because the entire rest of the series has to be less than this amount.

The other kind of series, the alternating one, is (in my opinion) much cooler. I think of the error kind of like the graph of sin x/x (desmos dat) because the estimate keeps going higher and lower and higher and lower, but these sums end up converging toward a single number. But at the same time, the last term in the sum is going to be the absolute maximum of the error because all following terms add up to less than that term.

The reason this is important is because if the last term of our sum is, say 0.00001, then we know with complete certainty (provided the series converges) that the rest of the sum will be less than 0.00001