Average Error: 29.6 → 0.1
Time: 13.0s
Precision: 64
\[\log \left(N + 1\right) - \log N\]
\[\begin{array}{l} \mathbf{if}\;N \le 4847.936709915299:\\ \;\;\;\;\log \left(\frac{\sqrt{1 + N}}{N}\right) + \log \left(\sqrt{1 + N}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\left(\frac{\frac{1}{N}}{N}\right), \left(\frac{\frac{1}{3}}{N} + \frac{-1}{2}\right), \left(\frac{1}{N}\right)\right)\\ \end{array}\]
\log \left(N + 1\right) - \log N
\begin{array}{l}
\mathbf{if}\;N \le 4847.936709915299:\\
\;\;\;\;\log \left(\frac{\sqrt{1 + N}}{N}\right) + \log \left(\sqrt{1 + N}\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(\frac{\frac{1}{N}}{N}\right), \left(\frac{\frac{1}{3}}{N} + \frac{-1}{2}\right), \left(\frac{1}{N}\right)\right)\\

\end{array}
double f(double N) {
        double r1337633 = N;
        double r1337634 = 1.0;
        double r1337635 = r1337633 + r1337634;
        double r1337636 = log(r1337635);
        double r1337637 = log(r1337633);
        double r1337638 = r1337636 - r1337637;
        return r1337638;
}

double f(double N) {
        double r1337639 = N;
        double r1337640 = 4847.936709915299;
        bool r1337641 = r1337639 <= r1337640;
        double r1337642 = 1.0;
        double r1337643 = r1337642 + r1337639;
        double r1337644 = sqrt(r1337643);
        double r1337645 = r1337644 / r1337639;
        double r1337646 = log(r1337645);
        double r1337647 = log(r1337644);
        double r1337648 = r1337646 + r1337647;
        double r1337649 = r1337642 / r1337639;
        double r1337650 = r1337649 / r1337639;
        double r1337651 = 0.3333333333333333;
        double r1337652 = r1337651 / r1337639;
        double r1337653 = -0.5;
        double r1337654 = r1337652 + r1337653;
        double r1337655 = fma(r1337650, r1337654, r1337649);
        double r1337656 = r1337641 ? r1337648 : r1337655;
        return r1337656;
}

Error

Bits error versus N

Derivation

  1. Split input into 2 regimes
  2. if N < 4847.936709915299

    1. Initial program 0.1

      \[\log \left(N + 1\right) - \log N\]
    2. Simplified0.1

      \[\leadsto \color{blue}{\mathsf{log1p}\left(N\right) - \log N}\]
    3. Using strategy rm
    4. Applied log1p-udef0.1

      \[\leadsto \color{blue}{\log \left(1 + N\right)} - \log N\]
    5. Applied diff-log0.1

      \[\leadsto \color{blue}{\log \left(\frac{1 + N}{N}\right)}\]
    6. Using strategy rm
    7. Applied *-un-lft-identity0.1

      \[\leadsto \log \left(\frac{1 + N}{\color{blue}{1 \cdot N}}\right)\]
    8. Applied add-sqr-sqrt0.1

      \[\leadsto \log \left(\frac{\color{blue}{\sqrt{1 + N} \cdot \sqrt{1 + N}}}{1 \cdot N}\right)\]
    9. Applied times-frac0.1

      \[\leadsto \log \color{blue}{\left(\frac{\sqrt{1 + N}}{1} \cdot \frac{\sqrt{1 + N}}{N}\right)}\]
    10. Applied log-prod0.1

      \[\leadsto \color{blue}{\log \left(\frac{\sqrt{1 + N}}{1}\right) + \log \left(\frac{\sqrt{1 + N}}{N}\right)}\]

    if 4847.936709915299 < N

    1. Initial program 59.3

      \[\log \left(N + 1\right) - \log N\]
    2. Simplified59.3

      \[\leadsto \color{blue}{\mathsf{log1p}\left(N\right) - \log N}\]
    3. Taylor expanded around -inf 0.0

      \[\leadsto \color{blue}{\left(\frac{1}{3} \cdot \frac{1}{{N}^{3}} + \frac{1}{N}\right) - \frac{1}{2} \cdot \frac{1}{{N}^{2}}}\]
    4. Simplified0.0

      \[\leadsto \color{blue}{\mathsf{fma}\left(\left(\frac{\frac{1}{N}}{N}\right), \left(\frac{\frac{1}{3}}{N} + \frac{-1}{2}\right), \left(\frac{1}{N}\right)\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;N \le 4847.936709915299:\\ \;\;\;\;\log \left(\frac{\sqrt{1 + N}}{N}\right) + \log \left(\sqrt{1 + N}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\left(\frac{\frac{1}{N}}{N}\right), \left(\frac{\frac{1}{3}}{N} + \frac{-1}{2}\right), \left(\frac{1}{N}\right)\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019133 +o rules:numerics
(FPCore (N)
  :name "2log (problem 3.3.6)"
  (- (log (+ N 1)) (log N)))