\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 -5.468069991666855 \cdot 10^{+134}:\\
\;\;\;\;\frac{\log \left(-re\right)}{\log base}\\
\mathbf{elif}\;re \leq -5.763545546578137 \cdot 10^{-161}:\\
\;\;\;\;\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 -5.468069991666855e+134)
(/ (log (- re)) (log base))
(if (<= re -5.763545546578137e-161)
(/ 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 <= -5.468069991666855e+134) {
tmp = log(-re) / log(base);
} else if (re <= -5.763545546578137e-161) {
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 < -5.46806999166685469e134Initial program 58.7
Simplified58.7
Taylor expanded around -inf 4.7
Simplified4.7
if -5.46806999166685469e134 < re < -5.76354554657813701e-161Initial program 11.4
Simplified11.3
rmApplied pow1/2_binary64_49911.3
Applied log-pow_binary64_50811.3
Applied associate-/l*_binary64_36411.4
if -5.76354554657813701e-161 < re Initial program 32.9
Simplified32.8
Taylor expanded around 0 5.2
Final simplification7.3
herbie shell --seed 2020358
(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))))