\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 -2.7113729341313481 \cdot 10^{136}:\\
\;\;\;\;\frac{\left(-1 \cdot \log \left(\frac{-1}{re}\right)\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\left(\log base \cdot \left(2 \cdot \log \left(\sqrt[3]{base}\right)\right) + \log base \cdot \log \left(\sqrt[3]{base}\right)\right) + 0.0 \cdot 0.0}\\
\mathbf{elif}\;re \le -3.3378995032617328 \cdot 10^{-307}:\\
\;\;\;\;\frac{1}{\frac{\left(0.0 \cdot 0.0\right) \cdot \left(0.0 \cdot 0.0\right) - {\left(\log base\right)}^{2} \cdot {\left(\log base\right)}^{2}}{\left(\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0\right) \cdot \left(0.0 \cdot 0.0 - {\left(\log base\right)}^{2}\right)}}\\
\mathbf{elif}\;re \le 5.49414863235609694 \cdot 10^{-172}:\\
\;\;\;\;\frac{\log im}{\log base}\\
\mathbf{elif}\;re \le 8.73128570597796415 \cdot 10^{80}:\\
\;\;\;\;\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\left(\log base \cdot \left(2 \cdot \log \left(\sqrt[3]{base}\right)\right) + \log base \cdot \log \left({\left(\frac{1}{base}\right)}^{\frac{-1}{3}}\right)\right) + 0.0 \cdot 0.0}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{\log \left(\frac{1}{base}\right)}{\log \left(\frac{1}{re}\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 <= -2.711372934131348e+136)) {
VAR = ((((-1.0 * log((-1.0 / re))) * log(base)) + (atan2(im, re) * 0.0)) / (((log(base) * (2.0 * log(cbrt(base)))) + (log(base) * log(cbrt(base)))) + (0.0 * 0.0)));
} else {
double VAR_1;
if ((re <= -3.3378995032617328e-307)) {
VAR_1 = (1.0 / ((((0.0 * 0.0) * (0.0 * 0.0)) - (pow(log(base), 2.0) * pow(log(base), 2.0))) / (((log(sqrt(((re * re) + (im * im)))) * log(base)) + (atan2(im, re) * 0.0)) * ((0.0 * 0.0) - pow(log(base), 2.0)))));
} else {
double VAR_2;
if ((re <= 5.494148632356097e-172)) {
VAR_2 = (log(im) / log(base));
} else {
double VAR_3;
if ((re <= 8.731285705977964e+80)) {
VAR_3 = (((log(sqrt(((re * re) + (im * im)))) * log(base)) + (atan2(im, re) * 0.0)) / (((log(base) * (2.0 * log(cbrt(base)))) + (log(base) * log(pow((1.0 / base), -0.3333333333333333)))) + (0.0 * 0.0)));
} else {
VAR_3 = (1.0 / (log((1.0 / base)) / log((1.0 / re))));
}
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 < -2.711372934131348e+136Initial program 59.4
rmApplied add-cube-cbrt59.4
Applied log-prod59.4
Applied distribute-lft-in59.4
Simplified59.4
Taylor expanded around -inf 64.0
Simplified8.4
if -2.711372934131348e+136 < re < -3.3378995032617328e-307Initial program 21.0
rmApplied clear-num21.0
Simplified21.0
rmApplied flip-+21.0
Applied associate-/l/21.1
if -3.3378995032617328e-307 < re < 5.494148632356097e-172Initial program 31.8
Taylor expanded around 0 34.7
if 5.494148632356097e-172 < re < 8.731285705977964e+80Initial program 17.5
rmApplied add-cube-cbrt17.5
Applied log-prod17.5
Applied distribute-lft-in17.6
Simplified17.6
Taylor expanded around inf 17.5
if 8.731285705977964e+80 < re Initial program 49.1
rmApplied clear-num49.1
Simplified49.1
Taylor expanded around inf 9.9
Final simplification18.0
herbie shell --seed 2020078
(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))))