\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\begin{array}{l}
\mathbf{if}\;im \leq 2.2514151755340617 \cdot 10^{-166}:\\
\;\;\;\;\frac{\sqrt{0.5}}{\frac{\log 10}{\sqrt{0.5} \cdot \left(-2 \cdot \log \left(\frac{-1}{re}\right)\right)}}\\
\mathbf{elif}\;im \leq 2.3275519908472327 \cdot 10^{+131}:\\
\;\;\;\;\frac{\sqrt{0.5}}{\frac{\frac{\log 10}{\log \left(re \cdot re + im \cdot im\right)}}{\sqrt{0.5}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{0.5}}{\frac{\log 10}{\sqrt{0.5} \cdot \left(-2 \cdot \log \left(\frac{1}{im}\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 2.2514151755340617e-166)
(/ (sqrt 0.5) (/ (log 10.0) (* (sqrt 0.5) (* -2.0 (log (/ -1.0 re))))))
(if (<= im 2.3275519908472327e+131)
(/ (sqrt 0.5) (/ (/ (log 10.0) (log (+ (* re re) (* im im)))) (sqrt 0.5)))
(/ (sqrt 0.5) (/ (log 10.0) (* (sqrt 0.5) (* -2.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 <= 2.2514151755340617e-166) {
tmp = sqrt(0.5) / (log(10.0) / (sqrt(0.5) * (-2.0 * log(-1.0 / re))));
} else if (im <= 2.3275519908472327e+131) {
tmp = sqrt(0.5) / ((log(10.0) / log((re * re) + (im * im))) / sqrt(0.5));
} else {
tmp = sqrt(0.5) / (log(10.0) / (sqrt(0.5) * (-2.0 * log(1.0 / im))));
}
return tmp;
}



Bits error versus re



Bits error versus im
Results
if im < 2.2514151755340617e-166Initial program 33.8
rmApplied pow1/2_binary64_15833.8
Applied log-pow_binary64_16733.8
Applied associate-/l*_binary64_2333.8
rmApplied add-sqr-sqrt_binary64_10033.9
Applied associate-/l*_binary64_2333.7
Simplified33.7
Taylor expanded around -inf 4.6
if 2.2514151755340617e-166 < im < 2.32755199084723273e131Initial program 11.3
rmApplied pow1/2_binary64_15811.3
Applied log-pow_binary64_16711.3
Applied associate-/l*_binary64_2311.3
rmApplied add-sqr-sqrt_binary64_10011.5
Applied associate-/l*_binary64_2311.2
if 2.32755199084723273e131 < im Initial program 58.1
rmApplied pow1/2_binary64_15858.1
Applied log-pow_binary64_16758.1
Applied associate-/l*_binary64_2358.1
rmApplied add-sqr-sqrt_binary64_10058.2
Applied associate-/l*_binary64_2358.1
Simplified58.1
Taylor expanded around inf 4.5
Final simplification6.9
herbie shell --seed 2021044
(FPCore (re im)
:name "math.log10 on complex, real part"
:precision binary64
(/ (log (sqrt (+ (* re re) (* im im)))) (log 10.0)))