\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\frac{1 \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}}}{\left(\sqrt{x} \cdot \left(\sqrt[3]{\sqrt{x + 1}} \cdot \sqrt[3]{\sqrt{x + 1}}\right)\right) \cdot \sqrt[3]{\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) * (cbrt(sqrt((x + 1.0))) * cbrt(sqrt((x + 1.0))))) * cbrt(sqrt((x + 1.0)))));
}




Bits error versus x
Results
| Original | 20.2 |
|---|---|
| Target | 0.7 |
| Herbie | 0.6 |
Initial program 20.2
rmApplied frac-sub20.2
Simplified20.2
rmApplied flip--19.9
Simplified19.5
Taylor expanded around 0 0.4
rmApplied add-cube-cbrt0.6
Applied associate-*r*0.6
Final simplification0.6
herbie shell --seed 2020060
(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)))))