\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 -1.1064451278764455 \cdot 10^{+77}:\\
\;\;\;\;\log \left(\sqrt[3]{-re}\right) \cdot \frac{2}{\log base} + \log \left({\left(-re\right)}^{\left(\frac{0.3333333333333333}{\log base}\right)}\right)\\
\mathbf{elif}\;re \leq -3.2946587297450698 \cdot 10^{-115}:\\
\;\;\;\;\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\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 -1.1064451278764455e+77)
(+
(* (log (cbrt (- re))) (/ 2.0 (log base)))
(log (pow (- re) (/ 0.3333333333333333 (log base)))))
(if (<= re -3.2946587297450698e-115)
(/ (log (sqrt (+ (* 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 <= -1.1064451278764455e+77) {
tmp = (log(cbrt(-re)) * (2.0 / log(base))) + log(pow(-re, (0.3333333333333333 / log(base))));
} else if (re <= -3.2946587297450698e-115) {
tmp = log(sqrt((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 < -1.10644512787644547e77Initial program 47.0
Simplified47.0
Taylor expanded around -inf 5.7
Simplified5.7
rmApplied add-log-exp_binary645.8
Simplified5.8
rmApplied add-cube-cbrt_binary645.8
Applied unpow-prod-down_binary645.9
Applied log-prod_binary645.9
Simplified5.8
Simplified5.7
rmApplied add-log-exp_binary645.8
Simplified5.8
if -1.10644512787644547e77 < re < -3.2946587297450698e-115Initial program 10.9
Simplified10.8
rmApplied *-un-lft-identity_binary6410.8
if -3.2946587297450698e-115 < re Initial program 31.2
Simplified31.2
Taylor expanded around 0 7.0
Final simplification7.4
herbie shell --seed 2021175
(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))))