12

I was looking at the function

$$ \frac{1}{1-e^{-\frac{1}{e^x}}}-e^x - \frac{1}{2}$$

I thought I had reason to believe this tends to 0 as $x$ tends to positive infinity because

$$ \sum_{n=0}^{\infty} e^{nx} = \frac{1}{1-e^x}= -\frac{1}{x}+\frac{1}{2}-\frac{1}{12}x \ + \ ...$$

So:

$$ \sum_{n=0}^{\infty} e^{-\frac{n}{x}} = \frac{1}{1-e^{-\frac{1}{x}}} = x + \frac{1}{2}+\frac{1}{12x} \ + \ ...$$

So:

$$ \sum_{n=0}^{\infty} e^{-\frac{n}{e^x}} = \frac{1}{1-e^{-\frac{1}{e^{x}}}} = e^x + \frac{1}{2}+\frac{1}{12e^x} \ + \ ...$$

So one would expect that

$$ \frac{1}{1-e^{-\frac{1}{e^{x}}}} - e^x - \frac{1}{2} $$

tends to 0 as $x$ goes to infinity as the coefficients are proportional to $\frac{B_n}{n!}$

Surprisingly, both Wolfram Alpha, and Desmos disagree, see images below:

desmos oscillation

wolfram oscillation

My gut feeling tells me i'm still correct here but the odds of tripping up TWO different graphing platforms seems unlikely so I wanted to get a reality check from someone:

Here are links to the graphs: Wolfram and Desmos

  • 9
    Have a look at this plot of the function $$\frac{1}{1-e^{-t}} - \frac{1}{t}$$ It gives you exactly what you expect, and because it is continuous with $f(0) = \frac{1}{2}$ we should be able to freely compose it with another continuous function such as $e^{-x}$. Most likely you are running into machine precision problems, which produces unbounded errors when you add two numbers which sum really close to zero. – Ninad Munshi Jun 28 '23 at 02:08
  • 1
    From those graphs , we cannot conclude the limit for $x\to \infty$ – Peter Jun 28 '23 at 07:11

2 Answers2

10

You want $$ \lim_{x \to +\infty} \frac{1}{1-e^{-\frac 1{e^x}}} - e^x - \frac 12 $$

Setting $e^x = t$, note that $t \to +\infty$ as $x \to +\infty$. Therefore, $$ \lim_{x \to +\infty} \frac{1}{1-e^{-\frac 1{e^x}}} - e^x - \frac 12 = \lim_{t \to \infty} \frac{1}{1-e^{-1/t}} - t-\frac 12. $$ Let $u = 1-e^{-\frac 1t}$. Then, $e^{-\frac 1t} = 1-u$ and hence $\frac {-1}{\ln(1-u)} = t$. Hence, as $t \to +\infty$, $\ln(1-u) \to 0^-$, hence $u \to 0^+$. Therefore, $$ \lim_{t \to \infty} \frac{1}{1-e^{-1/t}} - t-\frac 12 = \lim_{u \to 0^+} \frac 1u +\frac{1}{\ln(1-u)} - \frac 12=\lim_{u \to 0^+} \frac{\ln(1-u)+u}{u\ln(1-u)} - \frac 12 \\ = \lim_{u\to 0^+} \frac{\ln(1-u)-(-u)}{u^2}\frac{u}{\ln(1-u)} -\lim_{ u \to 0^+} \frac 12 $$ By the Taylor expansion of $\ln(1-u)$ near $u=0$, the limit of the first term equals $\frac 12 \times 1 = \frac 12$. Hence, the limit of the entire expression equals $0$, as desired.


It is impossible that the function in question can oscillate. By the derivative test, the the derivative of $\frac{1}{1-e^{-1/t}} - t - \frac 12$ is negative, which implies that the function is monotonically decreasing as $t \to +\infty$.

Therefore, any authentic enough rendering of the function at those values clearly requires monotonicity to be respected. As a comment points out, just because a function is oscillatory in a particular interval doesn't mean that it cannot have a limit. However, in this case the function cannot be oscillatory anywhere, and yet is shown to be precisely that on a particular interval, proving the inaccuracy of the graphs.


The oscillating behavior has to do with small value floating point errors, which are compounded by various operations. Namely, small enough values are set to $0$ by Wolfram Alpha.

In this case, the small values in question arise from the term $1-e^{-\frac 1{e^x}}$ which is going to $0$. When this value is extremely close to $0$, it cannot be approximated accurately. What happens is that, instead of computing this quantity, we end up computing $$ 1+\delta-e^{-\frac 1{e^{x}}}, $$ where $\delta$ is some truncation error. Given the true value of $x$, if one changes $x$ to $x+h$ then the value of this function changes roughly by $he^{-x-e^{-x}}$ by the MVT. Thus, $\delta = he^{-x-e^{-x}}$ which implies that $h = \delta e^{x+e^{-x}}$.

This shows that even if the truncation error is small, the function $1+\delta-e^{-\frac 1{e^{x}}}$ ends up looking like its value not at the point $x$ but rather at the point $x+h$ where $h$ is something exploding as $x \to \infty$ (if $\delta$ can be lower bounded away from $0$, which is generally the case depending upon the values of $x$ in consideration). Furthermore, note that $\delta$ can take positive or negative values depending upon the $x$ in consideration.

Furthermore, we are following up this error by taking the reciprocal of the function. Note that the reciprocal amplifies the sign issue, because $\frac 1y$ has the same sign as $y$ but also a much larger magnitude if $y$ has a small magnitude. Therefore, the error propagates to the reciprocal, but it is much more amplified. Roughly speaking, what happens is that the reciprocal obtained by Wolfram Alpha is not that obtained by actual evaluation at $x$, but rather at some point $x+h$, where $h$ depends on $x$ in such a way that $|h|$ probably goes to infinity as $x$ goes to infinity. Adding in the fact that $h$ may take positive or negative values unboundedly and the nature of the oscillation becomes clearer. Note that $e^x$ should also be carrying errors, but these are of smaller magnitude than that of the reciprocal term. The reciprocal term is the one doing the damage in both graphs.

Another example of how small terms cause damage is when you take the same limit pattern and plot the function $\frac{e^{-x}}{(1-e^{-1/e^x})} - 1$, which has limit $0$. This function will begin to oscillate due to errors, even quicker than the previous one. That's because there's not one small term here in consideration, but two small terms, since $e^{-x}$ is also very small and poorly approximated for $x$ large. These errors compound and make the apparent behavior of the function even worse than the previous situation, despite the limit still being equal to $0$.

Perhaps the lesson here is that we cannot always deduce limit behaviors from plots : instead, we must either seek to reduce inflammatory expressions by substitution (since this doesn't affect limit behavior) or, in our algorithms, must ensure that most errors are "benign" rather than "catastrophic", so that the graphs are easier to interpret. The former is a way out here, since the substitution of $t = e^x$ instantly makes the limit behavior clearer from a graphic point of view (until you hit something like $t = 10000$ and see the oscillations again, that is).

3

Let $h=e^{-x}$ so that $h\xrightarrow{x\rightarrow\infty}0+$. After algebraic manipulations, one gets $$ \frac{e^h}{e^{h}-1}-\frac{1}{h} =\frac{he^h-e^h+1}{he^h-h}$$ The limit as $x\rightarrow\infty$ (equivalently, as $h\rightarrow0+$) can be obtained by L'Hospital rule: $$\frac{he^h-e^h+1}{he^h-h}\stackrel{LHR}{\sim}\frac{he^h}{he^h+e^h-1}=\frac{e^h}{e^h+\frac{e^h-1}{h}}\xrightarrow{h\rightarrow0}\frac{1}{2}$$ Thus $$\lim_{x\rightarrow\infty}\frac{1}{1-e^{-e^{-x}}}-e^x-\frac12=0$$


The issue with your computer calculation is that

  1. The exponential grows very fast and thus very quickly $1/e^x$ is less than the machine epsilon.
  2. Subtraction is not a good computer operation when large numbers are involved, they often generate oscillations when there are none.
  3. Algebraic manipulations, changes of variables, and/or asymptotic methods are always advisable when one has a small (or large) parameter.

In the OP's case, simple calculus gives the limit and also the behavior of the function. An asymptotic expansion can be obtained from the work the OP did with series expansions): After setting $h=e^{-x}$, so that $h\rightarrow0$ iff $x\rightarrow\infty$, we obtain a the expression $$\Phi(h)=\frac{1}{1-e^{-h}}-\frac{1}{h}-\frac12$$ It is known that the function $f(h)=\frac{1}{1-e^{-h}}$ is analytic at $t=0$ and has a convergent series expansion $$ \frac{h}{1-e^{-h}}=\sum^\infty_{n=0}\frac{b^+_n}{n!}h^n $$ for $|h|<2\pi$ (the numbers $b^+_n$ are the Bernoulli numbers (there are also the numbers $b^-_n$ which appear in $-f(-h)$). An expression directly associated to the OP's function is $$ \frac{1}{1-e^{-h}}=\frac{b^+_0}{h}+b^+_1 +\sum^\infty_{n=2}\frac{b^+_n}{n!}h^{n-1}$$ It is easy to check that $b^+_0=1$, $b^+_1=\frac12$, and that in general $b^+_m=1-\sum^{m-1}_{k=0}\binom{m}{k}\frac{b^+_k}{m-k+1}$ for $m\geq1$. Hence $$\Phi(h):=\frac{1}{1-e^{-h}}-\frac{1}{h}-\frac12 \sim \sum^\infty_{n=1}\frac{b^+_{n+1}}{(n+1)!}h^n\qquad\text{as $h\rightarrow0$ }$$

The symbol $\sim$, introduced by Poincaré, means the following: Suppose $g_{n+1}(z)=o(g_n(z))$ as $z\rightarrow z_0$. Then, $f(z)\sim \sum^\infty_{n=0}a_ng_n(z)$ as $z\rightarrow z_0$ iff for any $m\in\mathbb{Z}_+$, $$f(z)-\sum^m_{k=0}a_kg_k(z)=o(g_m(z))\qquad\text{as $z\rightarrow z_0$}$$

In the OP's case we actually have equality, but $\sim$ works for cases in which a series is divergent.

Hence $\lim_{x\rightarrow\infty}\Phi(e^{-x})=0$, furthermore, the asymptotic expansion provides further information on how fast $\Phi(e^{-x})$ decays to $0$ as $x\rightarrow\infty$), i.e. the error of approximation.

Mittens
  • 46,352