Average Error: 29.6 → 0.0
Time: 22.2s
Precision: 64
\[\log \left(N + 1\right) - \log N\]
\[\mathsf{log1p}\left(\frac{1}{N}\right)\]
\log \left(N + 1\right) - \log N
\mathsf{log1p}\left(\frac{1}{N}\right)
double f(double N) {
        double r2582015 = N;
        double r2582016 = 1.0;
        double r2582017 = r2582015 + r2582016;
        double r2582018 = log(r2582017);
        double r2582019 = log(r2582015);
        double r2582020 = r2582018 - r2582019;
        return r2582020;
}

double f(double N) {
        double r2582021 = 1.0;
        double r2582022 = N;
        double r2582023 = r2582021 / r2582022;
        double r2582024 = log1p(r2582023);
        return r2582024;
}

Error

Bits error versus N

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 29.6

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

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

    \[\leadsto \log \color{blue}{\left(1 \cdot \frac{1}{N} + 1\right)}\]
  5. Simplified29.5

    \[\leadsto \log \color{blue}{\left(\frac{1}{N} + 1\right)}\]
  6. Using strategy rm
  7. Applied log1p-expm1-u29.5

    \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\log \left(\frac{1}{N} + 1\right)\right)\right)}\]
  8. Simplified0.0

    \[\leadsto \mathsf{log1p}\left(\color{blue}{\frac{1}{N}}\right)\]
  9. Final simplification0.0

    \[\leadsto \mathsf{log1p}\left(\frac{1}{N}\right)\]

Reproduce

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