Average Error: 29.9 → 0.0
Time: 8.8s
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 r2958660 = N;
        double r2958661 = 1.0;
        double r2958662 = r2958660 + r2958661;
        double r2958663 = log(r2958662);
        double r2958664 = log(r2958660);
        double r2958665 = r2958663 - r2958664;
        return r2958665;
}

double f(double N) {
        double r2958666 = 1.0;
        double r2958667 = N;
        double r2958668 = r2958666 / r2958667;
        double r2958669 = log1p(r2958668);
        return r2958669;
}

Error

Bits error versus N

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 29.9

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

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

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

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

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