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




Bits error versus x
Results
| Original | 29.4 |
|---|---|
| Target | 0.2 |
| Herbie | 0.3 |
Initial program 29.4
rmApplied flip--29.2
Simplified0.2
rmApplied add-sqr-sqrt0.3
Final simplification0.3
herbie shell --seed 2020092
(FPCore (x)
:name "2sqrt (example 3.1)"
:precision binary64
:herbie-target
(/ 1 (+ (sqrt (+ x 1)) (sqrt x)))
(- (sqrt (+ x 1)) (sqrt x)))