\sqrt{x + 1} - \sqrt{x}\frac{1}{\mathsf{hypot}\left(\sqrt{x}, 1\right) + \sqrt{x}}double f(double x) {
double r1881097 = x;
double r1881098 = 1.0;
double r1881099 = r1881097 + r1881098;
double r1881100 = sqrt(r1881099);
double r1881101 = sqrt(r1881097);
double r1881102 = r1881100 - r1881101;
return r1881102;
}
double f(double x) {
double r1881103 = 1.0;
double r1881104 = x;
double r1881105 = sqrt(r1881104);
double r1881106 = hypot(r1881105, r1881103);
double r1881107 = r1881106 + r1881105;
double r1881108 = r1881103 / r1881107;
return r1881108;
}




Bits error versus x
Results
| Original | 29.4 |
|---|---|
| Target | 0.2 |
| Herbie | 0.2 |
Initial program 29.4
rmApplied flip--29.2
Simplified28.8
Taylor expanded around 0 0.2
rmApplied *-un-lft-identity0.2
Applied add-sqr-sqrt0.2
Applied hypot-def0.2
Final simplification0.2
herbie shell --seed 2019153 +o rules:numerics
(FPCore (x)
:name "2sqrt (example 3.1)"
:herbie-target
(/ 1 (+ (sqrt (+ x 1)) (sqrt x)))
(- (sqrt (+ x 1)) (sqrt x)))