Average Error: 28.9 → 0.0
Time: 20.6s
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 r40891 = N;
        double r40892 = 1.0;
        double r40893 = r40891 + r40892;
        double r40894 = log(r40893);
        double r40895 = log(r40891);
        double r40896 = r40894 - r40895;
        return r40896;
}

double f(double N) {
        double r40897 = 1.0;
        double r40898 = N;
        double r40899 = r40897 / r40898;
        double r40900 = log1p(r40899);
        double r40901 = expm1(r40900);
        double r40902 = log1p(r40901);
        return r40902;
}

Error

Bits error versus N

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 28.9

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

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

    \[\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 2019326 +o rules:numerics
(FPCore (N)
  :name "2log (problem 3.3.6)"
  :precision binary64
  (- (log (+ N 1)) (log N)))