\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 5.022386159581915 \cdot 10^{-88}:\\
\;\;\;\;\frac{\log \left(-re\right)}{\log base}\\
\mathbf{elif}\;im \leq 2.710211708158825 \cdot 10^{+132}:\\
\;\;\;\;\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log base}\\
\mathbf{else}:\\
\;\;\;\;\frac{\log im}{\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 5.022386159581915e-88)
(/ (log (- re)) (log base))
(if (<= im 2.710211708158825e+132)
(/ (log (sqrt (+ (* re re) (* im im)))) (log base))
(/ (log 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 <= 5.022386159581915e-88) {
tmp = log(-re) / log(base);
} else if (im <= 2.710211708158825e+132) {
tmp = log(sqrt((re * re) + (im * im))) / log(base);
} else {
tmp = log(im) / log(base);
}
return tmp;
}



Bits error versus re



Bits error versus im



Bits error versus base
Results
if im < 5.02238615958191514e-88Initial program 30.1
Simplified30.0
Taylor expanded around -inf 8.2
Simplified8.2
if 5.02238615958191514e-88 < im < 2.71021170815882515e132Initial program 10.3
Simplified10.2
if 2.71021170815882515e132 < im Initial program 57.3
Simplified57.3
Taylor expanded around 0 4.4
Final simplification7.7
herbie shell --seed 2021058
(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))))