\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\begin{array}{l}
\mathbf{if}\;re \leq -9.645547492180995 \cdot 10^{+94}:\\
\;\;\;\;\frac{1}{\sqrt{\log 10}} \cdot \frac{\log \left(-re\right)}{\sqrt{\log 10}}\\
\mathbf{elif}\;re \leq -2.7017925900492935 \cdot 10^{-149}:\\
\;\;\;\;\frac{\log \left(\left|\sqrt[3]{re \cdot re + im \cdot im}\right| \cdot \sqrt{\sqrt[3]{re \cdot re + im \cdot im}}\right)}{\log 10}\\
\mathbf{else}:\\
\;\;\;\;-\frac{\log \left(\frac{1}{im}\right)}{\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 -9.645547492180995e+94)
(* (/ 1.0 (sqrt (log 10.0))) (/ (log (- re)) (sqrt (log 10.0))))
(if (<= re -2.7017925900492935e-149)
(/
(log
(*
(fabs (cbrt (+ (* re re) (* im im))))
(sqrt (cbrt (+ (* re re) (* im im))))))
(log 10.0))
(- (/ (log (/ 1.0 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 <= -9.645547492180995e+94) {
tmp = (1.0 / sqrt(log(10.0))) * (log(-re) / sqrt(log(10.0)));
} else if (re <= -2.7017925900492935e-149) {
tmp = log(fabs(cbrt((re * re) + (im * im))) * sqrt(cbrt((re * re) + (im * im)))) / log(10.0);
} else {
tmp = -(log(1.0 / im) / log(10.0));
}
return tmp;
}



Bits error versus re



Bits error versus im
Results
if re < -9.6455474921809946e94Initial program 50.7
Taylor expanded around -inf 5.2
Simplified5.2
rmApplied add-sqr-sqrt_binary645.2
Applied pow1_binary645.2
Applied log-pow_binary645.2
Applied times-frac_binary645.2
if -9.6455474921809946e94 < re < -2.70179259004929345e-149Initial program 11.3
rmApplied add-cube-cbrt_binary6411.3
Applied sqrt-prod_binary6411.3
Simplified11.3
if -2.70179259004929345e-149 < re Initial program 33.0
Taylor expanded around inf 5.8
Final simplification7.2
herbie shell --seed 2021175
(FPCore (re im)
:name "math.log10 on complex, real part"
:precision binary64
(/ (log (sqrt (+ (* re re) (* im im)))) (log 10.0)))