\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.2268200955213129 \cdot 10^{128}:\\
\;\;\;\;\frac{1}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}} \cdot \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}}\\
\mathbf{elif}\;re \le -4.36720304938663593 \cdot 10^{-290}:\\
\;\;\;\;\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 7.26452085516333024 \cdot 10^{-243}:\\
\;\;\;\;\frac{1}{\frac{\log base}{\log im}}\\
\mathbf{elif}\;re \le 2.3188158936543582 \cdot 10^{93}:\\
\;\;\;\;\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)}{\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 <= -1.2268200955213129e+128)) {
VAR = ((1.0 / sqrt(((log(base) * log(base)) + (0.0 * 0.0)))) * (((log((-1.0 * re)) * log(base)) + (atan2(im, re) * 0.0)) / sqrt(((log(base) * log(base)) + (0.0 * 0.0)))));
} else {
double VAR_1;
if ((re <= -4.367203049386636e-290)) {
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 <= 7.26452085516333e-243)) {
VAR_2 = (1.0 / (log(base) / log(im)));
} else {
double VAR_3;
if ((re <= 2.318815893654358e+93)) {
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)));
}
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.2268200955213129e+128Initial program 56.2
rmApplied add-sqr-sqrt56.2
Applied *-un-lft-identity56.2
Applied times-frac56.2
Taylor expanded around -inf 8.3
if -1.2268200955213129e+128 < re < -4.367203049386636e-290 or 7.26452085516333e-243 < re < 2.318815893654358e+93Initial program 20.3
rmApplied add-sqr-sqrt20.3
Applied *-un-lft-identity20.3
Applied times-frac20.3
if -4.367203049386636e-290 < re < 7.26452085516333e-243Initial program 32.6
rmApplied clear-num32.6
Simplified32.6
Taylor expanded around 0 34.2
if 2.318815893654358e+93 < re Initial program 50.7
Taylor expanded around inf 9.6
Final simplification17.7
herbie shell --seed 2020106
(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))))