\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\begin{array}{l}
\mathbf{if}\;re \le -1.79671734719750555 \cdot 10^{106}:\\
\;\;\;\;\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.8331979976285039 \cdot 10^{-297}:\\
\;\;\;\;\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 4.0892765348340891 \cdot 10^{-181}:\\
\;\;\;\;\sqrt{\frac{\frac{1}{2}}{\sqrt{\log 10}}} \cdot \left(\sqrt{\frac{\frac{1}{2}}{\sqrt{\log 10}}} \cdot \left(2 \cdot \left(\log im \cdot \sqrt{\frac{1}{\log 10}}\right)\right)\right)\\
\mathbf{elif}\;re \le 1.81716207369607329 \cdot 10^{93}:\\
\;\;\;\;\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}:\\
\;\;\;\;\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)\\
\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 <= -1.7967173471975055e+106)) {
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.833197997628504e-297)) {
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 <= 4.089276534834089e-181)) {
VAR_2 = (sqrt((0.5 / sqrt(log(10.0)))) * (sqrt((0.5 / sqrt(log(10.0)))) * (2.0 * (log(im) * sqrt((1.0 / log(10.0)))))));
} else {
double VAR_3;
if ((re <= 1.8171620736960733e+93)) {
VAR_3 = ((0.5 / sqrt(log(10.0))) * log(pow(((re * re) + (im * im)), (1.0 / sqrt(log(10.0))))));
} else {
VAR_3 = ((0.5 / sqrt(log(10.0))) * (-2.0 * (log((1.0 / re)) * sqrt((1.0 / log(10.0))))));
}
VAR_2 = VAR_3;
}
VAR_1 = VAR_2;
}
VAR = VAR_1;
}
return VAR;
}



Bits error versus re



Bits error versus im
Results
if re < -1.7967173471975055e+106Initial program 52.7
rmApplied add-sqr-sqrt52.7
Applied pow1/252.7
Applied log-pow52.7
Applied times-frac52.7
rmApplied add-sqr-sqrt52.7
Applied associate-*l*52.7
Taylor expanded around -inf 9.4
if -1.7967173471975055e+106 < re < 4.833197997628504e-297 or 4.089276534834089e-181 < re < 1.8171620736960733e+93Initial program 19.0
rmApplied add-sqr-sqrt19.0
Applied pow1/219.0
Applied log-pow19.0
Applied times-frac19.0
rmApplied add-log-exp19.0
Simplified18.8
if 4.833197997628504e-297 < re < 4.089276534834089e-181Initial program 30.9
rmApplied add-sqr-sqrt30.9
Applied pow1/230.9
Applied log-pow30.9
Applied times-frac30.9
rmApplied add-sqr-sqrt30.9
Applied associate-*l*30.8
Taylor expanded around 0 36.0
if 1.8171620736960733e+93 < re Initial program 50.3
rmApplied add-sqr-sqrt50.3
Applied pow1/250.3
Applied log-pow50.3
Applied times-frac50.3
Taylor expanded around inf 8.5
Final simplification17.1
herbie shell --seed 2020092
(FPCore (re im)
:name "math.log10 on complex, real part"
:precision binary64
(/ (log (sqrt (+ (* re re) (* im im)))) (log 10)))