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



Bits error versus re



Bits error versus im
Results
if re < -1.0759262699953573e106Initial program 53.4
rmApplied pow1/2_binary64_15853.4
Applied log-pow_binary64_16753.4
Applied associate-/l*_binary64_2353.4
rmApplied add-sqr-sqrt_binary64_10053.4
Applied associate-/l*_binary64_2353.3
Simplified53.3
Taylor expanded around -inf 8.2
Simplified8.2
if -1.0759262699953573e106 < re < 8.16944547209966887e99Initial program 21.6
rmApplied pow1/2_binary64_15821.6
Applied log-pow_binary64_16721.6
Applied associate-/l*_binary64_2321.6
rmApplied add-sqr-sqrt_binary64_10021.7
Applied associate-/l*_binary64_2321.5
Simplified21.5
rmApplied add-log-exp_binary64_11721.5
Simplified21.5
if 8.16944547209966887e99 < re Initial program 50.6
rmApplied pow1/2_binary64_15850.6
Applied log-pow_binary64_16750.6
Applied associate-/l*_binary64_2350.6
rmApplied add-sqr-sqrt_binary64_10050.6
Applied associate-/l*_binary64_2350.5
Simplified50.5
Taylor expanded around inf 8.4
Simplified8.4
Final simplification17.1
herbie shell --seed 2020355
(FPCore (re im)
:name "math.log10 on complex, real part"
:precision binary64
(/ (log (sqrt (+ (* re re) (* im im)))) (log 10.0)))