\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\begin{array}{l}
\mathbf{if}\;im \leq 3.1954262360162713 \cdot 10^{-124}:\\
\;\;\;\;\frac{1}{\sqrt{\log 10}} \cdot \frac{\log \left(-re\right)}{\sqrt{\log 10}}\\
\mathbf{elif}\;im \leq 6.578330190231049 \cdot 10^{+55}:\\
\;\;\;\;\frac{0.5}{\frac{\log 10}{\log \left(re \cdot re + im \cdot im\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\log im}{\log 10}\\
\end{array}(FPCore (re im) :precision binary64 (/ (log (sqrt (+ (* re re) (* im im)))) (log 10.0)))
(FPCore (re im)
:precision binary64
(if (<= im 3.1954262360162713e-124)
(* (/ 1.0 (sqrt (log 10.0))) (/ (log (- re)) (sqrt (log 10.0))))
(if (<= im 6.578330190231049e+55)
(/ 0.5 (/ (log 10.0) (log (+ (* re re) (* im im)))))
(/ (log im) (log 10.0)))))double code(double re, double im) {
return log(sqrt((re * re) + (im * im))) / log(10.0);
}
double code(double re, double im) {
double tmp;
if (im <= 3.1954262360162713e-124) {
tmp = (1.0 / sqrt(log(10.0))) * (log(-re) / sqrt(log(10.0)));
} else if (im <= 6.578330190231049e+55) {
tmp = 0.5 / (log(10.0) / log((re * re) + (im * im)));
} else {
tmp = log(im) / log(10.0);
}
return tmp;
}



Bits error versus re



Bits error versus im
Results
if im < 3.19542623601627129e-124Initial program 31.0
Taylor expanded around -inf 7.1
Simplified7.1
rmApplied add-sqr-sqrt_binary647.1
Applied pow1_binary647.1
Applied log-pow_binary647.1
Applied times-frac_binary647.1
if 3.19542623601627129e-124 < im < 6.57833019023104904e55Initial program 11.1
rmApplied pow1/2_binary6411.1
Applied log-pow_binary6411.1
Applied associate-/l*_binary6411.1
if 6.57833019023104904e55 < im Initial program 44.7
Taylor expanded around 0 6.7
Final simplification7.8
herbie shell --seed 2021174
(FPCore (re im)
:name "math.log10 on complex, real part"
:precision binary64
(/ (log (sqrt (+ (* re re) (* im im)))) (log 10.0)))