Average Error: 14.9 → 0.1
Time: 2.4s
Precision: binary64
\[\frac{1}{x + 1} - \frac{1}{x} \]
\[\frac{\frac{-1}{x}}{x + 1} \]
\frac{1}{x + 1} - \frac{1}{x}
\frac{\frac{-1}{x}}{x + 1}
(FPCore (x) :precision binary64 (- (/ 1.0 (+ x 1.0)) (/ 1.0 x)))
(FPCore (x) :precision binary64 (/ (/ -1.0 x) (+ x 1.0)))
double code(double x) {
	return (1.0 / (x + 1.0)) - (1.0 / x);
}
double code(double x) {
	return (-1.0 / x) / (x + 1.0);
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 14.9

    \[\frac{1}{x + 1} - \frac{1}{x} \]
  2. Applied egg-rr14.3

    \[\leadsto \color{blue}{\frac{x - \left(1 + x\right)}{x \cdot \left(1 + x\right)}} \]
  3. Applied egg-rr14.3

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

    \[\leadsto \frac{\frac{\color{blue}{-1}}{x}}{1 - x \cdot x} \cdot \left(1 - x\right) \]
  5. Applied egg-rr0.1

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

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

Reproduce

herbie shell --seed 2022130 
(FPCore (x)
  :name "2frac (problem 3.3.1)"
  :precision binary64
  (- (/ 1.0 (+ x 1.0)) (/ 1.0 x)))