1 - \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}\begin{array}{l}
\mathbf{if}\;x \le -0.960141676585021808:\\
\;\;\;\;\frac{\log \left(e^{\mathsf{fma}\left(\frac{1}{x}, 0.5 - \frac{0.25}{{x}^{2}}, 0.5\right)}\right)}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}\\
\mathbf{elif}\;x \le 0.00241917076359790323:\\
\;\;\;\;\frac{\mathsf{fma}\left(0.25, \frac{{x}^{2}}{{\left(\sqrt{1}\right)}^{3}}, 0.5 - \mathsf{fma}\left(0.5, \frac{1}{\sqrt{1}}, 0.1875 \cdot \frac{{x}^{4}}{{\left(\sqrt{1}\right)}^{5}}\right)\right)}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\log \left(e^{\mathsf{fma}\left(-0.5, 1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}, 1 \cdot 1\right)}\right)}{1 + \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}}\\
\end{array}double code(double x) {
return (1.0 - sqrt((0.5 * (1.0 + (1.0 / hypot(1.0, x))))));
}
double code(double x) {
double temp;
if ((x <= -0.9601416765850218)) {
temp = (log(exp(fma((1.0 / x), (0.5 - (0.25 / pow(x, 2.0))), 0.5))) / (1.0 + sqrt((0.5 * (1.0 + (1.0 / hypot(1.0, x)))))));
} else {
double temp_1;
if ((x <= 0.0024191707635979032)) {
temp_1 = (fma(0.25, (pow(x, 2.0) / pow(sqrt(1.0), 3.0)), (0.5 - fma(0.5, (1.0 / sqrt(1.0)), (0.1875 * (pow(x, 4.0) / pow(sqrt(1.0), 5.0)))))) / (1.0 + sqrt((0.5 * (1.0 + (1.0 / hypot(1.0, x)))))));
} else {
temp_1 = (log(exp(fma(-0.5, (1.0 + (1.0 / hypot(1.0, x))), (1.0 * 1.0)))) / (1.0 + sqrt((0.5 * (1.0 + (1.0 / hypot(1.0, x)))))));
}
temp = temp_1;
}
return temp;
}



Bits error versus x
Results
if x < -0.9601416765850218Initial program 1.0
rmApplied flip--1.0
Simplified0.0
rmApplied add-log-exp0.0
Taylor expanded around -inf 0.3
Simplified0.3
if -0.9601416765850218 < x < 0.0024191707635979032Initial program 29.8
rmApplied flip--29.8
Simplified29.8
Taylor expanded around 0 29.9
Simplified0.5
if 0.0024191707635979032 < x Initial program 1.1
rmApplied flip--1.1
Simplified0.1
rmApplied add-log-exp0.1
Final simplification0.4
herbie shell --seed 2020053 +o rules:numerics
(FPCore (x)
:name "Given's Rotation SVD example, simplified"
:precision binary64
(- 1 (sqrt (* 0.5 (+ 1 (/ 1 (hypot 1 x)))))))