\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\begin{array}{l}
\mathbf{if}\;re \leq -3.8588398939432175 \cdot 10^{+132}:\\
\;\;\;\;\sqrt{0.5} \cdot \frac{\sqrt{0.5}}{\frac{\log 10}{\log \left(\frac{-1}{re}\right) \cdot -2}}\\
\mathbf{elif}\;re \leq -4.2360820877371696 \cdot 10^{-235}:\\
\;\;\;\;\frac{0.5}{\sqrt{\log 10}} \cdot \left(\log \left(re \cdot re + im \cdot im\right) \cdot \frac{1}{\sqrt{\log 10}}\right)\\
\mathbf{elif}\;re \leq 2.1577752949736062 \cdot 10^{-187}:\\
\;\;\;\;\sqrt{0.5} \cdot \frac{\sqrt{0.5}}{\frac{\log 10}{2 \cdot \log im}}\\
\mathbf{elif}\;re \leq 1.2225237113435466 \cdot 10^{+30}:\\
\;\;\;\;\sqrt{\frac{0.5}{\sqrt{\log 10}}} \cdot \left(\sqrt{\frac{0.5}{\sqrt{\log 10}}} \cdot \frac{\log \left(re \cdot re + im \cdot im\right)}{\sqrt{\log 10}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{\sqrt{\log 10}} \cdot \frac{2 \cdot \log re}{\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 (<= re -3.8588398939432175e+132)
(* (sqrt 0.5) (/ (sqrt 0.5) (/ (log 10.0) (* (log (/ -1.0 re)) -2.0))))
(if (<= re -4.2360820877371696e-235)
(*
(/ 0.5 (sqrt (log 10.0)))
(* (log (+ (* re re) (* im im))) (/ 1.0 (sqrt (log 10.0)))))
(if (<= re 2.1577752949736062e-187)
(* (sqrt 0.5) (/ (sqrt 0.5) (/ (log 10.0) (* 2.0 (log im)))))
(if (<= re 1.2225237113435466e+30)
(*
(sqrt (/ 0.5 (sqrt (log 10.0))))
(*
(sqrt (/ 0.5 (sqrt (log 10.0))))
(/ (log (+ (* re re) (* im im))) (sqrt (log 10.0)))))
(*
(/ 0.5 (sqrt (log 10.0)))
(/ (* 2.0 (log re)) (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 (re <= -3.8588398939432175e+132) {
tmp = sqrt(0.5) * (sqrt(0.5) / (log(10.0) / (log(-1.0 / re) * -2.0)));
} else if (re <= -4.2360820877371696e-235) {
tmp = (0.5 / sqrt(log(10.0))) * (log((re * re) + (im * im)) * (1.0 / sqrt(log(10.0))));
} else if (re <= 2.1577752949736062e-187) {
tmp = sqrt(0.5) * (sqrt(0.5) / (log(10.0) / (2.0 * log(im))));
} else if (re <= 1.2225237113435466e+30) {
tmp = sqrt(0.5 / sqrt(log(10.0))) * (sqrt(0.5 / sqrt(log(10.0))) * (log((re * re) + (im * im)) / sqrt(log(10.0))));
} else {
tmp = (0.5 / sqrt(log(10.0))) * ((2.0 * log(re)) / sqrt(log(10.0)));
}
return tmp;
}



Bits error versus re



Bits error versus im
Results
if re < -3.8588398939432175e132Initial program 58.0
rmApplied add-sqr-sqrt_binary6458.0
Applied pow1/2_binary6458.0
Applied log-pow_binary6458.0
Applied times-frac_binary6458.0
rmApplied *-un-lft-identity_binary6458.0
Applied add-sqr-sqrt_binary6458.0
Applied times-frac_binary6458.0
Applied associate-*l*_binary6458.0
Simplified58.0
Taylor expanded around -inf 7.8
Simplified7.8
if -3.8588398939432175e132 < re < -4.23608208773716957e-235Initial program 19.2
rmApplied add-sqr-sqrt_binary6419.2
Applied pow1/2_binary6419.2
Applied log-pow_binary6419.2
Applied times-frac_binary6419.1
rmApplied div-inv_binary6419.0
if -4.23608208773716957e-235 < re < 2.15777529497360624e-187Initial program 33.1
rmApplied add-sqr-sqrt_binary6433.1
Applied pow1/2_binary6433.1
Applied log-pow_binary6433.1
Applied times-frac_binary6433.1
rmApplied *-un-lft-identity_binary6433.1
Applied add-sqr-sqrt_binary6433.1
Applied times-frac_binary6433.1
Applied associate-*l*_binary6433.0
Simplified33.0
Taylor expanded around 0 32.7
if 2.15777529497360624e-187 < re < 1.2225237113435466e30Initial program 17.8
rmApplied add-sqr-sqrt_binary6417.8
Applied pow1/2_binary6417.8
Applied log-pow_binary6417.8
Applied times-frac_binary6417.8
rmApplied add-sqr-sqrt_binary6417.8
Applied associate-*l*_binary6417.7
Simplified17.7
if 1.2225237113435466e30 < re Initial program 42.9
rmApplied add-sqr-sqrt_binary6442.9
Applied pow1/2_binary6442.9
Applied log-pow_binary6442.9
Applied times-frac_binary6442.9
Taylor expanded around inf 11.4
Simplified11.4
Final simplification17.8
herbie shell --seed 2020224
(FPCore (re im)
:name "math.log10 on complex, real part"
:precision binary64
(/ (log (sqrt (+ (* re re) (* im im)))) (log 10.0)))