# $e^{-5}$ error using Taylor's series

I am a student and I was reading Numerical Analysis by Burden. In one of the exercises, I have to calculate $e^{-5}$ in two ways.

The first is using the Taylor's series for $x=-5$, $( e^{-5} = 1 - 5/1! + 5^2/2!-...)$ and second way is calculating $e^5$ and then $e^{-5}=1/e^5$, again using Taylor's series but this time for $x=5$. In his solution, he says second way gives better results because we avoid subtraction. I think that it has to do with the floating point system but I am not very sure so I thought someone could further explain it to me. (Sorry if I have made any mistakes. English is not my native language)

• As Carl Bender famously points out, one of the worst things you can do with a series is sum it. – Pseudonym Jan 23 '17 at 1:00
• This is a pure mathematics question and should have been posted on or migrated to Mathematics. – Raphael Mar 12 '17 at 17:57
• $e^{-5}$ is not a good example, because you would get two plausible but different results. I'd choose a negative argument large enough so that the imprecise calculation gives a result outside [0, 1] where the result should be. – gnasher729 Jul 10 '17 at 22:13

Use a spreadsheet and calculate $e^{-100}$ both ways. It will become totally obvious what is going on. "We avoid subtraction" is not the problem. The problem is that you are adding the sum or difference of large numbers, and each large number has a large rounding error. For one method, the rounding error is not large compared to the result. For the other matter, the rounding errors are huge compared to the result.

Once you expand the series for

$$e^{(-x)}$$

you are going to get alternative negative terms as we can see the nth derivative of

$$e^{(-x)} = (-1)^n * e^{(-x)}$$