\sqrt{x + 1} - \sqrt{x}\frac{\frac{1 + 0}{\sqrt{\sqrt{x + 1} + \sqrt{x}}}}{\sqrt{\sqrt{x + 1} + \sqrt{x}}}double code(double x) {
return (sqrt((x + 1.0)) - sqrt(x));
}
double code(double x) {
return (((1.0 + 0.0) / sqrt((sqrt((x + 1.0)) + sqrt(x)))) / sqrt((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
Applied associate-/r*0.3
Final simplification0.3
herbie shell --seed 2020092 +o rules:numerics
(FPCore (x)
:name "Main:bigenough3 from C"
:precision binary64
:herbie-target
(/ 1 (+ (sqrt (+ x 1)) (sqrt x)))
(- (sqrt (+ x 1)) (sqrt x)))