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



Bits error versus re



Bits error versus im
Results
if re < -4.34354631906555476e132Initial program 58.5
rmApplied add-sqr-sqrt_binary64_10058.5
Applied pow1/2_binary64_15858.5
Applied log-pow_binary64_16758.5
Applied times-frac_binary64_8458.5
Taylor expanded around -inf 8.3
if -4.34354631906555476e132 < re < 2.5689374485974811e47Initial program 22.5
rmApplied add-sqr-sqrt_binary64_10022.5
Applied pow1/2_binary64_15822.5
Applied log-pow_binary64_16722.5
Applied times-frac_binary64_8422.4
rmApplied add-log-exp_binary64_11722.4
Simplified22.3
if 2.5689374485974811e47 < re Initial program 45.0
rmApplied add-sqr-sqrt_binary64_10045.0
Applied pow1/2_binary64_15845.0
Applied log-pow_binary64_16745.0
Applied times-frac_binary64_8445.0
Taylor expanded around inf 11.0
Simplified11.0
Final simplification17.8
herbie shell --seed 2020356
(FPCore (re im)
:name "math.log10 on complex, real part"
:precision binary64
(/ (log (sqrt (+ (* re re) (* im im)))) (log 10.0)))