\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 -4.086587529535461 \cdot 10^{+152}:\\
\;\;\;\;\frac{\log \left(-re\right)}{\log base}\\
\mathbf{elif}\;re \leq -8.450912480685567 \cdot 10^{-150}:\\
\;\;\;\;\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log base}\\
\mathbf{else}:\\
\;\;\;\;\frac{\log \left(im + 0.5 \cdot \left(\left(re \cdot \frac{\sqrt[3]{re} \cdot \sqrt[3]{re}}{\sqrt{im}}\right) \cdot \frac{\sqrt[3]{re}}{\sqrt{im}}\right)\right)}{\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 -4.086587529535461e+152)
(/ (log (- re)) (log base))
(if (<= re -8.450912480685567e-150)
(/ (log (sqrt (+ (* re re) (* im im)))) (log base))
(/
(log
(+
im
(*
0.5
(*
(* re (/ (* (cbrt re) (cbrt re)) (sqrt im)))
(/ (cbrt re) (sqrt 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 <= -4.086587529535461e+152) {
tmp = log(-re) / log(base);
} else if (re <= -8.450912480685567e-150) {
tmp = log(sqrt((re * re) + (im * im))) / log(base);
} else {
tmp = log(im + (0.5 * ((re * ((cbrt(re) * cbrt(re)) / sqrt(im))) * (cbrt(re) / sqrt(im))))) / log(base);
}
return tmp;
}



Bits error versus re



Bits error versus im



Bits error versus base
Results
if re < -4.0865875295354609e152Initial program 63.6
Simplified63.6
Taylor expanded around -inf 4.4
if -4.0865875295354609e152 < re < -8.45091248068556667e-150Initial program 10.4
Simplified10.3
if -8.45091248068556667e-150 < re Initial program 33.2
Simplified33.2
Taylor expanded around 0 8.2
Simplified8.2
rmApplied *-un-lft-identity_binary648.2
Applied times-frac_binary645.4
Simplified5.4
rmApplied add-sqr-sqrt_binary645.4
Applied add-cube-cbrt_binary645.4
Applied times-frac_binary645.4
Applied associate-*r*_binary645.6
Final simplification7.0
herbie shell --seed 2021176
(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))))