\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\begin{array}{l}
\mathbf{if}\;x \le 6940.77878829129895:\\
\;\;\;\;\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{{x}^{3} + {1}^{3}}} \cdot \sqrt{x \cdot x + \left(1 \cdot 1 - x \cdot 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(0.3125 \cdot \left(\sqrt{\frac{1}{{x}^{7}}} \cdot {\left(\sqrt{1}\right)}^{2}\right) + 0.5 \cdot \left(\sqrt{\frac{1}{{x}^{3}}} \cdot {\left(\sqrt{1}\right)}^{2}\right)\right) - 0.375 \cdot \left(\sqrt{\frac{1}{{x}^{5}}} \cdot {\left(\sqrt{1}\right)}^{2}\right)\\
\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 <= 6940.778788291299)) {
VAR = ((1.0 / sqrt(x)) - ((1.0 / sqrt((pow(x, 3.0) + pow(1.0, 3.0)))) * sqrt(((x * x) + ((1.0 * 1.0) - (x * 1.0))))));
} else {
VAR = (((0.3125 * (sqrt((1.0 / pow(x, 7.0))) * pow(sqrt(1.0), 2.0))) + (0.5 * (sqrt((1.0 / pow(x, 3.0))) * pow(sqrt(1.0), 2.0)))) - (0.375 * (sqrt((1.0 / pow(x, 5.0))) * pow(sqrt(1.0), 2.0))));
}
return VAR;
}




Bits error versus x
Results
| Original | 19.7 |
|---|---|
| Target | 0.7 |
| Herbie | 10.6 |
if x < 6940.778788291299Initial program 0.4
rmApplied flip3-+0.4
Applied sqrt-div0.4
Applied associate-/r/0.4
if 6940.778788291299 < x Initial program 39.7
rmApplied add-sqr-sqrt39.7
Applied sqrt-prod47.9
Applied add-sqr-sqrt47.9
Applied times-frac51.7
Applied add-sqr-sqrt45.6
Applied difference-of-squares45.6
Taylor expanded around inf 21.1
Final simplification10.6
herbie shell --seed 2020105 +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)))))