\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\begin{array}{l}
\mathbf{if}\;im \leq 1.1776961076709698 \cdot 10^{-158}:\\
\;\;\;\;\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}\;im \leq 9.723511542146676 \cdot 10^{+37}:\\
\;\;\;\;\frac{0.5}{\sqrt{\log 10}} \cdot \log \left({\left(im \cdot im + re \cdot re\right)}^{\left(\frac{1}{\sqrt{\log 10}}\right)}\right)\\
\mathbf{elif}\;im \leq 5.577535844625118 \cdot 10^{+41}:\\
\;\;\;\;\sqrt{0.5} \cdot \left(-2 \cdot \frac{\log \left(\frac{-1}{re}\right) \cdot \sqrt{0.5}}{\log 10}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{\sqrt{\log 10}} \cdot \left(-2 \cdot \left(\sqrt{\frac{1}{\log 10}} \cdot \log \left(\frac{1}{im}\right)\right)\right)\\
\end{array}(FPCore (re im) :precision binary64 (/ (log (sqrt (+ (* re re) (* im im)))) (log 10.0)))
(FPCore (re im)
:precision binary64
(if (<= im 1.1776961076709698e-158)
(*
(/ 0.5 (sqrt (log 10.0)))
(* -2.0 (* (log (/ -1.0 re)) (sqrt (/ 1.0 (log 10.0))))))
(if (<= im 9.723511542146676e+37)
(*
(/ 0.5 (sqrt (log 10.0)))
(log (pow (+ (* im im) (* re re)) (/ 1.0 (sqrt (log 10.0))))))
(if (<= im 5.577535844625118e+41)
(* (sqrt 0.5) (* -2.0 (/ (* (log (/ -1.0 re)) (sqrt 0.5)) (log 10.0))))
(*
(/ 0.5 (sqrt (log 10.0)))
(* -2.0 (* (sqrt (/ 1.0 (log 10.0))) (log (/ 1.0 im)))))))))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 <= 1.1776961076709698e-158) {
tmp = (0.5 / sqrt(log(10.0))) * (-2.0 * (log(-1.0 / re) * sqrt(1.0 / log(10.0))));
} else if (im <= 9.723511542146676e+37) {
tmp = (0.5 / sqrt(log(10.0))) * log(pow(((im * im) + (re * re)), (1.0 / sqrt(log(10.0)))));
} else if (im <= 5.577535844625118e+41) {
tmp = sqrt(0.5) * (-2.0 * ((log(-1.0 / re) * sqrt(0.5)) / log(10.0)));
} else {
tmp = (0.5 / sqrt(log(10.0))) * (-2.0 * (sqrt(1.0 / log(10.0)) * log(1.0 / im)));
}
return tmp;
}



Bits error versus re



Bits error versus im
Results
if im < 1.1776961076709698e-158Initial program 33.7
rmApplied add-sqr-sqrt_binary64_78233.7
Applied pow1/2_binary64_84033.7
Applied log-pow_binary64_84933.7
Applied times-frac_binary64_76633.7
Taylor expanded around -inf 5.2
if 1.1776961076709698e-158 < im < 9.7235115421466756e37Initial 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
rmApplied add-log-exp_binary64_79911.7
Simplified11.5
if 9.7235115421466756e37 < im < 5.57753584462511827e41Initial program 17.0
rmApplied add-sqr-sqrt_binary64_78217.0
Applied pow1/2_binary64_84017.0
Applied log-pow_binary64_84917.0
Applied times-frac_binary64_76617.0
rmApplied *-un-lft-identity_binary64_76017.0
Applied add-sqr-sqrt_binary64_78217.2
Applied times-frac_binary64_76617.0
Applied associate-*l*_binary64_70117.1
Simplified17.1
Taylor expanded around -inf 41.0
if 5.57753584462511827e41 < im Initial program 43.0
rmApplied add-sqr-sqrt_binary64_78243.0
Applied pow1/2_binary64_84043.0
Applied log-pow_binary64_84943.0
Applied times-frac_binary64_76642.9
Taylor expanded around inf 7.1
Final simplification7.5
herbie shell --seed 2021093
(FPCore (re im)
:name "math.log10 on complex, real part"
:precision binary64
(/ (log (sqrt (+ (* re re) (* im im)))) (log 10.0)))