TITLE: Why is $e^\pi - \pi$ so close to $20$?
QUESTION [46 upvotes]: $e^\pi-\pi\approx 19.99909998$
Why is this so close to $20$?

REPLY [2 votes]: 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:

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...$$

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

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$$
Add-on:
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...$