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\\
\mathbf{if}\;x \leq -0.00010956238046010226:\\
\;\;\;\;\frac{t_1}{1 + \log \left(e^{\sqrt{0.5 + t_0}}\right)}\\
\mathbf{elif}\;x \leq 0.00012153717904520032:\\
\;\;\;\;0.125 \cdot {x}^{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_1}{1 + \frac{\sqrt{0.25 - t_0 \cdot t_0}}{\sqrt{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 (- 0.5 t_0)))
(if (<= x -0.00010956238046010226)
(/ t_1 (+ 1.0 (log (exp (sqrt (+ 0.5 t_0))))))
(if (<= x 0.00012153717904520032)
(* 0.125 (pow x 2.0))
(/ t_1 (+ 1.0 (/ (sqrt (- 0.25 (* t_0 t_0))) (sqrt 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 = 0.5 - t_0;
double tmp;
if (x <= -0.00010956238046010226) {
tmp = t_1 / (1.0 + log(exp(sqrt(0.5 + t_0))));
} else if (x <= 0.00012153717904520032) {
tmp = 0.125 * pow(x, 2.0);
} else {
tmp = t_1 / (1.0 + (sqrt(0.25 - (t_0 * t_0)) / sqrt(t_1)));
}
return tmp;
}



Bits error versus x
Results
if x < -1.0956238046010226e-4Initial program 1.2
Simplified1.2
Applied flip--_binary641.2
Simplified0.2
Applied add-log-exp_binary640.2
if -1.0956238046010226e-4 < x < 1.21537179045200323e-4Initial program 30.2
Simplified30.2
Taylor expanded in x around 0 0.2
if 1.21537179045200323e-4 < x Initial program 1.1
Simplified1.1
Applied flip--_binary641.1
Simplified0.1
Applied flip-+_binary640.1
Applied sqrt-div_binary640.1
Final simplification0.2
herbie shell --seed 2022081
(FPCore (x)
:name "Given's Rotation SVD example, simplified"
:precision binary64
(- 1.0 (sqrt (* 0.5 (+ 1.0 (/ 1.0 (hypot 1.0 x)))))))