\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 -3.4367372751557022 \cdot 10^{+103}:\\
\;\;\;\;\frac{\log \left(-re\right)}{\log base}\\
\mathbf{elif}\;re \leq -1.1819915383869406 \cdot 10^{-181}:\\
\;\;\;\;\frac{\log \left(\left|\sqrt[3]{re \cdot re + im \cdot im}\right| \cdot \sqrt{\sqrt[3]{re \cdot re + im \cdot im}}\right)}{\log base}\\
\mathbf{elif}\;re \leq 8.172516521987715 \cdot 10^{-172}:\\
\;\;\;\;\frac{\log im}{\log base}\\
\mathbf{elif}\;re \leq 3.706762994210151 \cdot 10^{+72}:\\
\;\;\;\;\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log base}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{\log base} \cdot \left(2 \cdot \log re\right)\\
\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 -3.4367372751557022e+103)
(/ (log (- re)) (log base))
(if (<= re -1.1819915383869406e-181)
(/
(log
(*
(fabs (cbrt (+ (* re re) (* im im))))
(sqrt (cbrt (+ (* re re) (* im im))))))
(log base))
(if (<= re 8.172516521987715e-172)
(/ (log im) (log base))
(if (<= re 3.706762994210151e+72)
(/ (log (sqrt (+ (* re re) (* im im)))) (log base))
(* (/ 0.5 (log base)) (* 2.0 (log re))))))))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 <= -3.4367372751557022e+103) {
tmp = log(-re) / log(base);
} else if (re <= -1.1819915383869406e-181) {
tmp = log(fabs(cbrt((re * re) + (im * im))) * sqrt(cbrt((re * re) + (im * im)))) / log(base);
} else if (re <= 8.172516521987715e-172) {
tmp = log(im) / log(base);
} else if (re <= 3.706762994210151e+72) {
tmp = log(sqrt((re * re) + (im * im))) / log(base);
} else {
tmp = (0.5 / log(base)) * (2.0 * log(re));
}
return tmp;
}



Bits error versus re



Bits error versus im



Bits error versus base
Results
if re < -3.4367372751557022e103Initial program 52.5
Simplified52.5
Taylor expanded around -inf 8.9
Simplified8.9
if -3.4367372751557022e103 < re < -1.1819915383869406e-181Initial program 17.9
Simplified17.9
rmApplied add-cube-cbrt_binary64_45417.9
Applied sqrt-prod_binary64_43517.9
Simplified17.9
if -1.1819915383869406e-181 < re < 8.1725165219877145e-172Initial program 31.3
Simplified31.2
Taylor expanded around 0 33.6
if 8.1725165219877145e-172 < re < 3.7067629942101506e72Initial program 16.0
Simplified16.0
if 3.7067629942101506e72 < re Initial program 46.2
Simplified46.2
rmApplied pow1/2_binary64_49946.2
Applied log-pow_binary64_50846.2
Applied associate-/l*_binary64_36446.2
rmApplied associate-/r/_binary64_36546.2
Taylor expanded around inf 10.3
Simplified10.3
Final simplification17.9
herbie shell --seed 2020355
(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))))