\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 -5.60563964591766 \cdot 10^{+43}:\\
\;\;\;\;\frac{\log \left(-re\right)}{\log base}\\
\mathbf{elif}\;re \leq -1.3795563888914072 \cdot 10^{-05}:\\
\;\;\;\;\frac{\log im}{\log base}\\
\mathbf{elif}\;re \leq -5.867956787373959 \cdot 10^{-35}:\\
\;\;\;\;\left(\sqrt[3]{\log \left(\sqrt{re \cdot re + im \cdot im}\right)} \cdot \sqrt[3]{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}\right) \cdot \frac{\sqrt[3]{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}}{\log base}\\
\mathbf{elif}\;re \leq -3.3543382104116615 \cdot 10^{-69} \lor \neg \left(re \leq -2.1704890792695045 \cdot 10^{-147}\right):\\
\;\;\;\;\frac{\log im}{\log base}\\
\mathbf{else}:\\
\;\;\;\;\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\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 -5.60563964591766e+43)
(/ (log (- re)) (log base))
(if (<= re -1.3795563888914072e-05)
(/ (log im) (log base))
(if (<= re -5.867956787373959e-35)
(*
(*
(cbrt (log (sqrt (+ (* re re) (* im im)))))
(cbrt (log (sqrt (+ (* re re) (* im im))))))
(/ (cbrt (log (sqrt (+ (* re re) (* im im))))) (log base)))
(if (or (<= re -3.3543382104116615e-69)
(not (<= re -2.1704890792695045e-147)))
(/ (log im) (log base))
(/ (log (sqrt (+ (* re re) (* im 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 <= -5.60563964591766e+43) {
tmp = log(-re) / log(base);
} else if (re <= -1.3795563888914072e-05) {
tmp = log(im) / log(base);
} else if (re <= -5.867956787373959e-35) {
tmp = (cbrt(log(sqrt((re * re) + (im * im)))) * cbrt(log(sqrt((re * re) + (im * im))))) * (cbrt(log(sqrt((re * re) + (im * im)))) / log(base));
} else if ((re <= -3.3543382104116615e-69) || !(re <= -2.1704890792695045e-147)) {
tmp = log(im) / log(base);
} else {
tmp = log(sqrt((re * re) + (im * im))) / log(base);
}
return tmp;
}



Bits error versus re



Bits error versus im



Bits error versus base
Results
if re < -5.60563964591766037e43Initial program 43.2
Simplified43.2
Taylor expanded around -inf 6.4
Simplified6.4
if -5.60563964591766037e43 < re < -1.37955638889140722e-5 or -5.86795678737395936e-35 < re < -3.35433821041166152e-69 or -2.1704890792695045e-147 < re Initial program 28.4
Simplified28.3
Taylor expanded around 0 11.6
if -1.37955638889140722e-5 < re < -5.86795678737395936e-35Initial program 12.6
Simplified12.5
rmApplied pow1_binary64_48012.5
Applied log-pow_binary64_50812.5
Applied add-cube-cbrt_binary64_45413.2
Applied times-frac_binary64_42513.2
if -3.35433821041166152e-69 < re < -2.1704890792695045e-147Initial program 10.4
Simplified10.3
Final simplification9.6
herbie shell --seed 2021093
(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))))