\sqrt{x + 1} - \sqrt{x}\frac{1 + 0}{\mathsf{fma}\left(\sqrt{\sqrt[3]{x + 1} \cdot \sqrt[3]{x + 1}}, \sqrt{\sqrt[3]{x + 1}}, \sqrt{x}\right)}double code(double x) {
return (sqrt((x + 1.0)) - sqrt(x));
}
double code(double x) {
return ((1.0 + 0.0) / fma(sqrt((cbrt((x + 1.0)) * cbrt((x + 1.0)))), sqrt(cbrt((x + 1.0))), sqrt(x)));
}




Bits error versus x
Results
| Original | 29.7 |
|---|---|
| Target | 0.2 |
| Herbie | 0.3 |
Initial program 29.7
rmApplied flip--29.5
Simplified0.2
rmApplied add-cube-cbrt0.3
Applied sqrt-prod0.3
Applied fma-def0.3
Final simplification0.3
herbie shell --seed 2020091 +o rules:numerics
(FPCore (x)
:name "2sqrt (example 3.1)"
:precision binary64
:herbie-target
(/ 1 (+ (sqrt (+ x 1)) (sqrt x)))
(- (sqrt (+ x 1)) (sqrt x)))