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) \leq 1.0000000016899053:\\
\;\;\;\;\mathsf{fma}\left({x}^{4}, -0.0859375, 0.125 \cdot \left(x \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_0 := \frac{0.5}{\mathsf{hypot}\left(1, x\right)}\\
\frac{1}{\frac{1 + \sqrt{0.5 + t_0}}{0.5 - t_0}}
\end{array}\\
\end{array}
(FPCore (x) :precision binary64 (- 1.0 (sqrt (* 0.5 (+ 1.0 (/ 1.0 (hypot 1.0 x)))))))
(FPCore (x)
:precision binary64
(if (<= (hypot 1.0 x) 1.0000000016899053)
(fma (pow x 4.0) -0.0859375 (* 0.125 (* x x)))
(let* ((t_0 (/ 0.5 (hypot 1.0 x))))
(/ 1.0 (/ (+ 1.0 (sqrt (+ 0.5 t_0))) (- 0.5 t_0))))))double code(double x) {
return 1.0 - sqrt(0.5 * (1.0 + (1.0 / hypot(1.0, x))));
}
double code(double x) {
double tmp;
if (hypot(1.0, x) <= 1.0000000016899053) {
tmp = fma(pow(x, 4.0), -0.0859375, (0.125 * (x * x)));
} else {
double t_0 = 0.5 / hypot(1.0, x);
tmp = 1.0 / ((1.0 + sqrt(0.5 + t_0)) / (0.5 - t_0));
}
return tmp;
}



Bits error versus x
if (hypot.f64 1 x) < 1.00000000168990533Initial program 30.5
Simplified30.5
Taylor expanded in x around 0 0.0
Simplified0.0
if 1.00000000168990533 < (hypot.f64 1 x) Initial program 1.2
Simplified1.2
Applied flip--_binary641.2
Simplified0.2
Applied clear-num_binary640.2
Final simplification0.1
herbie shell --seed 2021313
(FPCore (x)
:name "Given's Rotation SVD example, simplified"
:precision binary64
(- 1.0 (sqrt (* 0.5 (+ 1.0 (/ 1.0 (hypot 1.0 x)))))))