1 - \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}\begin{array}{l}
\mathbf{if}\;\mathsf{hypot}\left(1, x\right) \le 1:\\
\;\;\;\;\sqrt{\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)} \cdot \frac{\sqrt{\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{\mathsf{fma}\left(-0.5, 1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}, 1 \cdot 1\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 VAR;
if ((hypot(1.0, x) <= 1.0)) {
VAR = (sqrt(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))))))) * (sqrt(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 {
VAR = (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)))))));
}
return VAR;
}



Bits error versus x
Results
if (hypot 1.0 x) < 1.0Initial program 30.3
rmApplied flip--30.3
Simplified30.3
Taylor expanded around 0 30.3
Simplified0.0
rmApplied *-un-lft-identity0.0
Applied add-sqr-sqrt0.0
Applied times-frac0.0
Simplified0.0
if 1.0 < (hypot 1.0 x) Initial program 1.5
rmApplied flip--1.5
Simplified0.6
Final simplification0.3
herbie shell --seed 2020103 +o rules:numerics
(FPCore (x)
:name "Given's Rotation SVD example, simplified"
:precision binary64
(- 1 (sqrt (* 0.5 (+ 1 (/ 1 (hypot 1 x)))))))