When I plot the following function, the graph behaves strangely:
$$f(x) = \left(1+\frac{1}{x^{16}}\right)^{x^{16}}$$
While $\lim_{x\to +\infty} f(x) = e$ the graph starts to fade at $x \approx 6$. What's going on here? (plotted on my trusty old 32 bit PC.)
I guess it's because of computer approximation and loss of significant digits. So I started calculating the binary representation to see if this is the case. However in my calculations values of $x=8$ should still behave nicely.
If computer approximation would be the problem, then plotting this function on a 64 bit pc should evade the problem (a bit). I tried the Wolfram Alpha servers:
The problem remains for the same values of $x$.
Questions
- Could someone pinpoint the problem? What about the 32 vs 64 bit plot?
- Is there a way to predict at which $x$-value the graph of the function below would start to fail? $$f_n(x) = \left(1+\frac{1}{x^n}\right)^{x^n}$$
32bit vs. 64bit affects which integer types are used by default, which is of no interest here. Rather, the floting point computations are made (by default) with IEEE
double
type. With thisdouble
precision (53 bit mantissa), the relative error of $(1+\frac1{x^{16}})$ is approximately $2^{-53}$. Raising to the $x^{16}$th power roughly multiplies the relative error, so it's $\frac{8^{16}}{2^{53}}=2^{-5}$ (so absolutely $\approx 0.1$) for $x=8$, which does match your plot. At $x=9$ we can expect a relative error $\frac{9^{16}}{2^{53}}\approx0.2$, also consistent with your plot. For $x>10$ we have $x^{16}>2^{53}$, so $(1+\frac1{x^{16}})\dot=1$, whereas righ tbefore this cutoff to a terminally too small $(1+\frac1{x^{16}})$, we have a longer phase of too big in the last and only bit, i.e., we essentially compute $(1+\frac2{x^{16}})^{x^{16}}\approx e^2\approx 7.4$.