# Why is $e^\pi - \pi$ so close to $20$?

$e^\pi-\pi\approx 19.99909998$

Why is this so close to $20$?

• by chance (6 more to go...) Mar 24 '14 at 15:51
• It's not close at all. There are infinitely many numbers closer than that. Mar 24 '14 at 16:15
• Obligatory link: xkcd.com/217 Mar 24 '14 at 17:26
• The $0$ at $10^{-4}$ removes any relevance of the $9998$ that follows... Jan 3 '16 at 14:50
• Though these comments are somewhat old, the argument that "[there] are infinitely many numbers closer" is unconvincing. For if the difference was, say, $10^{-10^{9}}$ or some other ridiculously tiny number, one could still employ that argument but I don't think many would accept it then. The reason for this is perhaps psychological, and perhaps that other near-integers (ie. Ramanujan's constant) are near-integers for a reason. Jan 4 '16 at 0:19

It cannot be accidental in the real sense. It is either special or typical. Observe that in almost all such equations it is always something else in disguise. For example, in many cases you can reduce numbers to their rational approximations and explicitly check everything.

Instead of just using approximation, you can find some simpler connection and argue about extreme values or something that is going to give you a common reason for the equation.

One of the examples of this procedure is given in: Prove $\left(\frac{2}{5}\right)^{\frac{2}{5}}<\ln{2}$

and I will illustrate here how we can check your statement above using the simple approximation of $$\pi \approx \sqrt{10}$$. This is probably not sufficient on its own for immediate success but it gives you the flavor of the method, and it gives you some estimation to work around, especially, it specifically explains that it is not $$e$$ or $$\pi$$ in many similar equations, it is just something that looks like it.

So the equation we are interested in becomes

$$y^{\sqrt{x}}-\sqrt{x}=20$$

The solution is of course

$$y=(\sqrt{x}+20)^{\frac{1}{{\sqrt{x}}}}$$

We can expand it around 0 and get

$$(\sqrt{x}+20)^{\frac{1}{{\sqrt{x}}}} = e^{\frac{1}{{\sqrt{x}}}\ln{(\sqrt{x}+20)}} \approx e^{\frac{\ln(20)}{\sqrt{x}}+\frac{1}{20}-\frac{\sqrt{x}}{800}+...}$$

For the sake of simplicity we will ignore the terms beyond $$-\frac{\sqrt{x}}{800}$$ and simply try to solve

$$\frac{\ln(20)}{\sqrt{x}}+\frac{1}{20} = 1$$

This gives

$$x=\frac{400\ln{20}^2}{361}$$

Well now it is easy

$$\frac{400\ln{20}^2}{361} \approx \frac{400\ln{20}^2}{360}=10(\frac{\ln{20}}{3})^2$$

and now comes the simple part $$\ln(20)=2.995 \approx 3$$ making $$(\frac{\ln{20}}{3})^2 \approx 1$$ and $$x \approx 10$$ as expected which is the key reason for the equation itself.

This is all telling you that you are right, but something is still missing.

What remains is to justify the remainder.

$$e^{\pi}-\pi=e^3 \cdot e^{\pi-3}-\pi=20$$ $$20 e^{\pi-3}-\pi \approx 20$$ $$e^{\pi-3}\approx 1+\frac{\pi}{20}$$

I hope that you can see the game here. $$0.14$$ is still small enough for reasonable estimation of $$e^{\Delta{x}}=1+\Delta{x}$$ and at the same time $$\frac{\pi}{20} \approx 0.15 \approx \pi - 3$$

So this last part is essentially $$e^{\pi-3}\approx 1+\pi-3 \approx 1+\frac{\pi}{20}$$

As you can see the equation in question is not much more than a game of two combined "accidents" $$\ln(20) \approx 3 \; \; \; (1)$$ and $$\frac{\pi}{20} \approx \pi - 3 \; \; \; (2)$$

We can establish a strict form and write

$$e^{3+x}-(3+x)=e^3$$

This has a nice solution in form of Lambert function

$$x=-W_{-1}(-e^{-e^3})-3-e^3 \approx 0.1454$$

but this is just rephrasing all what we have said already.

The key reason for the entire conundrum is obviously $$-W_{-1}(-e^{-e^3})-e^3 \approx \pi$$

Observe that the true nature of it is given by the approximations (1) and (2). This last is just all that at more sophisticated level. Still it has not much to do with $$\pi$$ itself, just with its value, as strange as this may sound.

You may ask, ok, but why do we have $$\ln(20) \approx 3$$? That is strange on its own. You can approach this by using some series for $$e^x$$ and argue about the zeros or you can again use something like

$$\frac{e^{x+1}}{5x}-x$$

and find that this has a minimum around $$x=1.99...$$ since it is achieved for $$e^{x+1}(x-1)=5x^2$$ and even just by looking at it you can see that $$x \approx 2$$ providing $$e^3 \approx 20$$ or the other way around.

I would truly consider the approximate thing of $$e^{\pi}-\pi \approx 20$$ as very much solved by this analysis.

For some reason unknown to me, it will not be that fast to find this or some derived explanation around the Internet. It can't be all that there is to it, can it?

Unless you want to add a factor or two more to justify maybe one digit more it is indeed all that there is to it: $$\ln(20) \approx 3$$ and $$\frac{\pi}{20} \approx \pi-3$$

(The reason I have used $$\sqrt{10}$$ for $$\pi$$ is to have something to check the estimations without going more close to the value of $$\pi$$ itself. Using $$\sqrt[3]{31}$$ we can achieve somewhat better accuracy but that is not completely necessary at first.)

If you are still in doubt simply draw an implicit graph $$y(x)$$ of

$$e^{x(1+\frac{1}{e^{y}})}-x(1+\frac{1}{e^{y}})-e^{y}=0$$

and notice how fast after 1 it becomes very close to $$y(x)=x$$. As an exercise you may even try to find derivative of this function.

In that sense this has not much to do with $$\pi$$ itself, it is something else in disguise.

Since we got very close, I will explain the final steps leading more precisely to the approximation. We start from

$$e^{3+x}-(3+x)=e^3$$

and realize that $$e^3$$ is a little bit larger than $$20$$. We rewrite it all as

$$e^{3+x}-(3+x)=e^{3-y}$$

and now all values are small so we can use linear approximation getting

$$(e^{3+x}-1)\mathrm{d} x=-e^{3-y}\mathrm{d} y$$

which makes

$$\mathrm{d} y = -\frac{(e^{3+x}-1)}{e^{3-y}}\mathrm{d} x$$

or with all things we know so far it is

$$\mathrm{d} y \approx -\frac{22}{20}\mathrm{d} x$$

We would like to reduce $$x$$ by about $$0.003899$$, which requires increasing y by about

$$\frac{22}{20}0.003899=0.0042889$$

Notice now that $$3-\ln(20)=0.00426...$$ almost precisely the figure we need in order to reach $$20$$ from $$e^3$$. Regardless of this last precision details, we could say that we are by chance almost as close to $$\ln(20)$$ in one case as we are to $$\pi$$ in another. This is not what is creating the approximation completely, this last is just adding a digit or two to the result because it can.

These last details are somewhat self-regulating since we are using linear approximations that are adding by themselves a digit or two more and the functions used are constantly some sort of $$e^x$$ so the needed ratio remains. What looks like some sort of chance (or design) is that all figures are sufficiently and relatively precisely close to each other so that we can use linear approximations and confirm that they are even closer.

Last but not least is indeed magic. Once we have reached a proximity of probably below fifth or sixth decimal digit, we allow ourselves a little bit of trickery. Imagine, we have the result of 19.9999999 for some value close to $$\pi$$, but in order to reach $$\pi$$ more closely we need 19.9992. We would totally allow this and still be surprised since our sense of being close allows a final margin of error to be just anything. In essence this is a trick since we are actually forcing the result close to what we want at the expense of enlarging the error.

You can find a similar magical effect on many even very serious sources which claim instead of the above that $$\cos(\ln(\pi+20)) \approx 1$$. $$\cos$$ is reducing the error around $$1$$ making the result even more "surprising", but unless this form is supported by some deeper theory, it is advisable to keep the form so that the surprising integer effect is lowered. (The form $$\cos(\ln(\pi+20))$$ is probably not going into the right direction since even $$\cos(\ln(\pi+21))$$ or $$\cos(\ln(\pi+19))$$ is "close" to 1 then.)

Far from being a complete trick, these almost integers are hiding some properties of the constants we know so well, which we would not be aware of otherwise.

All the above is saying why we have these two numbers so close, but it does not say if the situation is special in any particular way. If you run a simulation of around the same size random numbers, minimizing the value $$av_{1}+bv_{2}+c$$ you will notice that this behavior together with the error term below 0.001 is typical, you find about one or two solutions that use integers, $$a,b,c$$ in the range $$[-25,25]$$.

The fact that we have one large integer of 20 is another strong indication that there is no special linear relation between $$e^{\pi}$$ and $$\pi$$ that is not within the same rank of two average random numbers in the same range. For example, the testing shows that if there is more than one solution the average of integers employed is lower, and for our case $$\frac{20+1+1}{3} \approx 7$$ is just about right for the numbers that have one integer connection for the given margin of 0.001. There is no statistical evidence, if you want, that points to any special connection, which is to say that there could be as many as you like without any indication over which one is more correct.

(Of course the situation is simple enough to check all this using the probability theory, but for the moment we were quite happy with the simulation.)

This above is an illustration of the method. It gives the flavor. A full account actually goes over the function

$$-x-W_{-1}(-\frac{1}{e^{x}})$$ which is a solution for $$y$$ of $$e^y-y=x$$

We start from $$x_{0}=e^3-3 \approx 17$$ because $$-x_{0}-W_{-1}(-\frac{1}{e^{x_{0}}})=3$$

and we want to get to

$$-20 -W_{-1}(-\frac{1}{e^{20}}) \approx 3.1416 \approx \pi$$

We expand $$-x-W_{-1}(-\frac{1}{e^{x}})$$ around $$e^3-3$$ getting

$$-20-W_{-1}(-\frac{1}{e^{20}})=3+\frac{23-e^3}{e^3-1}-\frac{e^3(23-e^3)^2}{2(e^3-1)^3}+$$ $$\frac{e^3(23-e^3)^3(1+2e^3)}{6(e^3-1)^5}-\frac{e^3(23-e^3)^4(1+8e^3+6e^6)}{24(e^3-1)^7}+$$ $$\frac{e^3(23-e^3)^5(1+22e^3+58e^6+24e^9)}{120(e^3-1)^9}...$$ getting with first 5 terms $$3.14163...$$ only to realize that except at first few digits the value has no recognizable connection with $$\pi$$ itself.

If we make a crude assumption that $$e^3 = 20$$ we have that the value is $$\approx 3+\frac{3}{19}-\frac{9\cdot 20}{2\cdot 19^3}+\frac{27\cdot 820}{6\cdot 19^5}-...$$ which nicely explains the logic we have been trying to follow in the text considering the structure of the value of $$\pi$$.

Another options is to have it all expanded around $$x_{0}=20-\ln(20)$$, because $$-W_{-1}(-\frac{1}{e^{x_{0}}})=20$$. And now you need only $$\ln(20) \approx 3$$ to express the approximation to $$\pi$$.

$$-20-W_{-1}(-\frac{1}{e^{20}})=\ln(20)+\frac{\ln(20)}{19}-\frac{10\ln^2(20)}{19^3}+\frac{410\ln^3(20)}{3\cdot 19^5}$$ $$-\frac{12805 \ln^4(20)}{6\cdot 19^7}+\frac{215641 \ln^5(20)}{6\cdot 19^9}-\frac{22884241 \ln^6(20)}{36\cdot 19^{11}}+...$$

Finally if you expand around $$x_{0}=e^\pi - \pi$$ since $$-x_{0}-W_{-1}(-\frac{1}{e^{x_{0}}})=\pi$$ you have even the error term in a more precise form:

$$-20-W_{-1}(-\frac{1}{e^{20}})=\pi+\frac{20+\pi-e^{\pi}}{e^{\pi}-1}-\frac{e^{\pi}(20+\pi-e^{\pi})^2}{2(e^{\pi}-1)^3}+...$$

And the second term defines the error since the third is already $$\sim 10^{-9}$$, $$\frac{20+\pi-e^{\pi}}{e^{\pi}-1} \approx 0.00004$$.

• This is a really nice answer ! Thanks for providing it. Jan 5 '16 at 11:04

You may find :

This curious near-identity was apparently noticed almost simultaneously around 1988 by N. J. A. Sloane, J. H. Conway, and S. Plouffe, but no satisfying explanation as to "why" $e^\pi-\pi \simeq 20$ is true has yet been discovered.

after some googling.

• It's probably no accident that this is the very same S. Plouffe who coined the name "Ramanujan Constant" for the almost-integer $e^{\pi\sqrt{163}}$. Jan 14 '16 at 10:26
• well now this answer has exactly 20 upvotes, no approximation necessary
– Alex
Sep 30 '16 at 10:59
• "well now this answer has exactly 20 upvotes, no approximation necessary" - Sorry to burst your bubble, but one of those upvotes was only .99909998 of an upvote. The site doesn't display fractional upvotes carefully enough. Dec 6 '20 at 4:20
• Well, that's not good enough either. Really, that last one needed to be $(e^{\pi}-\pi-19)$'ths of an upvote. $.99909998$ isn't NEARLY good enough. Oct 5 '21 at 7:01
• Well, that's not good enough either. Really, that last one needed to be $(e^{\pi}-\pi-19)$'ths of an upvote. $.99909998$ isn't NEARLY good enough. Oct 5 '21 at 7:03

The proximity to $\pi$ is purely coincidental, as is often the case. Take for instance the root of the equation $x^4+x^5=e^6$, which is $x=\pi+0.000 000 029$. Many other far more accurate yet equally coincidental approximations are shown on this page: http://www.contestcen.com/pi.htm.

For each of these coincidences, one could be surprised and wonder: "Why is it so close? ". This is a naive question because a particular relationship is especially selected to be close to an exact value and chosen among an infinity of relationships more or less approximated.

One can find very easily as many coincidences as we want, with $\pi$ or/and with other usual constants, thanks to computer automatic search. The general principle of the method is described with examples in the paper "Mathématiques expérimentales" published on Scribd (in French): http://www.scribd.com/JJacquelin/documents.

The right question is why

$$e^\pi-\pi\approx 20-\frac{1}{1111+\frac{1}{11+\frac{1}{\sqrt{2}}}}$$

• Hmmmm.... ${}{}$ Mar 27 '18 at 10:12

As much as I wish there was some deep connection here, all (lack of) evidence points to the fact that this is nothing but mere, brilliant mathematical coincidence.

• There are actually quite some examples where some operations on transcedental numbers turn out to be extremely close to an integer. Maybe something good for a new post? Mar 24 '14 at 16:00
• @imranfat maybe a post on a list of coincidences.
– Guy
Mar 24 '14 at 16:05
• @Sabyasachi There are some that aren't coincidences, such as $e^{\pi\sqrt{163}}$ as Geoff mentions. This one is though, IMHO. Mar 24 '14 at 18:50
• @AlexBecker okay I wasn't aware of that.
– Guy
Mar 24 '14 at 18:57
• you could perhaps argue that nothing is a coincidence, and in time some weird area of number theory (perhaps alien to what we know today) will give this some better explanation than just "coincidence" Jan 4 '16 at 4:10

If you think that's good agreement, try Ramanujan's constant $e^{\pi \sqrt{163}}.$ There is a deep explanation for the proximity in that case though.

If $e^\pi-\pi\approx20$ then $e^x-x-20$ must have a root around $x=\pi$. Hence the function defined by $z=e^{f(z)}-f(z)-20$ should pass $f(0)\approx\pi$. So with the Lagrange Inversion Theorem, we can find a series representation for $f(z)$. If there's any special reason why $f(0)\approx\pi$, it would explain why $e^\pi-\pi\approx20$. We can find $f(z)$ by inverting $e^x-x-20$ at $x=3$, as follows. *

$$f(z)=3+\frac{[z-(e^3-23)]}{e^3-1}-\frac{e^3[z-(e^3-23)]^2}{(e^3-1)^3\cdot 2!}+\frac{(e^3+2e^6)[z-(e^3-23)]^3}{(e^3-1)^5\cdot 3!}\ldots$$

If we substitute $z=0$ and simplify the series, our question is equivalent to asking why: $$3+\sum_{n=1}^{+\infty}\frac{(23-e^3)^np_n(e^3)}{(e^3-1)^{2n-1}(2n-1)!}\approx\pi$$

Where $p_n(e^3)$ are polynomials in $e^3$. Indeed we see that the left hand side is approximately $3.1416$. This is expected since solving $e^x-x-20=0$ gives us $x\approx 3.141\,633\,302\,801\,037$.

Figure: $\color{red}{y=e^x-x-20}$ in red, $\color{blue}{y=x}$ in blue, $\color{purple}{y=f(x)}$ in purple and the partial sum for $\color{green}{y=f(x)}$ up to $n=3$ in green. The purple curve represents the reflection of the red curve over the line $y=x$. The purple curve crosses the $y$ axis around $(0,\pi)$, implying $e^\pi-\pi\approx20$. Geogebra link: https://www.desmos.com/calculator/nhbpehuuds

### Potential Next Steps

The coefficients of $e^{3k}$ for each $p_n(e^3)$ are shown in the table below. For example, when $n=3$, $p_3(e^3)=e^3+2e^6$.

$$\begin{array}{|c|c|c|c|c|} \hline n&\text{Coefficient of }e^3&e^6&e^9\\ \hline 1&0&0&0\\ \hline 2&-1&0&0\\ \hline 3&1&2&0\\ \hline 4&-1&-8&-6\\ \hline \end{array}$$

If you think you can see any particular pattern in the table, or would like to calculate more entries, it could poetntially lead to an explanation.

We could also attempt to compare the terms in the series to a series for $\pi$. Namely $f(0)=3+0.153-0.0123+0.00135-0.000169\ldots$. We could narrow our search to the series for $\pi$ with the same rate of convergence. I think this series has first order convergence.

* We can't invert $e^x-x-20$ around $x=0$ because the derivative is $0$ here. I tried at $x=1$ but couldn't get it to work.

Probably the simplest possible answer is in looking at

$$f(x,y)=x^y-y$$

around $$(x,y)=(3,3)$$ because both $$\pi$$ and $$e$$ are close to $$3$$

Taylor to first degree would be

$$f(3+x,3+y)=3^3-3+(y-3)(3^3\log(3)-1)+3^3(x-3)=24+(y-3)(27\log(3)-1)+27(x-3)$$

Notice that a very close expression (without $$\log(3)$$)

$$24+(y-3)(27-1)+27(x-3)=24+26(y-3)+27(x-3)$$

for rational approximations $$e=\frac{19}{7}$$ and $$\pi=\frac{22}{7}$$ is giving

$$24+(\frac{22}{7}-3)(27-1)+27(\frac{19}{7}-3)=20$$

So we are dealing with two functions that are very close and linear in the region which we are interested in, as you can see in the graph.

We want to arrive from the black dot at the blue line to the black dot at the orange line. But look, the situation is very symmetrical and quite linear so it is not surprise that we do not move too much from targeted $$20$$ when we use the intended full arguments not their rational approximations.

Let us swap the arguments to make this more obvious. Notice that both functions behave very linearly in this small space.

$$f_1(x,y)=x^y-y-20$$

$$f_2(x,y)=24+26(y-3)+27(x-3)-20$$

$$f_1(\frac{19}{7},\frac{22}{7})=(\frac{19}{7})^{\frac{22}{7}}-\frac{22}{7}-20=-0.079$$ $$f_2(\pi,e)=24+26(\pi-3)+27(e-3)-20=0.075$$

So we expect that swapping arguments will cancel the effect and keep the value intact, so we will get close to $$20$$ again, even with $$f(x,y)=x^y-y$$ and $$(x,y)=e,\pi$$

To make it totally clear create two implicit functions:

$$g_1(x,y):(\frac{19}{7}+x)^{\frac{22}{7}-y}-(\frac{22}{7}-y)=20$$

$$g_2(x,y):24+26(\pi+y-3)+27(e-x-3)=20$$

The difference between these two functions in the region we are interested in $$(e-\frac{19}{7},\frac{22}{7}-\pi)$$ is just about the precision we have in the expression which we are observing that is $$0.0001$$. As we push $$x,y$$ towards the value in $$g_2$$ that coincide with rational approximations, $$g_1$$ goes towards the intended values of $$e$$ and $$\pi$$.

Together this magic is consisting of three points:

1. Having rational approximations of $$\pi$$ and $$e$$ with a small denominator, actually the small one, $$7$$, with sufficient precision. Sure, this makes it easy to conjure up quite some integer connections, the simplest of which would be

$$\frac{e}{19}-\frac{\pi}{22}=0.0002...$$

1. Having $$\pi$$ and $$e$$ sufficiently close to $$3$$

2. A specific function $$x^y-y$$ that is comparable with another closely related linear function whose evaluation with rational approximations of $$e$$ and $$\pi$$ is an integer.

I am quite certain that just based on these principles of low but sufficiently precise rational approximations, one can invent tons of similar "surprising" examples. The choice of function is just that - a choice. The fact that $$e$$ and $$\pi$$ have the same small denominator in rational approximation might be something that would require some slightly deeper theory, but I doubt we would need much there.

Still, it is kind of a small theory, not just an incident I would say. It is just a couple of connected general properties.

Using the above system you can derive this "marvel":

$$\frac{1}{8}(e^4+\pi^4)=19.000905$$

After checking many similar examples, almost all of them follow the same pattern as long as the incigers (ha, did you see what I have done there) are relatively small.

I will show the system for $$\pi$$ but it is all the same for any other number and combination as long as the rational approximation is sufficiently good. For $$\pi$$ we set a reference to be $$3$$ but it could be any other rational number close to $$\pi$$.

Create an equation

$$a_0 + a_1(x-3)$$

where $$a_0$$ and $$a_1$$ are not extremely large, so that $$m$$ is an integer when $$x$$ is a rational approximation of $$\pi$$, $$x_{\pi}$$ like $$\frac{22}{7}$$.

$$a_0 + a_1(x_{\pi}-3)=m$$

Find a function $$f(x)$$ that is somewhat linear around $$3$$ so that

$$f(3) \approx a_0$$

and

$$f'(3) \approx a_1$$

if not equal. Then we expect $$f(\pi) \approx m$$ as well. Use this over $$x+x^2$$ and you will find not perfect but a good starter $$\pi+\pi^2=13.01...$$