\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 -4.624380692152419 \cdot 10^{+91}:\\
\;\;\;\;\frac{\log \left(-re\right)}{\log base}\\
\mathbf{elif}\;re \leq 7.137942334441359 \cdot 10^{+124}:\\
\;\;\;\;\frac{\log \left(\sqrt{\sqrt{re \cdot re + im \cdot im}} \cdot \sqrt{\sqrt{re \cdot re + im \cdot im}}\right)}{\log base}\\
\mathbf{else}:\\
\;\;\;\;\log re \cdot \frac{1}{\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 -4.624380692152419e+91)
(/ (log (- re)) (log base))
(if (<= re 7.137942334441359e+124)
(/
(log
(*
(sqrt (sqrt (+ (* re re) (* im im))))
(sqrt (sqrt (+ (* re re) (* im im))))))
(log base))
(* (log re) (/ 1.0 (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 <= -4.624380692152419e+91) {
tmp = log(-re) / log(base);
} else if (re <= 7.137942334441359e+124) {
tmp = log(sqrt(sqrt((re * re) + (im * im))) * sqrt(sqrt((re * re) + (im * im)))) / log(base);
} else {
tmp = log(re) * (1.0 / log(base));
}
return tmp;
}



Bits error versus re



Bits error versus im



Bits error versus base
Results
if re < -4.62438069215241924e91Initial program 49.0
Simplified48.9
Taylor expanded around -inf 9.4
Simplified9.4
if -4.62438069215241924e91 < re < 7.1379423344413593e124Initial program 21.4
Simplified21.3
rmApplied add-sqr-sqrt_binary64_44121.3
if 7.1379423344413593e124 < re Initial program 56.5
Simplified56.5
rmApplied div-inv_binary64_41656.5
Taylor expanded around inf 8.1
Final simplification17.2
herbie shell --seed 2020354
(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))))