0.5 \cdot \sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)}\begin{array}{l}
\mathbf{if}\;re \le 1755103.27134319046 \lor \neg \left(re \le 3.9030929001675639 \cdot 10^{52} \lor \neg \left(re \le 5.6852916263112347 \cdot 10^{140}\right)\right):\\
\;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(\left(\mathsf{hypot}\left(re, im\right) - re\right) + 0\right)}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \sqrt{2 \cdot \frac{{im}^{2} + 0}{re + \mathsf{hypot}\left(re, im\right)}}\\
\end{array}double code(double re, double im) {
return (0.5 * sqrt((2.0 * (sqrt(((re * re) + (im * im))) - re))));
}
double code(double re, double im) {
double temp;
if (((re <= 1755103.2713431905) || !((re <= 3.903092900167564e+52) || !(re <= 5.685291626311235e+140)))) {
temp = (0.5 * sqrt((2.0 * ((hypot(re, im) - re) + 0.0))));
} else {
temp = (0.5 * sqrt((2.0 * ((pow(im, 2.0) + 0.0) / (re + hypot(re, im))))));
}
return temp;
}



Bits error versus re



Bits error versus im
Results
if re < 1755103.2713431905 or 3.903092900167564e+52 < re < 5.685291626311235e+140Initial program 34.0
rmApplied add-cube-cbrt34.5
Applied add-sqr-sqrt34.5
Applied sqrt-prod34.6
Applied prod-diff34.7
Simplified8.5
Simplified7.9
if 1755103.2713431905 < re < 3.903092900167564e+52 or 5.685291626311235e+140 < re Initial program 59.9
rmApplied flip--59.9
Simplified44.9
Simplified31.3
Final simplification11.9
herbie shell --seed 2020066 +o rules:numerics
(FPCore (re im)
:name "math.sqrt on complex, imaginary part, im greater than 0 branch"
:precision binary64
(* 0.5 (sqrt (* 2 (- (sqrt (+ (* re re) (* im im))) re)))))