\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 -3.66139489561362384 \cdot 10^{142}:\\
\;\;\;\;\left(\log \left(-1 \cdot re\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 1.60317472953700272 \cdot 10^{-25}:\\
\;\;\;\;\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 <= -3.661394895613624e+142)) {
VAR = (((log((-1.0 * re)) * log(base)) + (atan2(im, re) * 0.0)) * (1.0 / ((log(base) * log(base)) + (0.0 * 0.0))));
} else {
double VAR_1;
if ((re <= 1.6031747295370027e-25)) {
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 {
VAR_1 = (log((1.0 / re)) / log((1.0 / base)));
}
VAR = VAR_1;
}
return VAR;
}



Bits error versus re



Bits error versus im



Bits error versus base
Results
if re < -3.661394895613624e+142Initial program 62.0
rmApplied div-inv62.0
Taylor expanded around -inf 7.3
if -3.661394895613624e+142 < re < 1.6031747295370027e-25Initial program 22.8
rmApplied div-inv22.8
if 1.6031747295370027e-25 < re Initial program 38.9
Taylor expanded around inf 15.1
Final simplification18.6
herbie shell --seed 2020103
(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))))