\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}\;re \leq -1.5791995229496047 \cdot 10^{+111}:\\
\;\;\;\;-\frac{\log \left(\frac{-1}{re}\right)}{\log base}\\
\mathbf{elif}\;re \leq -3.164913764562716 \cdot 10^{-110}:\\
\;\;\;\;\frac{0.5}{\frac{\log base}{\log \left(re \cdot re + im \cdot im\right)}}\\
\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 (<= re -1.5791995229496047e+111)
(- (/ (log (/ -1.0 re)) (log base)))
(if (<= re -3.164913764562716e-110)
(/ 0.5 (/ (log base) (log (+ (* re re) (* im im)))))
(/ (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 (re <= -1.5791995229496047e+111) {
tmp = -(log(-1.0 / re) / log(base));
} else if (re <= -3.164913764562716e-110) {
tmp = 0.5 / (log(base) / log((re * re) + (im * im)));
} else {
tmp = log(im) / log(base);
}
return tmp;
}



Bits error versus re



Bits error versus im



Bits error versus base
Results
if re < -1.57919952294960466e111Initial program 53.5
Simplified53.4
Taylor expanded around -inf 4.9
Simplified4.9
if -1.57919952294960466e111 < re < -3.16491376456271575e-110Initial program 11.3
Simplified11.2
rmApplied pow1/2_binary64_49911.2
Applied log-pow_binary64_50811.2
Applied associate-/l*_binary64_36411.3
if -3.16491376456271575e-110 < re Initial program 30.1
Simplified30.0
Taylor expanded around 0 8.0
Final simplification7.9
herbie shell --seed 2021060
(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))))