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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{N}, \sqrt[3]{{\left(1 - \frac{0.5}{N}\right)}^{\frac{3}{2}}} \cdot \sqrt[3]{{\left(1 - \frac{0.5}{N}\right)}^{\frac{3}{2}}}, \frac{0.3333333333333333148296162562473909929395}{{N}^{3}}\right)\\

\end{array}
double f(double N) {
        double r41342 = N;
        double r41343 = 1.0;
        double r41344 = r41342 + r41343;
        double r41345 = log(r41344);
        double r41346 = log(r41342);
        double r41347 = r41345 - r41346;
        return r41347;
}

double f(double N) {
        double r41348 = N;
        double r41349 = 9772.093561518632;
        bool r41350 = r41348 <= r41349;
        double r41351 = 1.0;
        double r41352 = r41348 + r41351;
        double r41353 = r41352 / r41348;
        double r41354 = log(r41353);
        double r41355 = 1.0;
        double r41356 = r41355 / r41348;
        double r41357 = 0.5;
        double r41358 = r41357 / r41348;
        double r41359 = r41351 - r41358;
        double r41360 = 1.5;
        double r41361 = pow(r41359, r41360);
        double r41362 = cbrt(r41361);
        double r41363 = r41362 * r41362;
        double r41364 = 0.3333333333333333;
        double r41365 = 3.0;
        double r41366 = pow(r41348, r41365);
        double r41367 = r41364 / r41366;
        double r41368 = fma(r41356, r41363, r41367);
        double r41369 = r41350 ? r41354 : r41368;
        return r41369;
}

Error

Bits error versus N

Derivation

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

    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)}\]

    if 9772.093561518632 < N

    1. Initial program 59.6

      \[\log \left(N + 1\right) - \log N\]
    2. Taylor expanded around inf 0.0

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{N}, 1 - \frac{0.5}{N}, \frac{0.3333333333333333148296162562473909929395}{{N}^{3}}\right)}\]
    4. Using strategy rm
    5. Applied add-cbrt-cube0.0

      \[\leadsto \mathsf{fma}\left(\frac{1}{N}, \color{blue}{\sqrt[3]{\left(\left(1 - \frac{0.5}{N}\right) \cdot \left(1 - \frac{0.5}{N}\right)\right) \cdot \left(1 - \frac{0.5}{N}\right)}}, \frac{0.3333333333333333148296162562473909929395}{{N}^{3}}\right)\]
    6. Simplified0.0

      \[\leadsto \mathsf{fma}\left(\frac{1}{N}, \sqrt[3]{\color{blue}{{\left(1 - \frac{0.5}{N}\right)}^{3}}}, \frac{0.3333333333333333148296162562473909929395}{{N}^{3}}\right)\]
    7. Using strategy rm
    8. Applied sqr-pow0.0

      \[\leadsto \mathsf{fma}\left(\frac{1}{N}, \sqrt[3]{\color{blue}{{\left(1 - \frac{0.5}{N}\right)}^{\left(\frac{3}{2}\right)} \cdot {\left(1 - \frac{0.5}{N}\right)}^{\left(\frac{3}{2}\right)}}}, \frac{0.3333333333333333148296162562473909929395}{{N}^{3}}\right)\]
    9. Applied cbrt-prod0.0

      \[\leadsto \mathsf{fma}\left(\frac{1}{N}, \color{blue}{\sqrt[3]{{\left(1 - \frac{0.5}{N}\right)}^{\left(\frac{3}{2}\right)}} \cdot \sqrt[3]{{\left(1 - \frac{0.5}{N}\right)}^{\left(\frac{3}{2}\right)}}}, \frac{0.3333333333333333148296162562473909929395}{{N}^{3}}\right)\]
    10. Simplified0.0

      \[\leadsto \mathsf{fma}\left(\frac{1}{N}, \color{blue}{\sqrt[3]{{\left(1 - \frac{0.5}{N}\right)}^{\frac{3}{2}}}} \cdot \sqrt[3]{{\left(1 - \frac{0.5}{N}\right)}^{\left(\frac{3}{2}\right)}}, \frac{0.3333333333333333148296162562473909929395}{{N}^{3}}\right)\]
    11. Simplified0.0

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

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

Reproduce

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