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



Bits error versus re



Bits error versus im
Results
if im < -7.0612851589288723e113Initial program 53.3
rmApplied add-sqr-sqrt_binary64_78253.3
Applied pow1/2_binary64_84053.3
Applied log-pow_binary64_84953.3
Applied times-frac_binary64_76653.3
Taylor expanded around -inf 8.8
if -7.0612851589288723e113 < im < -5.53516943454073139e-301 or 3.643016007571221e-180 < im < 5.1795402224441176e90Initial program 19.8
rmApplied add-sqr-sqrt_binary64_78219.8
Applied pow1/2_binary64_84019.8
Applied log-pow_binary64_84919.8
Applied times-frac_binary64_76619.8
rmApplied add-log-exp_binary64_79919.8
Simplified19.6
if -5.53516943454073139e-301 < im < 3.643016007571221e-180Initial program 32.7
rmApplied add-sqr-sqrt_binary64_78232.7
Applied pow1/2_binary64_84032.7
Applied log-pow_binary64_84932.7
Applied times-frac_binary64_76632.7
Taylor expanded around -inf 33.8
if 5.1795402224441176e90 < im Initial program 50.4
rmApplied add-sqr-sqrt_binary64_78250.4
Applied pow1/2_binary64_84050.4
Applied log-pow_binary64_84950.4
Applied times-frac_binary64_76650.4
Taylor expanded around inf 9.3
Final simplification17.7
herbie shell --seed 2021022
(FPCore (re im)
:name "math.log10 on complex, real part"
:precision binary64
(/ (log (sqrt (+ (* re re) (* im im)))) (log 10.0)))