\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0}{\log base \cdot \log base + 0 \cdot 0}\begin{array}{l}
\mathbf{if}\;im \leq 1.670968222443666 \cdot 10^{-197}:\\
\;\;\;\;\frac{\log \left(-re\right)}{\log base}\\
\mathbf{elif}\;im \leq 1.0164079588744982 \cdot 10^{-160}:\\
\;\;\;\;\frac{\log \left(im + 0.5 \cdot \frac{re \cdot re}{im}\right)}{\log base}\\
\mathbf{elif}\;im \leq 1.2659745474754468 \cdot 10^{+79}:\\
\;\;\;\;\frac{\log \left(\sqrt{e^{\log \left(re \cdot re + im \cdot im\right)}}\right)}{\log base}\\
\mathbf{else}:\\
\;\;\;\;-\frac{\log \left(\frac{1}{im}\right)}{\log base}\\
\end{array}(FPCore (re im base) :precision binary64 (/ (+ (* (log (sqrt (+ (* re re) (* im im)))) (log base)) (* (atan2 im re) 0.0)) (+ (* (log base) (log base)) (* 0.0 0.0))))
(FPCore (re im base)
:precision binary64
(if (<= im 1.670968222443666e-197)
(/ (log (- re)) (log base))
(if (<= im 1.0164079588744982e-160)
(/ (log (+ im (* 0.5 (/ (* re re) im)))) (log base))
(if (<= im 1.2659745474754468e+79)
(/ (log (sqrt (exp (log (+ (* re re) (* im im)))))) (log base))
(- (/ (log (/ 1.0 im)) (log base)))))))double code(double re, double im, double base) {
return ((log(sqrt((re * re) + (im * im))) * log(base)) + (atan2(im, re) * 0.0)) / ((log(base) * log(base)) + (0.0 * 0.0));
}
double code(double re, double im, double base) {
double tmp;
if (im <= 1.670968222443666e-197) {
tmp = log(-re) / log(base);
} else if (im <= 1.0164079588744982e-160) {
tmp = log(im + (0.5 * ((re * re) / im))) / log(base);
} else if (im <= 1.2659745474754468e+79) {
tmp = log(sqrt(exp(log((re * re) + (im * im))))) / log(base);
} else {
tmp = -(log(1.0 / im) / log(base));
}
return tmp;
}



Bits error versus re



Bits error versus im



Bits error versus base
Results
if im < 1.6709682224436661e-197Initial program 32.6
Simplified32.5
Taylor expanded around -inf 3.4
Simplified3.4
if 1.6709682224436661e-197 < im < 1.0164079588744982e-160Initial program 37.0
Simplified36.9
Taylor expanded around 0 38.7
Simplified38.7
if 1.0164079588744982e-160 < im < 1.2659745474754468e79Initial program 10.2
Simplified10.1
rmApplied add-exp-log_binary6410.1
if 1.2659745474754468e79 < im Initial program 47.7
Simplified47.7
Taylor expanded around inf 5.6
Final simplification7.2
herbie shell --seed 2021173
(FPCore (re im base)
:name "math.log/2 on complex, real part"
:precision binary64
(/ (+ (* (log (sqrt (+ (* re re) (* im im)))) (log base)) (* (atan2 im re) 0.0)) (+ (* (log base) (log base)) (* 0.0 0.0))))