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




Bits error versus x
Results
| Original | 19.6 |
|---|---|
| Target | 0.7 |
| Herbie | 0.5 |
Initial program 19.6
rmApplied frac-sub19.5
Simplified19.5
rmApplied flip--19.3
Simplified18.9
Taylor expanded around 0 0.4
rmApplied add-cube-cbrt0.5
Applied sqrt-prod0.5
Applied associate-*r*0.5
Simplified0.5
Final simplification0.5
herbie shell --seed 2020079 +o rules:numerics
(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)))))