Average Error: 29.1 → 0.0
Time: 16.0s
Precision: 64
\[\log \left(N + 1\right) - \log N\]
\[\mathsf{log1p}\left(\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{N}\right)\right)\right)\]
\log \left(N + 1\right) - \log N
\mathsf{log1p}\left(\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{N}\right)\right)\right)
double f(double N) {
        double r36687 = N;
        double r36688 = 1.0;
        double r36689 = r36687 + r36688;
        double r36690 = log(r36689);
        double r36691 = log(r36687);
        double r36692 = r36690 - r36691;
        return r36692;
}

double f(double N) {
        double r36693 = 1.0;
        double r36694 = N;
        double r36695 = r36693 / r36694;
        double r36696 = log1p(r36695);
        double r36697 = expm1(r36696);
        double r36698 = log1p(r36697);
        return r36698;
}

Error

Bits error versus N

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 29.1

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

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

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

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

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

Reproduce

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