\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\begin{array}{l}
\mathbf{if}\;re \leq -1.2818911259175852 \cdot 10^{+112}:\\
\;\;\;\;\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 -8.924391194312242 \cdot 10^{-179}:\\
\;\;\;\;\frac{\frac{0.5}{\sqrt{\log 10}} \cdot \log \left(re \cdot re + im \cdot im\right)}{\sqrt{\log 10}}\\
\mathbf{elif}\;re \leq -1.4464803866898927 \cdot 10^{-220}:\\
\;\;\;\;\sqrt{0.5} \cdot \frac{\sqrt{0.5}}{\frac{\log 10}{-2 \cdot \log \left(\frac{-1}{re}\right)}}\\
\mathbf{elif}\;re \leq 4.4402811843754925 \cdot 10^{-292}:\\
\;\;\;\;\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 7.847390610675132 \cdot 10^{-242}:\\
\;\;\;\;\frac{0.5}{\sqrt{\log 10}} \cdot \frac{-2 \cdot \log \left(\frac{-1}{im}\right)}{\sqrt{\log 10}}\\
\mathbf{elif}\;re \leq 4.7489781145347514 \cdot 10^{-151}:\\
\;\;\;\;\frac{-1}{\frac{\log 10}{-\log im}}\\
\mathbf{elif}\;re \leq 1.1192013375802831 \cdot 10^{+108}:\\
\;\;\;\;\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}:\\
\;\;\;\;\sqrt{0.5} \cdot \frac{\sqrt{0.5}}{\frac{\log 10}{-2 \cdot \left(-\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.2818911259175852e+112)
(*
(/ 0.5 (sqrt (log 10.0)))
(* -2.0 (* (log (/ -1.0 re)) (sqrt (/ 1.0 (log 10.0))))))
(if (<= re -8.924391194312242e-179)
(/
(* (/ 0.5 (sqrt (log 10.0))) (log (+ (* re re) (* im im))))
(sqrt (log 10.0)))
(if (<= re -1.4464803866898927e-220)
(* (sqrt 0.5) (/ (sqrt 0.5) (/ (log 10.0) (* -2.0 (log (/ -1.0 re))))))
(if (<= re 4.4402811843754925e-292)
(*
(/ 0.5 (sqrt (log 10.0)))
(log (pow (+ (* re re) (* im im)) (/ 1.0 (sqrt (log 10.0))))))
(if (<= re 7.847390610675132e-242)
(*
(/ 0.5 (sqrt (log 10.0)))
(/ (* -2.0 (log (/ -1.0 im))) (sqrt (log 10.0))))
(if (<= re 4.7489781145347514e-151)
(/ -1.0 (/ (log 10.0) (- (log im))))
(if (<= re 1.1192013375802831e+108)
(*
(/ 0.5 (sqrt (log 10.0)))
(log (pow (+ (* re re) (* im im)) (/ 1.0 (sqrt (log 10.0))))))
(*
(sqrt 0.5)
(/ (sqrt 0.5) (/ (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 <= -1.2818911259175852e+112) {
tmp = (0.5 / sqrt(log(10.0))) * (-2.0 * (log(-1.0 / re) * sqrt(1.0 / log(10.0))));
} else if (re <= -8.924391194312242e-179) {
tmp = ((0.5 / sqrt(log(10.0))) * log((re * re) + (im * im))) / sqrt(log(10.0));
} else if (re <= -1.4464803866898927e-220) {
tmp = sqrt(0.5) * (sqrt(0.5) / (log(10.0) / (-2.0 * log(-1.0 / re))));
} else if (re <= 4.4402811843754925e-292) {
tmp = (0.5 / sqrt(log(10.0))) * log(pow(((re * re) + (im * im)), (1.0 / sqrt(log(10.0)))));
} else if (re <= 7.847390610675132e-242) {
tmp = (0.5 / sqrt(log(10.0))) * ((-2.0 * log(-1.0 / im)) / sqrt(log(10.0)));
} else if (re <= 4.7489781145347514e-151) {
tmp = -1.0 / (log(10.0) / -log(im));
} else if (re <= 1.1192013375802831e+108) {
tmp = (0.5 / sqrt(log(10.0))) * log(pow(((re * re) + (im * im)), (1.0 / sqrt(log(10.0)))));
} else {
tmp = sqrt(0.5) * (sqrt(0.5) / (log(10.0) / (-2.0 * -log(re))));
}
return tmp;
}



Bits error versus re



Bits error versus im
Results
if re < -1.2818911259175852e112Initial program 53.9
rmApplied add-sqr-sqrt_binary64_10053.9
Applied pow1/2_binary64_15853.9
Applied log-pow_binary64_16753.9
Applied times-frac_binary64_8453.9
Taylor expanded around -inf 8.4
if -1.2818911259175852e112 < re < -8.9243911943122418e-179Initial program 16.4
rmApplied add-sqr-sqrt_binary64_10016.4
Applied pow1/2_binary64_15816.4
Applied log-pow_binary64_16716.4
Applied times-frac_binary64_8416.4
rmApplied associate-*l/_binary64_2116.6
Simplified16.4
if -8.9243911943122418e-179 < re < -1.4464803866898927e-220Initial program 35.3
rmApplied add-sqr-sqrt_binary64_10035.3
Applied pow1/2_binary64_15835.3
Applied log-pow_binary64_16735.3
Applied times-frac_binary64_8435.3
rmApplied *-un-lft-identity_binary64_7835.3
Applied add-sqr-sqrt_binary64_10035.2
Applied times-frac_binary64_8435.3
Applied associate-*l*_binary64_1935.2
Simplified35.1
Taylor expanded around -inf 46.8
if -1.4464803866898927e-220 < re < 4.44028118437549247e-292 or 4.7489781145347514e-151 < re < 1.119201337580283e108Initial program 19.4
rmApplied add-sqr-sqrt_binary64_10019.4
Applied pow1/2_binary64_15819.4
Applied log-pow_binary64_16719.4
Applied times-frac_binary64_8419.4
rmApplied add-log-exp_binary64_11719.4
Simplified19.2
if 4.44028118437549247e-292 < re < 7.8473906106751324e-242Initial program 31.8
rmApplied add-sqr-sqrt_binary64_10031.8
Applied pow1/2_binary64_15831.8
Applied log-pow_binary64_16731.8
Applied times-frac_binary64_8431.7
Taylor expanded around -inf 29.6
if 7.8473906106751324e-242 < re < 4.7489781145347514e-151Initial program 29.1
rmApplied add-sqr-sqrt_binary64_10029.1
Applied pow1/2_binary64_15829.1
Applied log-pow_binary64_16729.1
Applied times-frac_binary64_8429.1
rmApplied *-un-lft-identity_binary64_7829.1
Applied add-sqr-sqrt_binary64_10029.1
Applied times-frac_binary64_8429.1
Applied associate-*l*_binary64_1929.1
Simplified29.1
Taylor expanded around inf 36.0
Simplified35.9
if 1.119201337580283e108 < re Initial program 53.7
rmApplied add-sqr-sqrt_binary64_10053.7
Applied pow1/2_binary64_15853.7
Applied log-pow_binary64_16753.7
Applied times-frac_binary64_8453.7
rmApplied *-un-lft-identity_binary64_7853.7
Applied add-sqr-sqrt_binary64_10053.7
Applied times-frac_binary64_8453.7
Applied associate-*l*_binary64_1953.7
Simplified53.7
Taylor expanded around inf 7.9
Simplified7.9
Final simplification17.5
herbie shell --seed 2021009
(FPCore (re im)
:name "math.log10 on complex, real part"
:precision binary64
(/ (log (sqrt (+ (* re re) (* im im)))) (log 10.0)))