\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.756623360562739 \cdot 10^{+124}:\\
\;\;\;\;\frac{\log \left(-re\right)}{\log base}\\
\mathbf{elif}\;re \leq 3.955690204860042 \cdot 10^{+50}:\\
\;\;\;\;\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 -5.756623360562739e+124)
(/ (log (- re)) (log base))
(if (<= re 3.955690204860042e+50)
(/ (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 <= -5.756623360562739e+124) {
tmp = log(-re) / log(base);
} else if (re <= 3.955690204860042e+50) {
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 < -5.7566233605627392e124Initial program 57.0
Simplified57.0
Taylor expanded around -inf 7.9
Simplified7.9
if -5.7566233605627392e124 < re < 3.95569020486004164e50Initial program 21.8
Simplified21.7
if 3.95569020486004164e50 < re Initial program 44.5
Simplified44.5
rmApplied pow1/2_binary64_15844.5
Applied log-pow_binary64_16744.5
Applied associate-/l*_binary64_2344.5
rmApplied associate-/r/_binary64_2444.5
Taylor expanded around inf 11.7
Simplified11.7
Final simplification17.6
herbie shell --seed 2020356
(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))))