\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\begin{array}{l}
\mathbf{if}\;x \le 10784.107655470898:\\
\;\;\;\;\mathsf{fma}\left(\sqrt{x \cdot x + \left(1 \cdot 1 - x \cdot 1\right)}, \frac{-1}{\mathsf{hypot}\left({1}^{\frac{3}{2}}, {x}^{\frac{3}{2}}\right)}, \frac{1}{\sqrt{x}}\right) + \sqrt{x \cdot x + \left(1 \cdot 1 - x \cdot 1\right)} \cdot \left(\frac{-1}{\mathsf{hypot}\left({1}^{\frac{3}{2}}, {x}^{\frac{3}{2}}\right)} + \frac{1}{\sqrt{{x}^{3} + {1}^{3}}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1 \cdot \left(1 \cdot \left(\left(\frac{1}{{x}^{2}} + \frac{1}{{x}^{4}}\right) - \frac{1}{{x}^{3}}\right)\right)}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}\\
\end{array}double code(double x) {
return ((1.0 / sqrt(x)) - (1.0 / sqrt((x + 1.0))));
}
double code(double x) {
double VAR;
if ((x <= 10784.107655470898)) {
VAR = (fma(sqrt(((x * x) + ((1.0 * 1.0) - (x * 1.0)))), (-1.0 / hypot(pow(1.0, 1.5), pow(x, 1.5))), (1.0 / sqrt(x))) + (sqrt(((x * x) + ((1.0 * 1.0) - (x * 1.0)))) * ((-1.0 / hypot(pow(1.0, 1.5), pow(x, 1.5))) + (1.0 / sqrt((pow(x, 3.0) + pow(1.0, 3.0)))))));
} else {
VAR = ((1.0 * (1.0 * (((1.0 / pow(x, 2.0)) + (1.0 / pow(x, 4.0))) - (1.0 / pow(x, 3.0))))) / ((1.0 / sqrt(x)) + (1.0 / sqrt((x + 1.0)))));
}
return VAR;
}




Bits error versus x
Results
| Original | 19.8 |
|---|---|
| Target | 0.7 |
| Herbie | 5.7 |
if x < 10784.107655470898Initial program 0.4
rmApplied flip3-+0.4
Applied sqrt-div0.4
Applied associate-/r/0.4
Applied div-inv0.4
Applied prod-diff0.4
Simplified0.4
Simplified0.4
if 10784.107655470898 < x Initial program 39.9
rmApplied flip--39.9
Simplified39.9
Taylor expanded around inf 11.2
Simplified11.2
Final simplification5.7
herbie shell --seed 2020071 +o rules:numerics
(FPCore (x)
:name "2isqrt (example 3.6)"
:precision binary64
:herbie-target
(/ 1 (+ (* (+ x 1) (sqrt x)) (* x (sqrt (+ x 1)))))
(- (/ 1 (sqrt x)) (/ 1 (sqrt (+ x 1)))))