\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\begin{array}{l}
\mathbf{if}\;re \leq -8.54260365148822 \cdot 10^{+142}:\\
\;\;\;\;\frac{0.5}{\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 \leq 1.5911973190793671 \cdot 10^{+134}:\\
\;\;\;\;\frac{0.5}{\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{\log re}{\log 10}\\
\end{array}(FPCore (re im) :precision binary64 (/ (log (sqrt (+ (* re re) (* im im)))) (log 10.0)))
(FPCore (re im)
:precision binary64
(if (<= re -8.54260365148822e+142)
(*
(/ 0.5 (sqrt (log 10.0)))
(* -2.0 (* (log (/ -1.0 re)) (sqrt (/ 1.0 (log 10.0))))))
(if (<= re 1.5911973190793671e+134)
(*
(/ 0.5 (sqrt (log 10.0)))
(log (pow (+ (* re re) (* im im)) (/ 1.0 (sqrt (log 10.0))))))
(/ (log re) (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 (re <= -8.54260365148822e+142) {
tmp = (0.5 / sqrt(log(10.0))) * (-2.0 * (log(-1.0 / re) * sqrt(1.0 / log(10.0))));
} else if (re <= 1.5911973190793671e+134) {
tmp = (0.5 / sqrt(log(10.0))) * log(pow(((re * re) + (im * im)), (1.0 / sqrt(log(10.0)))));
} else {
tmp = log(re) / log(10.0);
}
return tmp;
}



Bits error versus re



Bits error versus im
Results
if re < -8.5426036514882195e142Initial program 60.8
rmApplied add-sqr-sqrt_binary64_78960.8
Applied pow1/2_binary64_84760.8
Applied log-pow_binary64_85660.8
Applied times-frac_binary64_77360.8
Taylor expanded around -inf 5.6
if -8.5426036514882195e142 < re < 1.59119731907936711e134Initial program 21.9
rmApplied add-sqr-sqrt_binary64_78921.9
Applied pow1/2_binary64_84721.9
Applied log-pow_binary64_85621.9
Applied times-frac_binary64_77321.9
rmApplied add-log-exp_binary64_80621.9
Simplified21.7
if 1.59119731907936711e134 < re Initial program 58.0
Taylor expanded around inf 8.2
Final simplification17.7
herbie shell --seed 2020280
(FPCore (re im)
:name "math.log10 on complex, real part"
:precision binary64
(/ (log (sqrt (+ (* re re) (* im im)))) (log 10.0)))