\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\begin{array}{l}
\mathbf{if}\;x \le 9.993638768580708575728490299319521227813 \cdot 10^{79}:\\
\;\;\;\;\left(\frac{1}{\sqrt{x}} - \frac{\frac{1}{\sqrt{\sqrt{1 + x}}}}{\sqrt{\sqrt{1 + x}}}\right) + \mathsf{fma}\left(\frac{1}{\sqrt{\sqrt{1 + x}}}, \frac{-1}{\sqrt{\sqrt{1 + x}}}, \frac{\frac{1}{\sqrt{\sqrt{1 + x}}}}{\sqrt{\sqrt{1 + x}}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x}}\right) \cdot \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{1 + x}} \cdot \left(\frac{1}{\sqrt{1 + x}} \cdot \frac{1}{\sqrt{1 + x}}\right)}{\mathsf{fma}\left(\frac{1}{\sqrt{1 + x}}, \frac{1}{\sqrt{1 + x}} + \frac{1}{\sqrt{x}}, \frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x}}\right)}\\
\end{array}double f(double x) {
double r5978813 = 1.0;
double r5978814 = x;
double r5978815 = sqrt(r5978814);
double r5978816 = r5978813 / r5978815;
double r5978817 = r5978814 + r5978813;
double r5978818 = sqrt(r5978817);
double r5978819 = r5978813 / r5978818;
double r5978820 = r5978816 - r5978819;
return r5978820;
}
double f(double x) {
double r5978821 = x;
double r5978822 = 9.993638768580709e+79;
bool r5978823 = r5978821 <= r5978822;
double r5978824 = 1.0;
double r5978825 = sqrt(r5978821);
double r5978826 = r5978824 / r5978825;
double r5978827 = r5978824 + r5978821;
double r5978828 = sqrt(r5978827);
double r5978829 = sqrt(r5978828);
double r5978830 = r5978824 / r5978829;
double r5978831 = r5978830 / r5978829;
double r5978832 = r5978826 - r5978831;
double r5978833 = -1.0;
double r5978834 = r5978833 / r5978829;
double r5978835 = fma(r5978830, r5978834, r5978831);
double r5978836 = r5978832 + r5978835;
double r5978837 = r5978826 * r5978826;
double r5978838 = r5978837 * r5978826;
double r5978839 = r5978824 / r5978828;
double r5978840 = r5978839 * r5978839;
double r5978841 = r5978839 * r5978840;
double r5978842 = r5978838 - r5978841;
double r5978843 = r5978839 + r5978826;
double r5978844 = fma(r5978839, r5978843, r5978837);
double r5978845 = r5978842 / r5978844;
double r5978846 = r5978823 ? r5978836 : r5978845;
return r5978846;
}




Bits error versus x
| Original | 20.1 |
|---|---|
| Target | 0.6 |
| Herbie | 19.9 |
if x < 9.993638768580709e+79Initial program 11.5
rmApplied add-sqr-sqrt11.5
Applied sqrt-prod11.5
Applied *-un-lft-identity11.5
Applied times-frac11.4
Applied add-sqr-sqrt11.8
Applied prod-diff11.8
Simplified11.3
Simplified11.3
if 9.993638768580709e+79 < x Initial program 34.3
rmApplied flip3--34.3
Simplified34.3
Simplified34.3
Final simplification19.9
herbie shell --seed 2019192 +o rules:numerics
(FPCore (x)
:name "2isqrt (example 3.6)"
:herbie-target
(/ 1.0 (+ (* (+ x 1.0) (sqrt x)) (* x (sqrt (+ x 1.0)))))
(- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))