\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\begin{array}{l}
\mathbf{if}\;re \leq -6.320249547149809 \cdot 10^{+143}:\\
\;\;\;\;\frac{\log \left(-re\right)}{\log 10}\\
\mathbf{elif}\;re \leq -5.3392694545660306 \cdot 10^{-201}:\\
\;\;\;\;\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 1.062658705492185 \cdot 10^{-196}:\\
\;\;\;\;\frac{0.5}{\sqrt{\log 10}} \cdot \left(2 \cdot \left(\log im \cdot \sqrt{\frac{1}{\log 10}}\right)\right)\\
\mathbf{elif}\;re \leq 1.5937983800646182 \cdot 10^{+130}:\\
\;\;\;\;\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{else}:\\
\;\;\;\;\sqrt{\frac{0.5}{\sqrt{\log 10}}} \cdot \left(\sqrt{\frac{0.5}{\sqrt{\log 10}}} \cdot \frac{2 \cdot \log re}{\sqrt{\log 10}}\right)\\
\end{array}(FPCore (re im) :precision binary64 (/ (log (sqrt (+ (* re re) (* im im)))) (log 10.0)))
(FPCore (re im)
:precision binary64
(if (<= re -6.320249547149809e+143)
(/ (log (- re)) (log 10.0))
(if (<= re -5.3392694545660306e-201)
(*
(/ 0.5 (sqrt (log 10.0)))
(* (log (+ (* re re) (* im im))) (/ 1.0 (sqrt (log 10.0)))))
(if (<= re 1.062658705492185e-196)
(*
(/ 0.5 (sqrt (log 10.0)))
(* 2.0 (* (log im) (sqrt (/ 1.0 (log 10.0))))))
(if (<= re 1.5937983800646182e+130)
(*
(/ 0.5 (sqrt (log 10.0)))
(* (log (+ (* re re) (* im im))) (/ 1.0 (sqrt (log 10.0)))))
(*
(sqrt (/ 0.5 (sqrt (log 10.0))))
(*
(sqrt (/ 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 <= -6.320249547149809e+143) {
tmp = log(-re) / log(10.0);
} else if (re <= -5.3392694545660306e-201) {
tmp = (0.5 / sqrt(log(10.0))) * (log((re * re) + (im * im)) * (1.0 / sqrt(log(10.0))));
} else if (re <= 1.062658705492185e-196) {
tmp = (0.5 / sqrt(log(10.0))) * (2.0 * (log(im) * sqrt(1.0 / log(10.0))));
} else if (re <= 1.5937983800646182e+130) {
tmp = (0.5 / sqrt(log(10.0))) * (log((re * re) + (im * im)) * (1.0 / sqrt(log(10.0))));
} else {
tmp = sqrt(0.5 / sqrt(log(10.0))) * (sqrt(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 < -6.32024954714980922e143Initial program 61.7
Taylor expanded around -inf 7.6
Simplified7.6
if -6.32024954714980922e143 < re < -5.3392694545660306e-201 or 1.06265870549218496e-196 < re < 1.5937983800646182e130Initial program 18.3
rmApplied add-sqr-sqrt_binary6418.3
Applied pow1/2_binary6418.3
Applied log-pow_binary6418.3
Applied times-frac_binary6418.3
rmApplied div-inv_binary6418.2
if -5.3392694545660306e-201 < re < 1.06265870549218496e-196Initial program 32.7
rmApplied add-sqr-sqrt_binary6432.7
Applied pow1/2_binary6432.7
Applied log-pow_binary6432.7
Applied times-frac_binary6432.7
Taylor expanded around 0 33.7
if 1.5937983800646182e130 < re Initial program 58.3
rmApplied add-sqr-sqrt_binary6458.3
Applied pow1/2_binary6458.3
Applied log-pow_binary6458.3
Applied times-frac_binary6458.3
rmApplied add-sqr-sqrt_binary6458.3
Applied associate-*l*_binary6458.3
Simplified58.3
Taylor expanded around inf 8.9
Simplified8.9
Final simplification18.2
herbie shell --seed 2020219
(FPCore (re im)
:name "math.log10 on complex, real part"
:precision binary64
(/ (log (sqrt (+ (* re re) (* im im)))) (log 10.0)))