\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\frac{\frac{1}{x}}{\frac{1}{\sqrt{x + 1}} + \frac{1}{\sqrt{x}}} \cdot \frac{1}{\frac{x + 1}{1}}double f(double x) {
double r5860288 = 1.0;
double r5860289 = x;
double r5860290 = sqrt(r5860289);
double r5860291 = r5860288 / r5860290;
double r5860292 = r5860289 + r5860288;
double r5860293 = sqrt(r5860292);
double r5860294 = r5860288 / r5860293;
double r5860295 = r5860291 - r5860294;
return r5860295;
}
double f(double x) {
double r5860296 = 1.0;
double r5860297 = x;
double r5860298 = r5860296 / r5860297;
double r5860299 = r5860297 + r5860296;
double r5860300 = sqrt(r5860299);
double r5860301 = r5860296 / r5860300;
double r5860302 = sqrt(r5860297);
double r5860303 = r5860296 / r5860302;
double r5860304 = r5860301 + r5860303;
double r5860305 = r5860298 / r5860304;
double r5860306 = r5860299 / r5860296;
double r5860307 = r5860296 / r5860306;
double r5860308 = r5860305 * r5860307;
return r5860308;
}




Bits error versus x
Results
| Original | 20.2 |
|---|---|
| Target | 0.7 |
| Herbie | 0.4 |
Initial program 20.2
rmApplied flip--20.2
rmApplied frac-times25.4
Applied frac-times20.3
Applied frac-sub20.0
Simplified19.6
Simplified19.6
Taylor expanded around 0 5.6
rmApplied *-un-lft-identity5.6
Applied times-frac5.1
Applied times-frac0.4
Simplified0.4
Final simplification0.4
herbie shell --seed 2019170
(FPCore (x)
:name "2isqrt (example 3.6)"
:herbie-target
(/ 1.0 (+ (* (+ x 1.0) (sqrt x)) (* x (sqrt (+ x 1.0)))))
(- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))