Why does Excel fail to properly evaluate $ \lim_{x \to 0} \frac{x(e^x+1)-2(e^x-1)}{x^3} $?

284 Views Asked by At

I have this limit: $$ \lim_{x \to 0} \frac{x(e^x+1)-2(e^x-1)}{x^3} $$ By using L'Hospital rule and Maclaurin expansion I both found that limit equals to $1/6$.

I want to simulate this to my student by Excel but I failed. This is my computation in Excel.

enter image description here

I did not know why Excel doesn't work in this situation?

Please help me. Thanks alot.

2

There are 2 best solutions below

3
On

If I do with Mathematica the same thing that you did with Excel, then I get a similar answer. That is due to numerical errors that are a consequence of a catastrophic cancellation, as you were told in the comments. However, I can force Mathematica to work with greater numerical precision and if I tell it to compute those numbers with ten significant figures, then I get a nice answer:

$$\begin{array}{c|c}n&f(10^{-n})\\\hline0&0.2817181715\\1&0.1752556563\\2&0.1675025056\\3&0.1667500250\\4&0.1666750003\\5&0.1666675000\\6&0.1666667500\\7&0.1666666750\\8&0.1666666675\\9&0.1666666668\end{array}$$I don't know whether or not you can do the same thing with Excel, but this could be a good lesson for your students.

1
On

In the evaluation of the numerator you can incur a floating point error of about the size $(2+|x|)e^x\mu$, $\mu=2^{-52}$ being the machine constant. For $x\approx0$ this is $2\mu\approx 4\cdot 10^{-15}$. In the quotient this makes an error of $\frac{2\mu}{x^3}$.

In the series expansion the next term after the constant one is $\frac{x}{12}$. The floating point error becomes larger than the linear term at about $\frac{x}{12}=\frac{2\mu}{x^3}$, that is, $x=\sqrt[4]{24\mu}=2.7\cdot10^{-4}$. This is the region of minimal error, and also the point where your results turn away from convergence.

enter image description here