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




Bits error versus x
Results
| Original | 29.8 |
|---|---|
| Target | 0.2 |
| Herbie | 0.2 |
Initial program 29.8
rmApplied flip--29.6
Simplified0.2
Final simplification0.2
herbie shell --seed 2020057
(FPCore (x)
:name "2sqrt (example 3.1)"
:precision binary64
:herbie-target
(/ 1 (+ (sqrt (+ x 1)) (sqrt x)))
(- (sqrt (+ x 1)) (sqrt x)))