\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 -1.0734375848046968 \cdot 10^{+70}:\\
\;\;\;\;\frac{\log \left(-re\right)}{\log base}\\
\mathbf{elif}\;re \leq -1.6582413586913936 \cdot 10^{-215}:\\
\;\;\;\;\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log base}\\
\mathbf{elif}\;re \leq -7.901868561004965 \cdot 10^{-300}:\\
\;\;\;\;\frac{\log \left(im + 0.5 \cdot \frac{re}{\frac{im}{re}}\right)}{\log base}\\
\mathbf{elif}\;re \leq 5.814525713456844 \cdot 10^{+84}:\\
\;\;\;\;\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log base}\\
\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 -1.0734375848046968e+70)
(/ (log (- re)) (log base))
(if (<= re -1.6582413586913936e-215)
(/ (log (sqrt (+ (* re re) (* im im)))) (log base))
(if (<= re -7.901868561004965e-300)
(/ (log (+ im (* 0.5 (/ re (/ im re))))) (log base))
(if (<= re 5.814525713456844e+84)
(/ (log (sqrt (+ (* re re) (* im im)))) (log base))
(/ (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 <= -1.0734375848046968e+70) {
tmp = log(-re) / log(base);
} else if (re <= -1.6582413586913936e-215) {
tmp = log(sqrt((re * re) + (im * im))) / log(base);
} else if (re <= -7.901868561004965e-300) {
tmp = log(im + (0.5 * (re / (im / re)))) / log(base);
} else if (re <= 5.814525713456844e+84) {
tmp = log(sqrt((re * re) + (im * im))) / log(base);
} else {
tmp = log(re) / log(base);
}
return tmp;
}



Bits error versus re



Bits error versus im



Bits error versus base
Results
if re < -1.07343758480469678e70Initial program 47.3
Simplified47.2
Taylor expanded around -inf 10.3
if -1.07343758480469678e70 < re < -1.6582413586913936e-215 or -7.9018685610049649e-300 < re < 5.8145257134568444e84Initial program 21.7
Simplified21.6
if -1.6582413586913936e-215 < re < -7.9018685610049649e-300Initial program 32.9
Simplified32.9
Taylor expanded around 0 36.0
Simplified35.9
if 5.8145257134568444e84 < re Initial program 49.4
Simplified49.3
Taylor expanded around inf 11.3
Simplified11.3
Final simplification18.5
herbie shell --seed 2021176
(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))))