Average Error: 20.6 → 0.3
Time: 4.1s
Precision: binary64
\[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\]
\[\frac{\frac{1 \cdot 1}{x + \sqrt{x} \cdot \sqrt{1 + x}}}{\sqrt{1 + x}}\]
\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
\frac{\frac{1 \cdot 1}{x + \sqrt{x} \cdot \sqrt{1 + x}}}{\sqrt{1 + x}}
(FPCore (x) :precision binary64 (- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))
(FPCore (x)
 :precision binary64
 (/ (/ (* 1.0 1.0) (+ x (* (sqrt x) (sqrt (+ 1.0 x))))) (sqrt (+ 1.0 x))))
double code(double x) {
	return ((double) ((1.0 / ((double) sqrt(x))) - (1.0 / ((double) sqrt(((double) (x + 1.0)))))));
}
double code(double x) {
	return ((((double) (1.0 * 1.0)) / ((double) (x + ((double) (((double) sqrt(x)) * ((double) sqrt(((double) (1.0 + x))))))))) / ((double) sqrt(((double) (1.0 + x)))));
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original20.6
Target0.7
Herbie0.3
\[\frac{1}{\left(x + 1\right) \cdot \sqrt{x} + x \cdot \sqrt{x + 1}}\]

Derivation

  1. Initial program Error: 20.6 bits

    \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\]
  2. Using strategy rm
  3. Applied frac-subError: 20.6 bits

    \[\leadsto \color{blue}{\frac{1 \cdot \sqrt{x + 1} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}}}\]
  4. SimplifiedError: 20.6 bits

    \[\leadsto \frac{\color{blue}{1 \cdot \left(\sqrt{1 + x} - \sqrt{x}\right)}}{\sqrt{x} \cdot \sqrt{x + 1}}\]
  5. SimplifiedError: 20.6 bits

    \[\leadsto \frac{1 \cdot \left(\sqrt{1 + x} - \sqrt{x}\right)}{\color{blue}{\sqrt{x} \cdot \sqrt{1 + x}}}\]
  6. Using strategy rm
  7. Applied flip--Error: 20.3 bits

    \[\leadsto \frac{1 \cdot \color{blue}{\frac{\sqrt{1 + x} \cdot \sqrt{1 + x} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{1 + x} + \sqrt{x}}}}{\sqrt{x} \cdot \sqrt{1 + x}}\]
  8. SimplifiedError: 0.4 bits

    \[\leadsto \frac{1 \cdot \frac{\color{blue}{1 + 0}}{\sqrt{1 + x} + \sqrt{x}}}{\sqrt{x} \cdot \sqrt{1 + x}}\]
  9. Using strategy rm
  10. Applied associate-/r*Error: 0.4 bits

    \[\leadsto \color{blue}{\frac{\frac{1 \cdot \frac{1 + 0}{\sqrt{1 + x} + \sqrt{x}}}{\sqrt{x}}}{\sqrt{1 + x}}}\]
  11. SimplifiedError: 0.3 bits

    \[\leadsto \frac{\color{blue}{\frac{1 \cdot 1}{x + \sqrt{x} \cdot \sqrt{x + 1}}}}{\sqrt{1 + x}}\]
  12. Final simplificationError: 0.3 bits

    \[\leadsto \frac{\frac{1 \cdot 1}{x + \sqrt{x} \cdot \sqrt{1 + x}}}{\sqrt{1 + x}}\]

Reproduce

herbie shell --seed 2020204 
(FPCore (x)
  :name "2isqrt (example 3.6)"
  :precision binary64

  :herbie-target
  (/ 1.0 (+ (* (+ x 1.0) (sqrt x)) (* x (sqrt (+ x 1.0)))))

  (- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))