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 := 1 + \sqrt{0.5 + t_0}\\
t_2 := 0.5 - t_0\\
\mathbf{if}\;x \leq -0.002203921674884077:\\
\;\;\;\;\frac{1}{\frac{t_1}{t_2}}\\
\mathbf{elif}\;x \leq 0.002673467331980555:\\
\;\;\;\;\mathsf{fma}\left(x, x \cdot 0.125, {x}^{4} \cdot -0.0859375\right)\\
\mathbf{else}:\\
\;\;\;\;t_2 \cdot \frac{1}{t_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 (+ 1.0 (sqrt (+ 0.5 t_0))))
(t_2 (- 0.5 t_0)))
(if (<= x -0.002203921674884077)
(/ 1.0 (/ t_1 t_2))
(if (<= x 0.002673467331980555)
(fma x (* x 0.125) (* (pow x 4.0) -0.0859375))
(* t_2 (/ 1.0 t_1))))))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 = 1.0 + sqrt(0.5 + t_0);
double t_2 = 0.5 - t_0;
double tmp;
if (x <= -0.002203921674884077) {
tmp = 1.0 / (t_1 / t_2);
} else if (x <= 0.002673467331980555) {
tmp = fma(x, (x * 0.125), (pow(x, 4.0) * -0.0859375));
} else {
tmp = t_2 * (1.0 / t_1);
}
return tmp;
}



Bits error versus x
if x < -0.00220392167488407719Initial program 1.0
Simplified1.0
Applied flip--_binary641.0
Simplified0.1
Applied clear-num_binary640.1
if -0.00220392167488407719 < x < 0.00267346733198055514Initial program 29.9
Simplified29.9
Applied flip--_binary6429.9
Simplified29.9
Taylor expanded in x around 0 0.1
Simplified0.1
if 0.00267346733198055514 < x Initial program 1.0
Simplified1.0
Applied flip--_binary641.0
Simplified0.1
Applied div-inv_binary640.1
Final simplification0.1
herbie shell --seed 2021225
(FPCore (x)
:name "Given's Rotation SVD example, simplified"
:precision binary64
(- 1.0 (sqrt (* 0.5 (+ 1.0 (/ 1.0 (hypot 1.0 x)))))))