\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\begin{array}{l}
\mathbf{if}\;re \le -9.31413148065956627 \cdot 10^{128}:\\
\;\;\;\;\frac{\frac{1}{2}}{\sqrt{\log 10}} \cdot \left(-2 \cdot \left(\log \left(\frac{-1}{re}\right) \cdot \sqrt{\frac{1}{\log 10}}\right)\right)\\
\mathbf{elif}\;re \le -1.40477998933113187 \cdot 10^{-158}:\\
\;\;\;\;\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 -7.85132988098298303 \cdot 10^{-304}:\\
\;\;\;\;\sqrt{\frac{\frac{1}{2}}{\sqrt{\log 10}}} \cdot \left(2 \cdot \left(\left(\log im \cdot \sqrt{\frac{1}{2}}\right) \cdot {\left(\frac{1}{{\left(\log 10\right)}^{3}}\right)}^{\frac{1}{4}}\right)\right)\\
\mathbf{elif}\;re \le 2.1537425348704007 \cdot 10^{102}:\\
\;\;\;\;\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 <= -9.314131480659566e+128)) {
VAR = ((0.5 / sqrt(log(10.0))) * (-2.0 * (log((-1.0 / re)) * sqrt((1.0 / log(10.0))))));
} else {
double VAR_1;
if ((re <= -1.4047799893311319e-158)) {
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 <= -7.851329880982983e-304)) {
VAR_2 = (sqrt((0.5 / sqrt(log(10.0)))) * (2.0 * ((log(im) * sqrt(0.5)) * pow((1.0 / pow(log(10.0), 3.0)), 0.25))));
} else {
double VAR_3;
if ((re <= 2.1537425348704007e+102)) {
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 < -9.314131480659566e+128Initial program 58.2
rmApplied add-sqr-sqrt58.2
Applied pow1/258.2
Applied log-pow58.2
Applied times-frac58.2
Taylor expanded around -inf 8.2
if -9.314131480659566e+128 < re < -1.4047799893311319e-158 or -7.851329880982983e-304 < re < 2.1537425348704007e+102Initial program 19.9
rmApplied add-sqr-sqrt19.9
Applied pow1/219.9
Applied log-pow19.9
Applied times-frac19.9
rmApplied add-log-exp19.9
Simplified19.7
if -1.4047799893311319e-158 < re < -7.851329880982983e-304Initial program 31.5
rmApplied add-sqr-sqrt31.5
Applied pow1/231.5
Applied log-pow31.5
Applied times-frac31.5
rmApplied add-sqr-sqrt31.5
Applied associate-*l*31.4
Taylor expanded around 0 35.3
if 2.1537425348704007e+102 < re Initial program 52.5
rmApplied add-sqr-sqrt52.5
Applied pow1/252.5
Applied log-pow52.5
Applied times-frac52.5
rmApplied add-sqr-sqrt52.4
Applied associate-*l*52.4
Taylor expanded around inf 9.3
Final simplification18.3
herbie shell --seed 2020102
(FPCore (re im)
:name "math.log10 on complex, real part"
:precision binary64
(/ (log (sqrt (+ (* re re) (* im im)))) (log 10)))