\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\begin{array}{l}
\mathbf{if}\;x \le 7911.288097968324:\\
\;\;\;\;\mathsf{fma}\left(\frac{-1}{\sqrt{\sqrt{1 + x}}}, \frac{1}{\sqrt{\sqrt{1 + x}}}, \frac{1}{\sqrt{\sqrt{1 + x}}} \cdot \frac{1}{\sqrt{\sqrt{1 + x}}}\right) + \mathsf{fma}\left(1, {x}^{\frac{-1}{2}}, -\frac{1}{\sqrt{\sqrt{1 + x}}} \cdot \frac{1}{\sqrt{\sqrt{1 + x}}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\frac{\frac{1}{x \cdot x}}{x \cdot x} + \frac{1}{x \cdot x}\right) - \frac{\frac{1}{x \cdot x}}{x}}{{x}^{\frac{-1}{2}} + \frac{1}{\sqrt{1 + x}}}\\
\end{array}double f(double x) {
double r3157799 = 1.0;
double r3157800 = x;
double r3157801 = sqrt(r3157800);
double r3157802 = r3157799 / r3157801;
double r3157803 = r3157800 + r3157799;
double r3157804 = sqrt(r3157803);
double r3157805 = r3157799 / r3157804;
double r3157806 = r3157802 - r3157805;
return r3157806;
}
double f(double x) {
double r3157807 = x;
double r3157808 = 7911.288097968324;
bool r3157809 = r3157807 <= r3157808;
double r3157810 = -1.0;
double r3157811 = 1.0;
double r3157812 = r3157811 + r3157807;
double r3157813 = sqrt(r3157812);
double r3157814 = sqrt(r3157813);
double r3157815 = r3157810 / r3157814;
double r3157816 = r3157811 / r3157814;
double r3157817 = r3157816 * r3157816;
double r3157818 = fma(r3157815, r3157816, r3157817);
double r3157819 = -0.5;
double r3157820 = pow(r3157807, r3157819);
double r3157821 = -r3157817;
double r3157822 = fma(r3157811, r3157820, r3157821);
double r3157823 = r3157818 + r3157822;
double r3157824 = r3157807 * r3157807;
double r3157825 = r3157811 / r3157824;
double r3157826 = r3157825 / r3157824;
double r3157827 = r3157826 + r3157825;
double r3157828 = r3157825 / r3157807;
double r3157829 = r3157827 - r3157828;
double r3157830 = r3157811 / r3157813;
double r3157831 = r3157820 + r3157830;
double r3157832 = r3157829 / r3157831;
double r3157833 = r3157809 ? r3157823 : r3157832;
return r3157833;
}




Bits error versus x
| Original | 19.9 |
|---|---|
| Target | 0.7 |
| Herbie | 5.5 |
if x < 7911.288097968324Initial program 0.3
rmApplied pow1/20.3
Applied pow-flip0.1
Simplified0.1
rmApplied add-sqr-sqrt0.1
Applied sqrt-prod0.1
Applied add-sqr-sqrt0.1
Applied times-frac0.1
Applied *-un-lft-identity0.1
Applied prod-diff0.1
if 7911.288097968324 < x Initial program 39.6
rmApplied pow1/239.6
Applied pow-flip44.6
Simplified44.6
rmApplied flip--44.6
Taylor expanded around inf 10.9
Simplified10.9
Final simplification5.5
herbie shell --seed 2019152 +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)))))