Average Error: 29.1 → 0.1
Time: 4.0s
Precision: 64
\[\log \left(N + 1\right) - \log N\]
\[\begin{array}{l} \mathbf{if}\;N \le 6058.78819213588122:\\ \;\;\;\;\log \left(\sqrt{N + 1}\right) + \log \left(\frac{\sqrt{N + 1}}{N}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{N}, 1 - \frac{0.5}{N}, \frac{0.333333333333333315}{{N}^{3}}\right)\\ \end{array}\]
\log \left(N + 1\right) - \log N
\begin{array}{l}
\mathbf{if}\;N \le 6058.78819213588122:\\
\;\;\;\;\log \left(\sqrt{N + 1}\right) + \log \left(\frac{\sqrt{N + 1}}{N}\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{N}, 1 - \frac{0.5}{N}, \frac{0.333333333333333315}{{N}^{3}}\right)\\

\end{array}
double f(double N) {
        double r105097 = N;
        double r105098 = 1.0;
        double r105099 = r105097 + r105098;
        double r105100 = log(r105099);
        double r105101 = log(r105097);
        double r105102 = r105100 - r105101;
        return r105102;
}

double f(double N) {
        double r105103 = N;
        double r105104 = 6058.788192135881;
        bool r105105 = r105103 <= r105104;
        double r105106 = 1.0;
        double r105107 = r105103 + r105106;
        double r105108 = sqrt(r105107);
        double r105109 = log(r105108);
        double r105110 = r105108 / r105103;
        double r105111 = log(r105110);
        double r105112 = r105109 + r105111;
        double r105113 = 1.0;
        double r105114 = r105113 / r105103;
        double r105115 = 0.5;
        double r105116 = r105115 / r105103;
        double r105117 = r105106 - r105116;
        double r105118 = 0.3333333333333333;
        double r105119 = 3.0;
        double r105120 = pow(r105103, r105119);
        double r105121 = r105118 / r105120;
        double r105122 = fma(r105114, r105117, r105121);
        double r105123 = r105105 ? r105112 : r105122;
        return r105123;
}

Error

Bits error versus N

Derivation

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

    1. Initial program 0.1

      \[\log \left(N + 1\right) - \log N\]
    2. Using strategy rm
    3. Applied diff-log0.1

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

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

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

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

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

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

    if 6058.788192135881 < N

    1. Initial program 59.5

      \[\log \left(N + 1\right) - \log N\]
    2. Using strategy rm
    3. Applied diff-log59.3

      \[\leadsto \color{blue}{\log \left(\frac{N + 1}{N}\right)}\]
    4. Taylor expanded around inf 0.1

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

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

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

Reproduce

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