\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\begin{array}{l}
\mathbf{if}\;re \leq -1.4840638130856809 \cdot 10^{+75}:\\
\;\;\;\;\frac{1}{\sqrt{\log 10}} \cdot \log \left({\left(-re\right)}^{\left(\frac{1}{\sqrt{\log 10}}\right)}\right)\\
\mathbf{elif}\;re \leq -2.5396447653359938 \cdot 10^{-165}:\\
\;\;\;\;\frac{0.5}{\sqrt{\log 10}} \cdot \frac{\log \left(re \cdot re + im \cdot im\right)}{\sqrt{\log 10}}\\
\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 (<= re -1.4840638130856809e+75)
(* (/ 1.0 (sqrt (log 10.0))) (log (pow (- re) (/ 1.0 (sqrt (log 10.0))))))
(if (<= re -2.5396447653359938e-165)
(*
(/ 0.5 (sqrt (log 10.0)))
(/ (log (+ (* re re) (* im im))) (sqrt (log 10.0))))
(/ (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 (re <= -1.4840638130856809e+75) {
tmp = (1.0 / sqrt(log(10.0))) * log(pow(-re, (1.0 / sqrt(log(10.0)))));
} else if (re <= -2.5396447653359938e-165) {
tmp = (0.5 / sqrt(log(10.0))) * (log((re * re) + (im * im)) / sqrt(log(10.0)));
} else {
tmp = log(im) / log(10.0);
}
return tmp;
}



Bits error versus re



Bits error versus im
Results
if re < -1.48406381308568086e75Initial program 46.5
Taylor expanded around -inf 5.7
Simplified5.7
rmApplied add-sqr-sqrt_binary64_7825.7
Applied pow1_binary64_8215.7
Applied log-pow_binary64_8495.7
Applied times-frac_binary64_7665.6
rmApplied add-log-exp_binary64_7995.6
Simplified5.4
if -1.48406381308568086e75 < re < -2.53964476533599376e-165Initial program 11.7
rmApplied add-sqr-sqrt_binary64_78211.7
Applied pow1/2_binary64_84011.7
Applied log-pow_binary64_84911.7
Applied times-frac_binary64_76611.7
if -2.53964476533599376e-165 < re Initial program 32.7
Taylor expanded around 0 4.8
Final simplification6.9
herbie shell --seed 2021058
(FPCore (re im)
:name "math.log10 on complex, real part"
:precision binary64
(/ (log (sqrt (+ (* re re) (* im im)))) (log 10.0)))