Average Error: 28.6 → 0.0
Time: 10.6s
Precision: 64
\[\log \left(N + 1\right) - \log N\]
\[\mathsf{log1p}\left(\left(\frac{1}{N}\right)\right)\]
\log \left(N + 1\right) - \log N
\mathsf{log1p}\left(\left(\frac{1}{N}\right)\right)
double f(double N) {
        double r1356657 = N;
        double r1356658 = 1.0;
        double r1356659 = r1356657 + r1356658;
        double r1356660 = log(r1356659);
        double r1356661 = log(r1356657);
        double r1356662 = r1356660 - r1356661;
        return r1356662;
}

double f(double N) {
        double r1356663 = 1.0;
        double r1356664 = N;
        double r1356665 = r1356663 / r1356664;
        double r1356666 = log1p(r1356665);
        return r1356666;
}

Error

Bits error versus N

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 28.6

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

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

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

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

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

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

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

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

Reproduce

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