Average Error: 28.9 → 0.0
Time: 18.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 r38168 = N;
        double r38169 = 1.0;
        double r38170 = r38168 + r38169;
        double r38171 = log(r38170);
        double r38172 = log(r38168);
        double r38173 = r38171 - r38172;
        return r38173;
}

double f(double N) {
        double r38174 = 1.0;
        double r38175 = N;
        double r38176 = r38174 / r38175;
        double r38177 = log1p(r38176);
        return r38177;
}

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 pow128.8

    \[\leadsto \log \color{blue}{\left({\left(\frac{N + 1}{N}\right)}^{1}\right)}\]
  6. Applied log-pow28.8

    \[\leadsto \color{blue}{1 \cdot \log \left(\frac{N + 1}{N}\right)}\]
  7. Simplified0.0

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

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

Reproduce

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