\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 -2309443542.211869:\\
\;\;\;\;-\frac{\log \left(\frac{-1}{re}\right)}{\log base}\\
\mathbf{elif}\;re \leq 3.1078363892846655 \cdot 10^{+118}:\\
\;\;\;\;\frac{\log \left(\sqrt[3]{\sqrt{re \cdot re + im \cdot im}} \cdot \left(\sqrt[3]{\sqrt{re \cdot re + im \cdot im}} \cdot \sqrt[3]{\sqrt{re \cdot re + im \cdot im}}\right)\right)}{\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 -2309443542.211869)
(- (/ (log (/ -1.0 re)) (log base)))
(if (<= re 3.1078363892846655e+118)
(/
(log
(*
(cbrt (sqrt (+ (* re re) (* im im))))
(*
(cbrt (sqrt (+ (* re re) (* im im))))
(cbrt (sqrt (+ (* re re) (* im im)))))))
(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 <= -2309443542.211869) {
tmp = -(log(-1.0 / re) / log(base));
} else if (re <= 3.1078363892846655e+118) {
tmp = log(cbrt(sqrt((re * re) + (im * im))) * (cbrt(sqrt((re * re) + (im * im))) * cbrt(sqrt((re * re) + (im * im))))) / 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 < -2309443542.21186876Initial program 40.0
Simplified39.9
Taylor expanded around -inf 64.0
Simplified12.3
if -2309443542.21186876 < re < 3.10783638928466553e118Initial program 22.5
Simplified22.4
rmApplied add-cube-cbrt_binary6422.4
if 3.10783638928466553e118 < re Initial program 56.5
Simplified56.5
Taylor expanded around inf 8.8
Final simplification17.9
herbie shell --seed 2020232
(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))))