Average Error: 28.8 → 0.0
Time: 17.2s
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 r36065 = N;
        double r36066 = 1.0;
        double r36067 = r36065 + r36066;
        double r36068 = log(r36067);
        double r36069 = log(r36065);
        double r36070 = r36068 - r36069;
        return r36070;
}

double f(double N) {
        double r36071 = 1.0;
        double r36072 = N;
        double r36073 = r36071 / r36072;
        double r36074 = log1p(r36073);
        double r36075 = expm1(r36074);
        double r36076 = log1p(r36075);
        return r36076;
}

Error

Bits error versus N

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 28.8

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

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

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