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




Bits error versus x
Results
| Original | 19.6 |
|---|---|
| Target | 0.6 |
| Herbie | 10.5 |
if x < 7077.048346062627Initial program 0.3
rmApplied add-sqr-sqrt0.3
Applied sqrt-prod0.4
Applied associate-/r*0.4
if 7077.048346062627 < x Initial program 39.5
rmApplied add-sqr-sqrt39.5
Applied sqrt-prod48.7
Applied add-sqr-sqrt48.7
Applied times-frac51.8
Applied add-sqr-sqrt45.6
Applied difference-of-squares45.6
Taylor expanded around inf 21.0
Simplified21.0
Final simplification10.5
herbie shell --seed 2020091
(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)))))