\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 -2.445723404147339 \cdot 10^{+149}:\\
\;\;\;\;\frac{0.5}{\frac{\log base}{\log \left(\frac{-1}{re}\right) \cdot -2}}\\
\mathbf{elif}\;re \leq 8.305432065725839 \cdot 10^{+108}:\\
\;\;\;\;\frac{\log base \cdot \log \left(\sqrt{re \cdot re + im \cdot im}\right) + \tan^{-1}_* \frac{im}{re} \cdot 0}{\log base \cdot \log base}\\
\mathbf{else}:\\
\;\;\;\;\frac{\log re}{\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 -2.445723404147339e+149)
(/ 0.5 (/ (log base) (* (log (/ -1.0 re)) -2.0)))
(if (<= re 8.305432065725839e+108)
(/
(+
(* (log base) (log (sqrt (+ (* re re) (* im im)))))
(* (atan2 im re) 0.0))
(* (log base) (log base)))
(/ (log re) (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 <= -2.445723404147339e+149) {
tmp = 0.5 / (log(base) / (log(-1.0 / re) * -2.0));
} else if (re <= 8.305432065725839e+108) {
tmp = ((log(base) * log(sqrt((re * re) + (im * im)))) + (atan2(im, re) * 0.0)) / (log(base) * log(base));
} else {
tmp = log(re) / log(base);
}
return tmp;
}



Bits error versus re



Bits error versus im



Bits error versus base
Results
if re < -2.4457234041473391e149Initial program 62.5
Simplified62.5
rmApplied pow1/2_binary6462.5
Applied log-pow_binary6462.5
Applied associate-/l*_binary6462.5
Taylor expanded around -inf 6.7
Simplified6.7
if -2.4457234041473391e149 < re < 8.30543206572583891e108Initial program 21.6
if 8.30543206572583891e108 < re Initial program 53.0
Simplified53.0
Taylor expanded around inf 8.6
Final simplification17.6
herbie shell --seed 2020233
(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))))