\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 4.322908374335732 \cdot 10^{-148}:\\
\;\;\;\;-\frac{\log \left(\frac{-1}{re}\right)}{\log base}\\
\mathbf{elif}\;im \leq 2.0625261815864652 \cdot 10^{+83}:\\
\;\;\;\;\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 4.322908374335732e-148)
(- (/ (log (/ -1.0 re)) (log base)))
(if (<= im 2.0625261815864652e+83)
(/ (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 <= 4.322908374335732e-148) {
tmp = -(log(-1.0 / re) / log(base));
} else if (im <= 2.0625261815864652e+83) {
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 < 4.32290837433573192e-148Initial program 31.4
Simplified31.3
Taylor expanded around -inf 5.3
Simplified5.3
if 4.32290837433573192e-148 < im < 2.0625261815864652e83Initial program 11.3
Simplified11.2
if 2.0625261815864652e83 < im Initial program 48.0
Simplified47.9
Taylor expanded around inf 5.7
Simplified5.7
Final simplification7.1
herbie shell --seed 2021098
(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))))