\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\log base \cdot \log base + 0.0 \cdot 0.0}\begin{array}{l}
\mathbf{if}\;re \le -9.38679650841443355 \cdot 10^{100}:\\
\;\;\;\;\frac{\frac{\log \left(-1 \cdot re\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}\\
\mathbf{elif}\;re \le -1.8339980874230569 \cdot 10^{-192}:\\
\;\;\;\;\left(\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0\right) \cdot \frac{1}{\log base \cdot \log base + 0.0 \cdot 0.0}\\
\mathbf{elif}\;re \le -5.11232928655223888 \cdot 10^{-278}:\\
\;\;\;\;\frac{\log im}{\log base}\\
\mathbf{elif}\;re \le 1.27467538034503037 \cdot 10^{95}:\\
\;\;\;\;\left(\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0\right) \cdot \frac{1}{\log base \cdot \log base + 0.0 \cdot 0.0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\log \left(\frac{1}{re}\right)}{\log \left(\frac{1}{base}\right)}\\
\end{array}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 VAR;
if ((re <= -9.386796508414434e+100)) {
VAR = ((((log((-1.0 * re)) * log(base)) + (atan2(im, re) * 0.0)) / sqrt(((log(base) * log(base)) + (0.0 * 0.0)))) / sqrt(((log(base) * log(base)) + (0.0 * 0.0))));
} else {
double VAR_1;
if ((re <= -1.833998087423057e-192)) {
VAR_1 = (((log(sqrt(((re * re) + (im * im)))) * log(base)) + (atan2(im, re) * 0.0)) * (1.0 / ((log(base) * log(base)) + (0.0 * 0.0))));
} else {
double VAR_2;
if ((re <= -5.112329286552239e-278)) {
VAR_2 = (log(im) / log(base));
} else {
double VAR_3;
if ((re <= 1.2746753803450304e+95)) {
VAR_3 = (((log(sqrt(((re * re) + (im * im)))) * log(base)) + (atan2(im, re) * 0.0)) * (1.0 / ((log(base) * log(base)) + (0.0 * 0.0))));
} else {
VAR_3 = (log((1.0 / re)) / log((1.0 / base)));
}
VAR_2 = VAR_3;
}
VAR_1 = VAR_2;
}
VAR = VAR_1;
}
return VAR;
}



Bits error versus re



Bits error versus im



Bits error versus base
Results
if re < -9.386796508414434e+100Initial program 52.3
rmApplied add-sqr-sqrt52.3
Applied associate-/r*52.2
Taylor expanded around -inf 8.9
if -9.386796508414434e+100 < re < -1.833998087423057e-192 or -5.112329286552239e-278 < re < 1.2746753803450304e+95Initial program 19.7
rmApplied div-inv19.7
if -1.833998087423057e-192 < re < -5.112329286552239e-278Initial program 30.9
Taylor expanded around 0 34.7
if 1.2746753803450304e+95 < re Initial program 48.8
Taylor expanded around inf 8.7
Final simplification17.0
herbie shell --seed 2020092
(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))))