\log \left(N + 1\right) - \log N
\begin{array}{l}
\mathbf{if}\;\log \left(N + 1\right) - \log N \leq 8.861960054673546 \cdot 10^{-10}:\\
\;\;\;\;\frac{1 - \frac{0.5}{N}}{N}\\
\mathbf{else}:\\
\;\;\;\;\log \left(\frac{N + 1}{N}\right)\\
\end{array}
(FPCore (N) :precision binary64 (- (log (+ N 1.0)) (log N)))
(FPCore (N) :precision binary64 (if (<= (- (log (+ N 1.0)) (log N)) 8.861960054673546e-10) (/ (- 1.0 (/ 0.5 N)) N) (log (/ (+ N 1.0) N))))
double code(double N) {
return log((N + 1.0)) - log(N);
}
double code(double N) {
double tmp;
if ((log((N + 1.0)) - log(N)) <= 8.861960054673546e-10) {
tmp = (1.0 - (0.5 / N)) / N;
} else {
tmp = log(((N + 1.0) / N));
}
return tmp;
}



Bits error versus N
Results
if (-.f64 (log.f64 (+.f64 N 1)) (log.f64 N)) < 8.8619601e-10Initial program 60.1
Taylor expanded in N around inf 0.0
Simplified0.0
Applied egg-rr0.0
if 8.8619601e-10 < (-.f64 (log.f64 (+.f64 N 1)) (log.f64 N)) Initial program 0.5
Applied egg-rr0.4
Final simplification0.2
herbie shell --seed 2022130
(FPCore (N)
:name "2log (problem 3.3.6)"
:precision binary64
(- (log (+ N 1.0)) (log N)))