\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\begin{array}{l}
\mathbf{if}\;x \le 6705.611752539598:\\
\;\;\;\;\mathsf{fma}\left(\frac{-1}{\sqrt[3]{\sqrt{1 + x}}}, \frac{1}{\sqrt[3]{\sqrt{1 + x}} \cdot \sqrt[3]{\sqrt{1 + x}}}, \frac{1}{\sqrt[3]{\sqrt{1 + x}} \cdot \sqrt[3]{\sqrt{1 + x}}} \cdot \frac{1}{\sqrt[3]{\sqrt{1 + x}}}\right) + \mathsf{fma}\left(1, {x}^{\frac{-1}{2}}, \frac{1}{\sqrt[3]{\sqrt{1 + x}} \cdot \sqrt[3]{\sqrt{1 + x}}} \cdot \frac{-1}{\sqrt[3]{\sqrt{1 + x}}}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{e^{\log x \cdot \frac{-1}{2}}}{x}, \frac{1}{2}, \left(\frac{\frac{5}{16}}{x} - \frac{3}{8}\right) \cdot \frac{e^{\log x \cdot \frac{-1}{2}}}{x \cdot x}\right)\\
\end{array}double f(double x) {
double r4871215 = 1.0;
double r4871216 = x;
double r4871217 = sqrt(r4871216);
double r4871218 = r4871215 / r4871217;
double r4871219 = r4871216 + r4871215;
double r4871220 = sqrt(r4871219);
double r4871221 = r4871215 / r4871220;
double r4871222 = r4871218 - r4871221;
return r4871222;
}
double f(double x) {
double r4871223 = x;
double r4871224 = 6705.611752539598;
bool r4871225 = r4871223 <= r4871224;
double r4871226 = -1.0;
double r4871227 = 1.0;
double r4871228 = r4871227 + r4871223;
double r4871229 = sqrt(r4871228);
double r4871230 = cbrt(r4871229);
double r4871231 = r4871226 / r4871230;
double r4871232 = r4871230 * r4871230;
double r4871233 = r4871227 / r4871232;
double r4871234 = r4871227 / r4871230;
double r4871235 = r4871233 * r4871234;
double r4871236 = fma(r4871231, r4871233, r4871235);
double r4871237 = -0.5;
double r4871238 = pow(r4871223, r4871237);
double r4871239 = r4871233 * r4871231;
double r4871240 = fma(r4871227, r4871238, r4871239);
double r4871241 = r4871236 + r4871240;
double r4871242 = log(r4871223);
double r4871243 = r4871242 * r4871237;
double r4871244 = exp(r4871243);
double r4871245 = r4871244 / r4871223;
double r4871246 = 0.5;
double r4871247 = 0.3125;
double r4871248 = r4871247 / r4871223;
double r4871249 = 0.375;
double r4871250 = r4871248 - r4871249;
double r4871251 = r4871223 * r4871223;
double r4871252 = r4871244 / r4871251;
double r4871253 = r4871250 * r4871252;
double r4871254 = fma(r4871245, r4871246, r4871253);
double r4871255 = r4871225 ? r4871241 : r4871254;
return r4871255;
}




Bits error versus x
| Original | 19.9 |
|---|---|
| Target | 0.6 |
| Herbie | 1.5 |
if x < 6705.611752539598Initial program 0.3
rmApplied pow1/20.3
Applied pow-flip0.1
Simplified0.1
rmApplied add-cube-cbrt0.1
Applied add-sqr-sqrt0.1
Applied times-frac0.1
Applied *-un-lft-identity0.1
Applied prod-diff0.1
if 6705.611752539598 < x Initial program 39.7
rmApplied pow1/239.7
Applied pow-flip44.5
Simplified44.5
rmApplied pow1/244.5
Applied pow-flip39.7
Simplified39.7
Taylor expanded around -inf 62.7
Simplified2.9
Final simplification1.5
herbie shell --seed 2019168 +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)))))