I created this weird problem in my head which might be trivial or rather complicated but I somehow can't figure out how to solve it:
Imagine you have a bar/line connecting the graphs of $e^x$ and $ln(x)$ at $e^0$ and $\ln(1)$ (which has the distance of $\sqrt2$ ).
And now you move that bar along the x axes without changing its slope (which is $-\sqrt2$) where it intersects the $e^x$ and $\ln(x)$ values accordingly.
How could you describe the length of that bar with a function of $x$?
Here are 4 of those graph-connecting lines and what I'm looking for is the length of any line $d(x)$
$d(x)$" />
Firstly, the slope of the line is $-1$, not $-\sqrt{2}$. Let's take $x$ to be the location of the intersection with $e^x$.
The equation of a line with slope $-1$ that passes through $(x, e^x)$ is $y' - e^x = -(x' - x)$, or $y' = x + e^x - x'$. This will intersect $\ln(x)$ when $e^{y'} = x'$. Putting this into the equation for the line, we see that the intersection is at $(e^x, x)$. We could also come to this result using the fact that $e^x$ and $\ln(x)$ are reflections over $y = x$.
The distance between these points is $\sqrt{(e^x - x)^2 + (x - e^x)^2}$, so we have $$ d(x) = \sqrt{2}(e^x - x) $$