Average Error: 14.7 → 0.1
Time: 11.7s
Precision: 64
\[\frac{1}{x + 1} - \frac{1}{x}\]
\[\frac{\frac{1 \cdot \left(-1\right)}{x + 1}}{x}\]
\frac{1}{x + 1} - \frac{1}{x}
\frac{\frac{1 \cdot \left(-1\right)}{x + 1}}{x}
double f(double x) {
        double r2895539 = 1.0;
        double r2895540 = x;
        double r2895541 = r2895540 + r2895539;
        double r2895542 = r2895539 / r2895541;
        double r2895543 = r2895539 / r2895540;
        double r2895544 = r2895542 - r2895543;
        return r2895544;
}

double f(double x) {
        double r2895545 = 1.0;
        double r2895546 = -r2895545;
        double r2895547 = r2895545 * r2895546;
        double r2895548 = x;
        double r2895549 = r2895548 + r2895545;
        double r2895550 = r2895547 / r2895549;
        double r2895551 = r2895550 / r2895548;
        return r2895551;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 14.7

    \[\frac{1}{x + 1} - \frac{1}{x}\]
  2. Using strategy rm
  3. Applied frac-sub14.1

    \[\leadsto \color{blue}{\frac{1 \cdot x - \left(x + 1\right) \cdot 1}{\left(x + 1\right) \cdot x}}\]
  4. Simplified14.1

    \[\leadsto \frac{\color{blue}{1 \cdot \left(x - \left(x + 1\right)\right)}}{\left(x + 1\right) \cdot x}\]
  5. Taylor expanded around 0 0.3

    \[\leadsto \frac{1 \cdot \color{blue}{\left(-1\right)}}{\left(x + 1\right) \cdot x}\]
  6. Using strategy rm
  7. Applied associate-/r*0.1

    \[\leadsto \color{blue}{\frac{\frac{1 \cdot \left(-1\right)}{x + 1}}{x}}\]
  8. Final simplification0.1

    \[\leadsto \frac{\frac{1 \cdot \left(-1\right)}{x + 1}}{x}\]

Reproduce

herbie shell --seed 2019172 +o rules:numerics
(FPCore (x)
  :name "2frac (problem 3.3.1)"
  (- (/ 1.0 (+ x 1.0)) (/ 1.0 x)))