Average Error: 14.4 → 0.1
Time: 3.5s
Precision: 64
\[\frac{1}{x + 1} - \frac{1}{x}\]
\[\frac{\frac{1}{\frac{x + 1}{0 - 1}}}{x}\]
\frac{1}{x + 1} - \frac{1}{x}
\frac{\frac{1}{\frac{x + 1}{0 - 1}}}{x}
double code(double x) {
	return ((1.0 / (x + 1.0)) - (1.0 / x));
}
double code(double x) {
	return ((1.0 / ((x + 1.0) / (0.0 - 1.0))) / x);
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 14.4

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

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

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

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

    \[\leadsto \frac{\color{blue}{\frac{1}{\frac{x + 1}{0 - 1}}}}{x}\]
  8. Final simplification0.1

    \[\leadsto \frac{\frac{1}{\frac{x + 1}{0 - 1}}}{x}\]

Reproduce

herbie shell --seed 2020106 +o rules:numerics
(FPCore (x)
  :name "2frac (problem 3.3.1)"
  :precision binary64
  (- (/ 1 (+ x 1)) (/ 1 x)))