\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.21907540931537393 \cdot 10^{117}:\\
\;\;\;\;\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 -7.2713402830638425 \cdot 10^{-171}:\\
\;\;\;\;\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 1.9780598850161828 \cdot 10^{-206}:\\
\;\;\;\;\frac{\log im}{\log base}\\
\mathbf{elif}\;re \le 6.21416753908483653 \cdot 10^{-142}:\\
\;\;\;\;\frac{\log \left(\frac{1}{re}\right)}{\log \left(\frac{1}{base}\right)}\\
\mathbf{elif}\;re \le 1.492585514901269 \cdot 10^{-103}:\\
\;\;\;\;\frac{\log im}{\log base}\\
\mathbf{elif}\;re \le 2.43405196972925384 \cdot 10^{101}:\\
\;\;\;\;\frac{\log \left(\left(\sqrt[3]{\sqrt{re \cdot re + im \cdot im}} \cdot \sqrt[3]{\sqrt{re \cdot re + im \cdot im}}\right) \cdot \sqrt[3]{\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}\\
\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.219075409315374e+117)) {
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 <= -7.2713402830638425e-171)) {
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 <= 1.9780598850161828e-206)) {
VAR_2 = (log(im) / log(base));
} else {
double VAR_3;
if ((re <= 6.2141675390848365e-142)) {
VAR_3 = (log((1.0 / re)) / log((1.0 / base)));
} else {
double VAR_4;
if ((re <= 1.4925855149012688e-103)) {
VAR_4 = (log(im) / log(base));
} else {
double VAR_5;
if ((re <= 2.4340519697292538e+101)) {
VAR_5 = (((log(((cbrt(sqrt(((re * re) + (im * im)))) * cbrt(sqrt(((re * re) + (im * im))))) * cbrt(sqrt(((re * re) + (im * im)))))) * log(base)) + (atan2(im, re) * 0.0)) / ((log(base) * log(base)) + (0.0 * 0.0)));
} else {
VAR_5 = (log((1.0 / re)) / log((1.0 / base)));
}
VAR_4 = VAR_5;
}
VAR_3 = VAR_4;
}
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 < -3.219075409315374e+117Initial program 55.6
rmApplied add-sqr-sqrt55.6
Applied associate-/r*55.6
Taylor expanded around -inf 7.9
if -3.219075409315374e+117 < re < -7.2713402830638425e-171Initial program 16.1
rmApplied add-sqr-sqrt16.1
Applied *-un-lft-identity16.1
Applied times-frac16.1
if -7.2713402830638425e-171 < re < 1.9780598850161828e-206 or 6.2141675390848365e-142 < re < 1.4925855149012688e-103Initial program 30.4
Taylor expanded around 0 34.8
if 1.9780598850161828e-206 < re < 6.2141675390848365e-142 or 2.4340519697292538e+101 < re Initial program 45.5
Taylor expanded around inf 17.5
if 1.4925855149012688e-103 < re < 2.4340519697292538e+101Initial program 14.5
rmApplied add-cube-cbrt14.6
Final simplification19.2
herbie shell --seed 2020100
(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))))