\sqrt{re \cdot re + im \cdot im}\begin{array}{l}
\mathbf{if}\;re \leq -4.864167289730826 \cdot 10^{+136}:\\
\;\;\;\;-re\\
\mathbf{elif}\;re \leq -2.4704911317770355 \cdot 10^{-70}:\\
\;\;\;\;\sqrt{re \cdot re + im \cdot im}\\
\mathbf{elif}\;re \leq -1.6020683207984553 \cdot 10^{-95}:\\
\;\;\;\;im\\
\mathbf{elif}\;re \leq 1.1635286815108139 \cdot 10^{+92}:\\
\;\;\;\;\sqrt{re \cdot re + im \cdot im}\\
\mathbf{else}:\\
\;\;\;\;re\\
\end{array}(FPCore (re im) :precision binary64 (sqrt (+ (* re re) (* im im))))
(FPCore (re im)
:precision binary64
(if (<= re -4.864167289730826e+136)
(- re)
(if (<= re -2.4704911317770355e-70)
(sqrt (+ (* re re) (* im im)))
(if (<= re -1.6020683207984553e-95)
im
(if (<= re 1.1635286815108139e+92)
(sqrt (+ (* re re) (* im im)))
re)))))double code(double re, double im) {
return ((double) sqrt(((double) (((double) (re * re)) + ((double) (im * im))))));
}
double code(double re, double im) {
double tmp;
if ((re <= -4.864167289730826e+136)) {
tmp = ((double) -(re));
} else {
double tmp_1;
if ((re <= -2.4704911317770355e-70)) {
tmp_1 = ((double) sqrt(((double) (((double) (re * re)) + ((double) (im * im))))));
} else {
double tmp_2;
if ((re <= -1.6020683207984553e-95)) {
tmp_2 = im;
} else {
double tmp_3;
if ((re <= 1.1635286815108139e+92)) {
tmp_3 = ((double) sqrt(((double) (((double) (re * re)) + ((double) (im * im))))));
} else {
tmp_3 = re;
}
tmp_2 = tmp_3;
}
tmp_1 = tmp_2;
}
tmp = tmp_1;
}
return tmp;
}



Bits error versus re



Bits error versus im
Results
if re < -4.8641672897308265e136Initial program Error: 59.4 bits
Taylor expanded around -inf Error: 9.6 bits
SimplifiedError: 9.6 bits
if -4.8641672897308265e136 < re < -2.4704911317770355e-70 or -1.6020683207984553e-95 < re < 1.1635286815108139e92Initial program Error: 21.0 bits
if -2.4704911317770355e-70 < re < -1.6020683207984553e-95Initial program Error: 20.5 bits
Taylor expanded around 0 Error: 39.2 bits
if 1.1635286815108139e92 < re Initial program Error: 49.8 bits
Taylor expanded around inf Error: 11.6 bits
Final simplificationError: 18.0 bits
herbie shell --seed 2020204
(FPCore (re im)
:name "math.abs on complex"
:precision binary64
(sqrt (+ (* re re) (* im im))))