This question is inspired by the fact that decent mathematical libraries in programming languages compute sine of double precision approximation of $\pi$ correctly to the last bit (example is in Julia):
> sin(Float64(π))
1.2246467991473532e-16
As a fun fact, it can be used to extract $\pi$ to quadruple precision using double precision sine function.
I was wondering, can we easily implement function $\ln(x) - 1$ that would yield correct values for $x \approx e$? By "easily" I mean without explicitly specifying $e$ to quadruple precision, preferably by just cleverly using available functions from standard double precision math libraries.
Straightforwardly calculating $\ln(x) - 1$ of double precision approximation of $e$ yields $0.0$:
> log(Float64(ℯ)) - 1
0.0
while the actual value is
> log(BigFloat(Float64(ℯ))) - 1
-5.318237706605891370519835446436883266985903310522696816605415323809030383416923e-17
Clarification I would like to clarify that the idea is not to explicitly use calculations beyond double machine precision. The trick is not to have a series expansion of the function near $x \approx e$ and expand it in terms of $x - e$, the hard part is computing $x - e$ within the double precision arithmetic if $x$ is already approximately $e$ to double precision.
For comparison, if $x = 3.141592653589793$ (actually, its binary approximation, that's important) then we can compute $x - \pi$ as $x - \pi \approx - \sin x$ and standard math library function will give us the correct result, all $\sim 17$ digits. I wondered, can we get the same with $e$ without explicitly going beyond double precision, computing $\ln(x) - 1$ is an equivalent task. Answers of emacs drives me nuts and Somos do explictly use beyond double precision calculation of $x - e$.
What you can try is expanding the Mercator series of $\ln$. Let $x\approx e$, say $x = e+\Delta x$ with $|\Delta x|\ll 1$:
$$\begin{align} \ln x - 1 = \ln\left(1+\frac{\Delta x}e\right) &= \sum_{k=1}^\infty (-1)^{n+1}\frac{\Delta x^n}{ne^n} \\ &= \frac{\Delta x}{e} - \frac{\Delta x^2}{2e^2} +\frac{\Delta x^3}{3e^3} \mp\cdots \end{align}$$ $\def\artanh{\operatorname{artanh}}$
You might get faster convergence using $\artanh$:
$$\begin{align} \ln x - 1 &= 2\artanh\frac{\Delta x}{2e+\Delta x} \\ &= 2\xi + \frac23\xi^3+\frac25\xi^5+\frac27\xi^7+\cdots \\ &= 2\xi \left(1 + \xi^2\left(\frac13 + \xi^2\left(\frac15+\xi^2\left(\frac17 + \cdots \right)\right)\right)\right)\tag 2\\ \end{align}$$ with $\xi=\Delta x/(2e+\Delta x)$. As indicated by the last line, evaluation is performed using the Horner scheme. Start with the highest power $n$ of $\xi$ such that $$n > 1+\frac{53\ln 2}{1+\ln 2 - \ln \Delta x}$$
For example, if $\Delta x = 10^{-8}$, then $n> 2.82$. The next-greater odd number is $n=3$ so that 2 terms of $(2)$ are enough to achieve IEEE-754 double precision.