\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\begin{array}{l}
\mathbf{if}\;x \le 11789.29797293433:\\
\;\;\;\;{x}^{\frac{-1}{2}} - {\left(1 + x\right)}^{\frac{-1}{2}}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\frac{5}{16}}{x \cdot x}, \frac{e^{\log x \cdot \frac{-1}{2}}}{x}, \mathsf{fma}\left(\frac{1}{2}, \frac{e^{\log x \cdot \frac{-1}{2}}}{x}, \frac{-3}{8} \cdot \frac{e^{\log x \cdot \frac{-1}{2}}}{x \cdot x}\right)\right)\\
\end{array}double f(double x) {
double r2221106 = 1.0;
double r2221107 = x;
double r2221108 = sqrt(r2221107);
double r2221109 = r2221106 / r2221108;
double r2221110 = r2221107 + r2221106;
double r2221111 = sqrt(r2221110);
double r2221112 = r2221106 / r2221111;
double r2221113 = r2221109 - r2221112;
return r2221113;
}
double f(double x) {
double r2221114 = x;
double r2221115 = 11789.29797293433;
bool r2221116 = r2221114 <= r2221115;
double r2221117 = -0.5;
double r2221118 = pow(r2221114, r2221117);
double r2221119 = 1.0;
double r2221120 = r2221119 + r2221114;
double r2221121 = pow(r2221120, r2221117);
double r2221122 = r2221118 - r2221121;
double r2221123 = 0.3125;
double r2221124 = r2221114 * r2221114;
double r2221125 = r2221123 / r2221124;
double r2221126 = log(r2221114);
double r2221127 = r2221126 * r2221117;
double r2221128 = exp(r2221127);
double r2221129 = r2221128 / r2221114;
double r2221130 = 0.5;
double r2221131 = -0.375;
double r2221132 = r2221128 / r2221124;
double r2221133 = r2221131 * r2221132;
double r2221134 = fma(r2221130, r2221129, r2221133);
double r2221135 = fma(r2221125, r2221129, r2221134);
double r2221136 = r2221116 ? r2221122 : r2221135;
return r2221136;
}




Bits error versus x
| Original | 19.9 |
|---|---|
| Target | 0.7 |
| Herbie | 1.5 |
if x < 11789.29797293433Initial program 0.4
rmApplied pow10.4
Applied sqrt-pow10.4
Applied pow-flip0.1
Simplified0.1
rmApplied pow10.1
Applied sqrt-pow10.1
Applied pow-flip0.1
Simplified0.1
if 11789.29797293433 < x Initial program 39.6
rmApplied pow139.6
Applied sqrt-pow139.6
Applied pow-flip44.6
Simplified44.6
rmApplied pow144.6
Applied sqrt-pow144.6
Applied pow-flip39.6
Simplified39.6
Taylor expanded around -inf 62.7
Simplified2.8
Final simplification1.5
herbie shell --seed 2019152 +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)))))