\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.6955531565480706 \cdot 10^{+118}:\\
\;\;\;\;\log \left(-re\right) \cdot \frac{1}{\log base}\\
\mathbf{elif}\;re \leq -1.801774026465648 \cdot 10^{-285}:\\
\;\;\;\;\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log base}\\
\mathbf{elif}\;re \leq 3.5257614717372405 \cdot 10^{-306}:\\
\;\;\;\;\frac{\log im}{\log base}\\
\mathbf{elif}\;re \leq 3447503664711254:\\
\;\;\;\;\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log base}\\
\mathbf{elif}\;re \leq 5.687874650979834 \cdot 10^{+56}:\\
\;\;\;\;\frac{1}{\log base} \cdot \log im\\
\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 -2.6955531565480706e+118)
(* (log (- re)) (/ 1.0 (log base)))
(if (<= re -1.801774026465648e-285)
(/ (log (sqrt (+ (* re re) (* im im)))) (log base))
(if (<= re 3.5257614717372405e-306)
(/ (log im) (log base))
(if (<= re 3447503664711254.0)
(/ (log (sqrt (+ (* re re) (* im im)))) (log base))
(if (<= re 5.687874650979834e+56)
(* (/ 1.0 (log base)) (log im))
(/ (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 <= -2.6955531565480706e+118) {
tmp = log(-re) * (1.0 / log(base));
} else if (re <= -1.801774026465648e-285) {
tmp = log(sqrt((re * re) + (im * im))) / log(base);
} else if (re <= 3.5257614717372405e-306) {
tmp = log(im) / log(base);
} else if (re <= 3447503664711254.0) {
tmp = log(sqrt((re * re) + (im * im))) / log(base);
} else if (re <= 5.687874650979834e+56) {
tmp = (1.0 / log(base)) * log(im);
} else {
tmp = log(re) / log(base);
}
return tmp;
}



Bits error versus re



Bits error versus im



Bits error versus base
Results
if re < -2.6955531565480706e118Initial program 55.5
Simplified55.5
rmApplied div-inv_binary64_42055.5
Taylor expanded around -inf 8.7
Simplified8.7
if -2.6955531565480706e118 < re < -1.801774026465648e-285 or 3.52576147173724054e-306 < re < 3447503664711254Initial program 21.7
Simplified21.6
if -1.801774026465648e-285 < re < 3.52576147173724054e-306Initial program 36.7
Simplified36.6
Taylor expanded around 0 32.8
if 3447503664711254 < re < 5.68787465097983412e56Initial program 18.2
Simplified18.1
rmApplied div-inv_binary64_42018.1
Taylor expanded around 0 47.8
if 5.68787465097983412e56 < re Initial program 46.3
Simplified46.3
Taylor expanded around inf 11.3
Final simplification18.7
herbie shell --seed 2020280
(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))))