Average Error: 19.8 → 0.6
Time: 4.8s
Precision: binary64
\[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\]
\[\frac{1}{\sqrt{x} + x \cdot \left(\sqrt{x} + \sqrt{1 + x}\right)}\]
\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
\frac{1}{\sqrt{x} + x \cdot \left(\sqrt{x} + \sqrt{1 + x}\right)}
(FPCore (x) :precision binary64 (- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))
(FPCore (x)
 :precision binary64
 (/ 1.0 (+ (sqrt x) (* x (+ (sqrt x) (sqrt (+ 1.0 x)))))))
double code(double x) {
	return (1.0 / sqrt(x)) - (1.0 / sqrt(x + 1.0));
}
double code(double x) {
	return 1.0 / (sqrt(x) + (x * (sqrt(x) + sqrt(1.0 + x))));
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original19.8
Target0.6
Herbie0.6
\[\frac{1}{\left(x + 1\right) \cdot \sqrt{x} + x \cdot \sqrt{x + 1}}\]

Derivation

  1. Initial program 19.8

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

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

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

    \[\leadsto \frac{\sqrt{1 + x} - \sqrt{x}}{\color{blue}{\sqrt{x} \cdot \sqrt{1 + x}}}\]
  6. Using strategy rm
  7. Applied flip--_binary64_107619.7

    \[\leadsto \frac{\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. Simplified0.4

    \[\leadsto \frac{\frac{\color{blue}{1}}{\sqrt{1 + x} + \sqrt{x}}}{\sqrt{x} \cdot \sqrt{1 + x}}\]
  9. Using strategy rm
  10. Applied clear-num_binary64_11000.8

    \[\leadsto \color{blue}{\frac{1}{\frac{\sqrt{x} \cdot \sqrt{1 + x}}{\frac{1}{\sqrt{1 + x} + \sqrt{x}}}}}\]
  11. Simplified0.6

    \[\leadsto \frac{1}{\color{blue}{\left(x + 1\right) \cdot \sqrt{x} + x \cdot \sqrt{x + 1}}}\]
  12. Using strategy rm
  13. Applied clear-num_binary64_11000.6

    \[\leadsto \color{blue}{\frac{1}{\frac{\left(x + 1\right) \cdot \sqrt{x} + x \cdot \sqrt{x + 1}}{1}}}\]
  14. Simplified0.6

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

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

Reproduce

herbie shell --seed 2021011 
(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)))))