\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 -1.82014315131001227 \cdot 10^{121}:\\
\;\;\;\;\frac{\log \left(-1 \cdot re\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\log base \cdot \log base + 0.0 \cdot 0.0}\\
\mathbf{elif}\;re \le -8.1232485912120391 \cdot 10^{-303}:\\
\;\;\;\;\frac{1}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}} \cdot \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}\\
\mathbf{elif}\;re \le 6.7545363965455156 \cdot 10^{-163}:\\
\;\;\;\;\frac{\log im}{\log base}\\
\mathbf{elif}\;re \le 7.2813928336898266 \cdot 10^{80}:\\
\;\;\;\;\frac{1}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}} \cdot \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\log \left(\frac{1}{re}\right) \cdot \log \left(\frac{1}{base}\right) + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\log base \cdot \log base + 0.0 \cdot 0.0}\\
\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 <= -1.8201431513100123e+121)) {
VAR = (((log((-1.0 * re)) * log(base)) + (atan2(im, re) * 0.0)) / ((log(base) * log(base)) + (0.0 * 0.0)));
} else {
double VAR_1;
if ((re <= -8.123248591212039e-303)) {
VAR_1 = ((1.0 / sqrt(((log(base) * log(base)) + (0.0 * 0.0)))) * (((log(sqrt(((re * re) + (im * im)))) * log(base)) + (atan2(im, re) * 0.0)) / sqrt(((log(base) * log(base)) + (0.0 * 0.0)))));
} else {
double VAR_2;
if ((re <= 6.754536396545516e-163)) {
VAR_2 = (log(im) / log(base));
} else {
double VAR_3;
if ((re <= 7.281392833689827e+80)) {
VAR_3 = ((1.0 / sqrt(((log(base) * log(base)) + (0.0 * 0.0)))) * (((log(sqrt(((re * re) + (im * im)))) * log(base)) + (atan2(im, re) * 0.0)) / sqrt(((log(base) * log(base)) + (0.0 * 0.0)))));
} else {
VAR_3 = (((log((1.0 / re)) * log((1.0 / base))) + (atan2(im, re) * 0.0)) / ((log(base) * log(base)) + (0.0 * 0.0)));
}
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 < -1.8201431513100123e+121Initial program 55.8
Taylor expanded around -inf 9.5
if -1.8201431513100123e+121 < re < -8.123248591212039e-303 or 6.754536396545516e-163 < re < 7.281392833689827e+80Initial program 19.9
rmApplied add-sqr-sqrt19.9
Applied *-un-lft-identity19.9
Applied times-frac19.9
if -8.123248591212039e-303 < re < 6.754536396545516e-163Initial program 32.1
Taylor expanded around 0 35.7
if 7.281392833689827e+80 < re Initial program 47.7
Taylor expanded around inf 8.9
Final simplification18.2
herbie shell --seed 2020075
(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))))