\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\begin{array}{l}
\mathbf{if}\;re \leq -1.3312363646484332 \cdot 10^{+76}:\\
\;\;\;\;\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 -1.0550493251927753 \cdot 10^{-114}:\\
\;\;\;\;\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 -1.9775890958403967 \cdot 10^{-256}:\\
\;\;\;\;\frac{0.5}{\sqrt{\log 10}} \cdot \left(2 \cdot \left(\sqrt{\frac{1}{\log 10}} \cdot \log im\right)\right)\\
\mathbf{elif}\;re \leq 6.515608694411437 \cdot 10^{+115}:\\
\;\;\;\;\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}:\\
\;\;\;\;\frac{0.5}{\sqrt{\log 10}} \cdot \left(2 \cdot \left(\sqrt{\frac{1}{\log 10}} \cdot \log re\right)\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.3312363646484332e+76)
(*
(/ 0.5 (sqrt (log 10.0)))
(* -2.0 (* (log (/ -1.0 re)) (sqrt (/ 1.0 (log 10.0))))))
(if (<= re -1.0550493251927753e-114)
(*
(/ 0.5 (sqrt (log 10.0)))
(log (pow (+ (* re re) (* im im)) (/ 1.0 (sqrt (log 10.0))))))
(if (<= re -1.9775890958403967e-256)
(*
(/ 0.5 (sqrt (log 10.0)))
(* 2.0 (* (sqrt (/ 1.0 (log 10.0))) (log im))))
(if (<= re 6.515608694411437e+115)
(*
(/ 0.5 (sqrt (log 10.0)))
(log (pow (+ (* re re) (* im im)) (/ 1.0 (sqrt (log 10.0))))))
(*
(/ 0.5 (sqrt (log 10.0)))
(* 2.0 (* (sqrt (/ 1.0 (log 10.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.3312363646484332e+76) {
tmp = (0.5 / sqrt(log(10.0))) * (-2.0 * (log(-1.0 / re) * sqrt(1.0 / log(10.0))));
} else if (re <= -1.0550493251927753e-114) {
tmp = (0.5 / sqrt(log(10.0))) * log(pow(((re * re) + (im * im)), (1.0 / sqrt(log(10.0)))));
} else if (re <= -1.9775890958403967e-256) {
tmp = (0.5 / sqrt(log(10.0))) * (2.0 * (sqrt(1.0 / log(10.0)) * log(im)));
} else if (re <= 6.515608694411437e+115) {
tmp = (0.5 / sqrt(log(10.0))) * log(pow(((re * re) + (im * im)), (1.0 / sqrt(log(10.0)))));
} else {
tmp = (0.5 / sqrt(log(10.0))) * (2.0 * (sqrt(1.0 / log(10.0)) * log(re)));
}
return tmp;
}



Bits error versus re



Bits error versus im
Results
if re < -1.33123e76Initial program 47.2
rmApplied add-sqr-sqrt_binary6447.2
Applied pow1_binary6447.2
Applied sqrt-pow1_binary6447.2
Applied log-pow_binary6447.2
Applied times-frac_binary6447.2
Simplified47.2
Taylor expanded around -inf 9.7
if -1.33123e76 < re < -1.05506e-114 or -1.97759e-256 < re < 6.51562e115Initial program 21.4
rmApplied add-sqr-sqrt_binary6421.4
Applied pow1_binary6421.4
Applied sqrt-pow1_binary6421.4
Applied log-pow_binary6421.4
Applied times-frac_binary6421.4
Simplified21.4
rmApplied div-inv_binary6421.3
rmApplied add-log-exp_binary6421.3
Simplified21.2
if -1.05506e-114 < re < -1.97759e-256Initial program 28.8
rmApplied add-sqr-sqrt_binary6428.8
Applied pow1_binary6428.8
Applied sqrt-pow1_binary6428.8
Applied log-pow_binary6428.8
Applied times-frac_binary6428.8
Simplified28.8
Taylor expanded around 0 38.3
if 6.51562e115 < re Initial program 54.6
rmApplied add-sqr-sqrt_binary6454.6
Applied pow1_binary6454.6
Applied sqrt-pow1_binary6454.6
Applied log-pow_binary6454.6
Applied times-frac_binary6454.6
Simplified54.6
Taylor expanded around inf 7.7
Simplified7.7
Final simplification19.0
herbie shell --seed 2020231
(FPCore (re im)
:name "math.log10 on complex, real part"
:precision binary64
(/ (log (sqrt (+ (* re re) (* im im)))) (log 10.0)))