\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log 10}\begin{array}{l}
\mathbf{if}\;re \leq -5.192603281076975 \cdot 10^{+93}:\\
\;\;\;\;\sqrt{\frac{1}{\sqrt{\log 10} \cdot 2}} \cdot \left(-2 \cdot \left(\left(\sqrt{0.5} \cdot \log \left(\frac{-1}{re}\right)\right) \cdot {\left(\frac{1}{{\log 10}^{3}}\right)}^{0.25}\right)\right)\\
\mathbf{elif}\;re \leq -2.8031941910929914 \cdot 10^{-216}:\\
\;\;\;\;\frac{1}{\sqrt{\log 10} \cdot 2} \cdot \left(\log \left(re \cdot re + im \cdot im\right) \cdot \frac{1}{\sqrt{\log 10}}\right)\\
\mathbf{elif}\;re \leq 1.906370662006563 \cdot 10^{-105}:\\
\;\;\;\;\frac{1}{\sqrt{\log 10} \cdot 2} \cdot \left(\left(2 \cdot \log im\right) \cdot \sqrt{\frac{1}{\log 10}}\right)\\
\mathbf{elif}\;re \leq 3.164209138874086 \cdot 10^{+97}:\\
\;\;\;\;\frac{1}{\sqrt{\log 10} \cdot 2} \cdot \left(\log \left(re \cdot re + im \cdot im\right) \cdot \frac{1}{\sqrt{\log 10}}\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{1}{\sqrt{\log 10} \cdot 2}} \cdot \left(\sqrt{\frac{1}{\sqrt{\log 10} \cdot 2}} \cdot \frac{-2 \cdot \log \left(\frac{1}{re}\right)}{\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 -5.192603281076975e+93)
(*
(sqrt (/ 1.0 (* (sqrt (log 10.0)) 2.0)))
(*
-2.0
(*
(* (sqrt 0.5) (log (/ -1.0 re)))
(pow (/ 1.0 (pow (log 10.0) 3.0)) 0.25))))
(if (<= re -2.8031941910929914e-216)
(*
(/ 1.0 (* (sqrt (log 10.0)) 2.0))
(* (log (+ (* re re) (* im im))) (/ 1.0 (sqrt (log 10.0)))))
(if (<= re 1.906370662006563e-105)
(*
(/ 1.0 (* (sqrt (log 10.0)) 2.0))
(* (* 2.0 (log im)) (sqrt (/ 1.0 (log 10.0)))))
(if (<= re 3.164209138874086e+97)
(*
(/ 1.0 (* (sqrt (log 10.0)) 2.0))
(* (log (+ (* re re) (* im im))) (/ 1.0 (sqrt (log 10.0)))))
(*
(sqrt (/ 1.0 (* (sqrt (log 10.0)) 2.0)))
(*
(sqrt (/ 1.0 (* (sqrt (log 10.0)) 2.0)))
(/ (* -2.0 (log (/ 1.0 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 <= -5.192603281076975e+93) {
tmp = sqrt(1.0 / (sqrt(log(10.0)) * 2.0)) * (-2.0 * ((sqrt(0.5) * log(-1.0 / re)) * pow((1.0 / pow(log(10.0), 3.0)), 0.25)));
} else if (re <= -2.8031941910929914e-216) {
tmp = (1.0 / (sqrt(log(10.0)) * 2.0)) * (log((re * re) + (im * im)) * (1.0 / sqrt(log(10.0))));
} else if (re <= 1.906370662006563e-105) {
tmp = (1.0 / (sqrt(log(10.0)) * 2.0)) * ((2.0 * log(im)) * sqrt(1.0 / log(10.0)));
} else if (re <= 3.164209138874086e+97) {
tmp = (1.0 / (sqrt(log(10.0)) * 2.0)) * (log((re * re) + (im * im)) * (1.0 / sqrt(log(10.0))));
} else {
tmp = sqrt(1.0 / (sqrt(log(10.0)) * 2.0)) * (sqrt(1.0 / (sqrt(log(10.0)) * 2.0)) * ((-2.0 * log(1.0 / re)) / sqrt(log(10.0))));
}
return tmp;
}



Bits error versus re



Bits error versus im
Results
if re < -5.19260328107697459e93Initial program 49.3
rmApplied add-sqr-sqrt_binary64_78249.3
Applied pow1_binary64_82149.3
Applied sqrt-pow1_binary64_77849.3
Applied log-pow_binary64_84949.3
Applied times-frac_binary64_76649.3
Simplified49.3
rmApplied add-sqr-sqrt_binary64_78249.3
Applied associate-*l*_binary64_70149.2
Simplified49.2
Taylor expanded around -inf 9.3
if -5.19260328107697459e93 < re < -2.8031941910929914e-216 or 1.90637066200656318e-105 < re < 3.1642091388740861e97Initial program 17.5
rmApplied add-sqr-sqrt_binary64_78217.5
Applied pow1_binary64_82117.5
Applied sqrt-pow1_binary64_77817.5
Applied log-pow_binary64_84917.5
Applied times-frac_binary64_76617.5
Simplified17.5
rmApplied div-inv_binary64_75717.4
if -2.8031941910929914e-216 < re < 1.90637066200656318e-105Initial program 28.3
rmApplied add-sqr-sqrt_binary64_78228.3
Applied pow1_binary64_82128.3
Applied sqrt-pow1_binary64_77828.3
Applied log-pow_binary64_84928.3
Applied times-frac_binary64_76628.3
Simplified28.3
Taylor expanded around 0 31.4
Simplified35.1
if 3.1642091388740861e97 < re Initial program 51.8
rmApplied add-sqr-sqrt_binary64_78251.8
Applied pow1_binary64_82151.8
Applied sqrt-pow1_binary64_77851.8
Applied log-pow_binary64_84951.8
Applied times-frac_binary64_76651.8
Simplified51.8
rmApplied add-sqr-sqrt_binary64_78251.8
Applied associate-*l*_binary64_70151.8
Simplified51.8
Taylor expanded around inf 9.3
Final simplification18.8
herbie shell --seed 2021176
(FPCore (re im)
:name "math.log10 on complex, real part"
:precision binary64
(/ (log (sqrt (+ (* re re) (* im im)))) (log 10.0)))