\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\begin{array}{l}
\mathbf{if}\;re \leq -6.278604197488825 \cdot 10^{+103}:\\
\;\;\;\;\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 -1.5790382649926146 \cdot 10^{-307}:\\
\;\;\;\;\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{elif}\;re \leq 6.0245846924273985 \cdot 10^{-220}:\\
\;\;\;\;\sqrt{0.5} \cdot \frac{\sqrt{0.5}}{\frac{\log 10}{2 \cdot \log im}}\\
\mathbf{elif}\;re \leq 1.2668046021614768 \cdot 10^{+48}:\\
\;\;\;\;\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(\sqrt{\frac{1}{\log 10}} \cdot \left(2 \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 -6.278604197488825e+103)
(*
(/ 0.5 (sqrt (log 10.0)))
(* -2.0 (* (log (/ -1.0 re)) (sqrt (/ 1.0 (log 10.0))))))
(if (<= re -1.5790382649926146e-307)
(*
(/ 0.5 (sqrt (log 10.0)))
(log (pow (+ (* re re) (* im im)) (/ 1.0 (sqrt (log 10.0))))))
(if (<= re 6.0245846924273985e-220)
(* (sqrt 0.5) (/ (sqrt 0.5) (/ (log 10.0) (* 2.0 (log im)))))
(if (<= re 1.2668046021614768e+48)
(*
(/ 0.5 (sqrt (log 10.0)))
(log (pow (+ (* re re) (* im im)) (/ 1.0 (sqrt (log 10.0))))))
(*
(/ 0.5 (sqrt (log 10.0)))
(* (sqrt (/ 1.0 (log 10.0))) (* 2.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 <= -6.278604197488825e+103) {
tmp = (0.5 / sqrt(log(10.0))) * (-2.0 * (log(-1.0 / re) * sqrt(1.0 / log(10.0))));
} else if (re <= -1.5790382649926146e-307) {
tmp = (0.5 / sqrt(log(10.0))) * log(pow(((re * re) + (im * im)), (1.0 / sqrt(log(10.0)))));
} else if (re <= 6.0245846924273985e-220) {
tmp = sqrt(0.5) * (sqrt(0.5) / (log(10.0) / (2.0 * log(im))));
} else if (re <= 1.2668046021614768e+48) {
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))) * (sqrt(1.0 / log(10.0)) * (2.0 * log(re)));
}
return tmp;
}



Bits error versus re



Bits error versus im
Results
if re < -6.2786041974888246e103Initial program 52.2
rmApplied add-sqr-sqrt_binary64_78252.2
Applied pow1/2_binary64_84052.2
Applied log-pow_binary64_84952.2
Applied times-frac_binary64_76652.2
Taylor expanded around -inf 8.7
if -6.2786041974888246e103 < re < -1.5790382649926146e-307 or 6.0245846924273985e-220 < re < 1.2668046021614768e48Initial program 20.7
rmApplied add-sqr-sqrt_binary64_78220.7
Applied pow1/2_binary64_84020.7
Applied log-pow_binary64_84920.7
Applied times-frac_binary64_76620.7
rmApplied add-log-exp_binary64_79920.7
Simplified20.5
if -1.5790382649926146e-307 < re < 6.0245846924273985e-220Initial program 29.7
rmApplied add-sqr-sqrt_binary64_78229.7
Applied pow1/2_binary64_84029.7
Applied log-pow_binary64_84929.7
Applied times-frac_binary64_76629.7
rmApplied *-un-lft-identity_binary64_76029.7
Applied add-sqr-sqrt_binary64_78229.8
Applied times-frac_binary64_76629.7
Applied associate-*l*_binary64_70129.6
Simplified29.7
Taylor expanded around 0 36.1
if 1.2668046021614768e48 < re Initial program 46.4
rmApplied add-sqr-sqrt_binary64_78246.4
Applied pow1/2_binary64_84046.4
Applied log-pow_binary64_84946.4
Applied times-frac_binary64_76646.4
Taylor expanded around inf 12.3
Simplified12.3
Final simplification18.0
herbie shell --seed 2020342
(FPCore (re im)
:name "math.log10 on complex, real part"
:precision binary64
(/ (log (sqrt (+ (* re re) (* im im)))) (log 10.0)))