\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.8625576543047326 \cdot 10^{137}:\\
\;\;\;\;\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 -4.87467442121705053 \cdot 10^{-285}:\\
\;\;\;\;\frac{\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}}}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}\\
\mathbf{elif}\;re \le 1.124886252440386 \cdot 10^{-292}:\\
\;\;\;\;\frac{\log im}{\log base}\\
\mathbf{elif}\;re \le 1.93623703611671345 \cdot 10^{98}:\\
\;\;\;\;\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{1}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}} \cdot \frac{\log re \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\sqrt{\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.8625576543047326e+137)) {
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 <= -4.8746744212170505e-285)) {
VAR_1 = ((((log(sqrt(((re * re) + (im * im)))) * 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_2;
if ((re <= 1.124886252440386e-292)) {
VAR_2 = (log(im) / log(base));
} else {
double VAR_3;
if ((re <= 1.9362370361167134e+98)) {
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 = ((1.0 / sqrt(((log(base) * log(base)) + (0.0 * 0.0)))) * (((log(re) * log(base)) + (atan2(im, re) * 0.0)) / sqrt(((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.8625576543047326e+137Initial program 59.4
rmApplied add-sqr-sqrt59.4
Applied associate-/r*59.4
Taylor expanded around -inf 7.6
if -1.8625576543047326e+137 < re < -4.8746744212170505e-285Initial program 20.2
rmApplied add-sqr-sqrt20.2
Applied associate-/r*20.2
if -4.8746744212170505e-285 < re < 1.124886252440386e-292Initial program 32.1
Taylor expanded around 0 34.8
if 1.124886252440386e-292 < re < 1.9362370361167134e+98Initial program 21.0
rmApplied add-sqr-sqrt21.0
Applied *-un-lft-identity21.0
Applied times-frac21.0
if 1.9362370361167134e+98 < re Initial program 51.2
rmApplied add-sqr-sqrt51.2
Applied *-un-lft-identity51.2
Applied times-frac51.2
Taylor expanded around inf 9.2
Final simplification17.3
herbie shell --seed 2020079
(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))))