\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\begin{array}{l}
\mathbf{if}\;re \le -7.58989654767235 \cdot 10^{122}:\\
\;\;\;\;\sqrt{\frac{\frac{1}{2}}{\sqrt{\log 10}}} \cdot \left(\sqrt{\frac{\frac{1}{2}}{\sqrt{\log 10}}} \cdot \frac{-2 \cdot \log \left(\frac{-1}{re}\right)}{\sqrt{\log 10}}\right)\\
\mathbf{elif}\;re \le -4.17286400801288077 \cdot 10^{-274}:\\
\;\;\;\;\frac{\frac{1}{2}}{\sqrt{\log 10}} \cdot \log \left({\left(re \cdot re + im \cdot im\right)}^{\left(\frac{1}{\sqrt{\log 10}}\right)}\right)\\
\mathbf{elif}\;re \le 1.8902523850390375 \cdot 10^{-167}:\\
\;\;\;\;\frac{\frac{1}{2}}{\sqrt{\log 10}} \cdot \left(2 \cdot \left(\log im \cdot \sqrt{\frac{1}{\log 10}}\right)\right)\\
\mathbf{elif}\;re \le 3.6652606826977648 \cdot 10^{101}:\\
\;\;\;\;\frac{\frac{1}{2}}{\sqrt{\log 10}} \cdot \log \left({\left(re \cdot re + im \cdot im\right)}^{\left(\frac{1}{\sqrt{\log 10}}\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{\frac{1}{2}}{\sqrt{\log 10}}} \cdot \left(-2 \cdot \left(\left(\log \left(\frac{1}{re}\right) \cdot \sqrt{\frac{1}{2}}\right) \cdot {\left(\frac{1}{{\left(\log 10\right)}^{3}}\right)}^{\frac{1}{4}}\right)\right)\\
\end{array}double code(double re, double im) {
return (log(sqrt(((re * re) + (im * im)))) / log(10.0));
}
double code(double re, double im) {
double VAR;
if ((re <= -7.58989654767235e+122)) {
VAR = (sqrt((0.5 / sqrt(log(10.0)))) * (sqrt((0.5 / sqrt(log(10.0)))) * (-(2.0 * log((-1.0 / re))) / sqrt(log(10.0)))));
} else {
double VAR_1;
if ((re <= -4.172864008012881e-274)) {
VAR_1 = ((0.5 / sqrt(log(10.0))) * log(pow(((re * re) + (im * im)), (1.0 / sqrt(log(10.0))))));
} else {
double VAR_2;
if ((re <= 1.8902523850390375e-167)) {
VAR_2 = ((0.5 / sqrt(log(10.0))) * (2.0 * (log(im) * sqrt((1.0 / log(10.0))))));
} else {
double VAR_3;
if ((re <= 3.665260682697765e+101)) {
VAR_3 = ((0.5 / sqrt(log(10.0))) * log(pow(((re * re) + (im * im)), (1.0 / sqrt(log(10.0))))));
} else {
VAR_3 = (sqrt((0.5 / sqrt(log(10.0)))) * (-2.0 * ((log((1.0 / re)) * sqrt(0.5)) * pow((1.0 / pow(log(10.0), 3.0)), 0.25))));
}
VAR_2 = VAR_3;
}
VAR_1 = VAR_2;
}
VAR = VAR_1;
}
return VAR;
}



Bits error versus re



Bits error versus im
Results
if re < -7.58989654767235e+122Initial program 56.8
rmApplied add-sqr-sqrt56.8
Applied pow1/256.8
Applied log-pow56.8
Applied times-frac56.7
rmApplied add-sqr-sqrt56.7
Applied associate-*l*56.7
Taylor expanded around -inf 8.5
if -7.58989654767235e+122 < re < -4.172864008012881e-274 or 1.8902523850390375e-167 < re < 3.665260682697765e+101Initial program 19.1
rmApplied add-sqr-sqrt19.1
Applied pow1/219.1
Applied log-pow19.1
Applied times-frac19.1
rmApplied add-log-exp19.1
Simplified18.9
if -4.172864008012881e-274 < re < 1.8902523850390375e-167Initial program 31.9
rmApplied add-sqr-sqrt31.9
Applied pow1/231.9
Applied log-pow31.9
Applied times-frac31.8
Taylor expanded around 0 34.7
if 3.665260682697765e+101 < re Initial program 52.1
rmApplied add-sqr-sqrt52.1
Applied pow1/252.1
Applied log-pow52.1
Applied times-frac52.1
rmApplied add-sqr-sqrt52.1
Applied associate-*l*52.0
Taylor expanded around inf 9.3
Final simplification18.0
herbie shell --seed 2020079
(FPCore (re im)
:name "math.log10 on complex, real part"
:precision binary64
(/ (log (sqrt (+ (* re re) (* im im)))) (log 10)))