\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.1460850084900386 \cdot 10^{+66}:\\
\;\;\;\;\frac{0.5}{\frac{\log base}{\log \left(\frac{-1}{re}\right) \cdot -2}}\\
\mathbf{elif}\;re \leq 9.280062418099048 \cdot 10^{+107}:\\
\;\;\;\;\frac{0.5}{\frac{\log base}{\log \left(\sqrt[3]{re \cdot re + im \cdot im}\right) + \log \left(\sqrt[3]{re \cdot re + im \cdot im}\right) \cdot 2}}\\
\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 -3.1460850084900386e+66)
(/ 0.5 (/ (log base) (* (log (/ -1.0 re)) -2.0)))
(if (<= re 9.280062418099048e+107)
(/
0.5
(/
(log base)
(+
(log (cbrt (+ (* re re) (* im im))))
(* (log (cbrt (+ (* re re) (* im im)))) 2.0))))
(/ (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 <= -3.1460850084900386e+66) {
tmp = 0.5 / (log(base) / (log(-1.0 / re) * -2.0));
} else if (re <= 9.280062418099048e+107) {
tmp = 0.5 / (log(base) / (log(cbrt((re * re) + (im * im))) + (log(cbrt((re * re) + (im * im))) * 2.0)));
} else {
tmp = log(re) / log(base);
}
return tmp;
}



Bits error versus re



Bits error versus im



Bits error versus base
Results
if re < -3.14608500849003864e66Initial program 46.1
Simplified46.1
rmApplied pow1/2_binary64_49146.1
Applied log-pow_binary64_50046.1
Applied associate-/l*_binary64_36146.1
Taylor expanded around -inf 10.7
Simplified10.7
if -3.14608500849003864e66 < re < 9.2800624180990482e107Initial program 21.9
Simplified21.8
rmApplied pow1/2_binary64_49121.8
Applied log-pow_binary64_50021.8
Applied associate-/l*_binary64_36121.9
rmApplied add-cube-cbrt_binary64_44621.9
Applied log-prod_binary64_49721.9
Simplified21.9
if 9.2800624180990482e107 < re Initial program 53.8
Simplified53.8
Taylor expanded around inf 8.7
Final simplification17.7
herbie shell --seed 2020281
(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))))