1 - \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}
\begin{array}{l}
t_0 := \frac{0.5}{\mathsf{hypot}\left(1, x\right)}\\
t_1 := 0.5 + t_0\\
t_2 := \sqrt{t_1}\\
\mathbf{if}\;x \leq -0.0108257881037984:\\
\;\;\;\;\left(1 - {t_1}^{1.5}\right) \cdot \sqrt{{\left(1.5 + \left(t_0 + t_2\right)\right)}^{-2}}\\
\mathbf{elif}\;x \leq 0.010586867664495958:\\
\;\;\;\;\mathsf{fma}\left({x}^{4}, -0.0859375, \mathsf{fma}\left(0.125, x \cdot x, 0.0673828125 \cdot {x}^{6}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{1 + t_2} \cdot {\left(\frac{1}{0.5 - t_0}\right)}^{-1}\\
\end{array}
(FPCore (x) :precision binary64 (- 1.0 (sqrt (* 0.5 (+ 1.0 (/ 1.0 (hypot 1.0 x)))))))
(FPCore (x)
:precision binary64
(let* ((t_0 (/ 0.5 (hypot 1.0 x))) (t_1 (+ 0.5 t_0)) (t_2 (sqrt t_1)))
(if (<= x -0.0108257881037984)
(* (- 1.0 (pow t_1 1.5)) (sqrt (pow (+ 1.5 (+ t_0 t_2)) -2.0)))
(if (<= x 0.010586867664495958)
(fma
(pow x 4.0)
-0.0859375
(fma 0.125 (* x x) (* 0.0673828125 (pow x 6.0))))
(* (/ 1.0 (+ 1.0 t_2)) (pow (/ 1.0 (- 0.5 t_0)) -1.0))))))double code(double x) {
return 1.0 - sqrt((0.5 * (1.0 + (1.0 / hypot(1.0, x)))));
}
double code(double x) {
double t_0 = 0.5 / hypot(1.0, x);
double t_1 = 0.5 + t_0;
double t_2 = sqrt(t_1);
double tmp;
if (x <= -0.0108257881037984) {
tmp = (1.0 - pow(t_1, 1.5)) * sqrt(pow((1.5 + (t_0 + t_2)), -2.0));
} else if (x <= 0.010586867664495958) {
tmp = fma(pow(x, 4.0), -0.0859375, fma(0.125, (x * x), (0.0673828125 * pow(x, 6.0))));
} else {
tmp = (1.0 / (1.0 + t_2)) * pow((1.0 / (0.5 - t_0)), -1.0);
}
return tmp;
}



Bits error versus x
if x < -0.0108257881037984Initial program 1.0
Simplified1.0
Applied egg-rr1.0
Applied egg-rr0.1
if -0.0108257881037984 < x < 0.01058686766449596Initial program 30.1
Simplified30.1
Taylor expanded in x around 0 0.0
Simplified0.0
if 0.01058686766449596 < x Initial program 1.0
Simplified1.0
Applied egg-rr0.0
Applied egg-rr0.1
Final simplification0.0
herbie shell --seed 2022130
(FPCore (x)
:name "Given's Rotation SVD example, simplified"
:precision binary64
(- 1.0 (sqrt (* 0.5 (+ 1.0 (/ 1.0 (hypot 1.0 x)))))))