\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\begin{array}{l}
\mathbf{if}\;re \leq -2.8827138647577603 \cdot 10^{+149}:\\
\;\;\;\;\frac{0.5}{\frac{\log 10}{\log \left(\frac{-1}{re}\right) \cdot -2}}\\
\mathbf{elif}\;re \leq 1.5818348111842102 \cdot 10^{-202}:\\
\;\;\;\;\frac{\sqrt{0.5}}{\frac{\log 10}{\sqrt{0.5} \cdot \log \left(re \cdot re + im \cdot im\right)}}\\
\mathbf{elif}\;re \leq 8.96470249214571 \cdot 10^{-167}:\\
\;\;\;\;\frac{\log re}{\log 10}\\
\mathbf{elif}\;re \leq 8.602806491746828 \cdot 10^{+130}:\\
\;\;\;\;\sqrt{0.5} \cdot \frac{\sqrt{0.5}}{\frac{\log 10}{\log \left(re \cdot re + im \cdot im\right)}}\\
\mathbf{else}:\\
\;\;\;\;3 \cdot \frac{\log \left(\sqrt[3]{re}\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 -2.8827138647577603e+149)
(/ 0.5 (/ (log 10.0) (* (log (/ -1.0 re)) -2.0)))
(if (<= re 1.5818348111842102e-202)
(/ (sqrt 0.5) (/ (log 10.0) (* (sqrt 0.5) (log (+ (* re re) (* im im))))))
(if (<= re 8.96470249214571e-167)
(/ (log re) (log 10.0))
(if (<= re 8.602806491746828e+130)
(*
(sqrt 0.5)
(/ (sqrt 0.5) (/ (log 10.0) (log (+ (* re re) (* im im))))))
(* 3.0 (/ (log (cbrt 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 <= -2.8827138647577603e+149) {
tmp = 0.5 / (log(10.0) / (log(-1.0 / re) * -2.0));
} else if (re <= 1.5818348111842102e-202) {
tmp = sqrt(0.5) / (log(10.0) / (sqrt(0.5) * log((re * re) + (im * im))));
} else if (re <= 8.96470249214571e-167) {
tmp = log(re) / log(10.0);
} else if (re <= 8.602806491746828e+130) {
tmp = sqrt(0.5) * (sqrt(0.5) / (log(10.0) / log((re * re) + (im * im))));
} else {
tmp = 3.0 * (log(cbrt(re)) / log(10.0));
}
return tmp;
}



Bits error versus re



Bits error versus im
Results
if re < -2.8827138647577603e149Initial program 62.8
rmApplied pow1/2_binary64_84762.8
Applied log-pow_binary64_85662.8
Applied associate-/l*_binary64_71262.8
Taylor expanded around -inf 7.2
Simplified7.2
if -2.8827138647577603e149 < re < 1.5818348111842102e-202Initial program 22.9
rmApplied pow1/2_binary64_84722.9
Applied log-pow_binary64_85622.9
Applied associate-/l*_binary64_71222.9
rmApplied add-sqr-sqrt_binary64_78923.0
Applied associate-/l*_binary64_71222.8
Simplified22.8
if 1.5818348111842102e-202 < re < 8.9647024921457103e-167Initial program 32.9
Taylor expanded around inf 46.4
if 8.9647024921457103e-167 < re < 8.6028064917468283e130Initial program 16.1
rmApplied pow1/2_binary64_84716.1
Applied log-pow_binary64_85616.1
Applied associate-/l*_binary64_71216.1
rmApplied pow1_binary64_82816.1
Applied log-pow_binary64_85616.1
Applied pow1_binary64_82816.1
Applied log-pow_binary64_85616.1
Applied times-frac_binary64_77316.1
Applied add-sqr-sqrt_binary64_78916.2
Applied times-frac_binary64_77316.0
Simplified16.0
if 8.6028064917468283e130 < re Initial program 58.8
rmApplied add-cube-cbrt_binary64_80258.8
rmApplied pow1_binary64_82858.8
Applied log-pow_binary64_85658.8
Applied pow3_binary64_85058.8
Applied log-pow_binary64_85658.8
Applied times-frac_binary64_77358.8
Simplified58.8
Taylor expanded around inf 8.6
Final simplification17.6
herbie shell --seed 2020292
(FPCore (re im)
:name "math.log10 on complex, real part"
:precision binary64
(/ (log (sqrt (+ (* re re) (* im im)))) (log 10.0)))