\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\frac{1}{\mathsf{fma}\left(\left(x + 1\right), \left(\sqrt{x}\right), \left(x \cdot \sqrt{x + 1}\right)\right)}double f(double x) {
double r11009495 = 1.0;
double r11009496 = x;
double r11009497 = sqrt(r11009496);
double r11009498 = r11009495 / r11009497;
double r11009499 = r11009496 + r11009495;
double r11009500 = sqrt(r11009499);
double r11009501 = r11009495 / r11009500;
double r11009502 = r11009498 - r11009501;
return r11009502;
}
double f(double x) {
double r11009503 = 1.0;
double r11009504 = x;
double r11009505 = r11009504 + r11009503;
double r11009506 = sqrt(r11009504);
double r11009507 = sqrt(r11009505);
double r11009508 = r11009504 * r11009507;
double r11009509 = fma(r11009505, r11009506, r11009508);
double r11009510 = r11009503 / r11009509;
return r11009510;
}




Bits error versus x
| Original | 19.8 |
|---|---|
| Target | 0.6 |
| Herbie | 0.6 |
Initial program 19.8
rmApplied frac-sub19.8
Simplified19.8
rmApplied flip--19.6
Applied associate-/l/19.6
Simplified0.8
rmApplied pow10.8
Applied pow10.8
Applied pow10.8
Applied pow-prod-down0.8
Applied pow-prod-down0.8
Simplified0.6
rmApplied *-un-lft-identity0.6
Applied add-sqr-sqrt0.6
Applied times-frac0.6
Simplified0.6
Simplified0.6
Final simplification0.6
herbie shell --seed 2019121 +o rules:numerics
(FPCore (x)
:name "2isqrt (example 3.6)"
:herbie-target
(/ 1 (+ (* (+ x 1) (sqrt x)) (* x (sqrt (+ x 1)))))
(- (/ 1 (sqrt x)) (/ 1 (sqrt (+ x 1)))))