\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.849551058941963 \cdot 10^{+146}:\\
\;\;\;\;\log \left(e^{-\frac{\log \left(\frac{-1}{re}\right)}{\log base}}\right)\\
\mathbf{elif}\;re \leq -1.0647680349542202 \cdot 10^{-112}:\\
\;\;\;\;\frac{\log \left(\sqrt{\sqrt[3]{re \cdot re + im \cdot im} \cdot \left(\sqrt[3]{re \cdot re + im \cdot im} \cdot \sqrt[3]{re \cdot re + im \cdot im}\right)}\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 (<= re -2.849551058941963e+146)
(log (exp (- (/ (log (/ -1.0 re)) (log base)))))
(if (<= re -1.0647680349542202e-112)
(/
(log
(sqrt
(*
(cbrt (+ (* re re) (* im im)))
(* (cbrt (+ (* re re) (* im im))) (cbrt (+ (* 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 (re <= -2.849551058941963e+146) {
tmp = log(exp(-(log(-1.0 / re) / log(base))));
} else if (re <= -1.0647680349542202e-112) {
tmp = log(sqrt(cbrt((re * re) + (im * im)) * (cbrt((re * re) + (im * im)) * cbrt((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 re < -2.84955105894196315e146Initial program 62.2
Simplified62.2
Taylor expanded around -inf 4.2
Simplified4.2
rmApplied add-log-exp_binary644.3
Simplified4.3
Taylor expanded around -inf 4.3
if -2.84955105894196315e146 < re < -1.0647680349542202e-112Initial program 10.9
Simplified10.8
rmApplied add-cube-cbrt_binary6410.9
if -1.0647680349542202e-112 < re Initial program 30.0
Simplified30.0
Taylor expanded around 0 7.8
Final simplification7.9
herbie shell --seed 2021174
(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))))