Average Error: 20.2 → 0.4
Time: 5.3s
Precision: 64
\[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\]
\[\frac{\frac{1 \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}}}{\sqrt{x}}}{\sqrt{x + 1}}\]
\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
\frac{\frac{1 \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}}}{\sqrt{x}}}{\sqrt{x + 1}}
double code(double x) {
	return ((1.0 / sqrt(x)) - (1.0 / sqrt((x + 1.0))));
}
double code(double x) {
	return (((1.0 * (1.0 / (sqrt((x + 1.0)) + sqrt(x)))) / sqrt(x)) / sqrt((x + 1.0)));
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 20.2

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

    \[\leadsto \color{blue}{\frac{1 \cdot \sqrt{x + 1} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}}}\]
  4. Simplified20.2

    \[\leadsto \frac{\color{blue}{1 \cdot \left(\sqrt{x + 1} - \sqrt{x}\right)}}{\sqrt{x} \cdot \sqrt{x + 1}}\]
  5. Using strategy rm
  6. Applied flip--19.9

    \[\leadsto \frac{1 \cdot \color{blue}{\frac{\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{x + 1} + \sqrt{x}}}}{\sqrt{x} \cdot \sqrt{x + 1}}\]
  7. Simplified19.5

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

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

    \[\leadsto \color{blue}{\frac{\frac{1 \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}}}{\sqrt{x}}}{\sqrt{x + 1}}}\]
  11. Final simplification0.4

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

Reproduce

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

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

  (- (/ 1 (sqrt x)) (/ 1 (sqrt (+ x 1)))))