\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x + 1} \cdot \sqrt{x} + \left(x + 1\right)}double code(double x) {
return ((1.0 / sqrt(x)) - (1.0 / sqrt((x + 1.0))));
}
double code(double x) {
return ((1.0 / sqrt(x)) * (1.0 / ((sqrt((x + 1.0)) * sqrt(x)) + (x + 1.0))));
}




Bits error versus x
Results
| Original | 19.5 |
|---|---|
| Target | 0.6 |
| Herbie | 0.3 |
Initial program 19.5
rmApplied frac-sub19.5
Simplified19.5
rmApplied flip--19.3
Simplified18.9
Taylor expanded around 0 0.4
rmApplied times-frac0.4
Simplified0.3
Final simplification0.3
herbie shell --seed 2020092
(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)))))