\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 -6.7980708782508348 \cdot 10^{132}:\\
\;\;\;\;\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 8.21636159632643809 \cdot 10^{28}:\\
\;\;\;\;\frac{1}{\frac{0.0 \cdot 0.0 + {\left(\log base\right)}^{2}}{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \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 <= -6.798070878250835e+132)) {
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 <= 8.216361596326438e+28)) {
VAR_1 = (1.0 / (((0.0 * 0.0) + pow(log(base), 2.0)) / ((log(sqrt(((re * re) + (im * im)))) * log(base)) + (atan2(im, re) * 0.0))));
} else {
VAR_1 = ((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 = VAR_1;
}
return VAR;
}



Bits error versus re



Bits error versus im



Bits error versus base
Results
if re < -6.798070878250835e+132Initial program 57.1
rmApplied add-sqr-sqrt57.1
Applied associate-/r*57.1
Taylor expanded around -inf 7.3
if -6.798070878250835e+132 < re < 8.216361596326438e+28Initial program 21.5
rmApplied clear-num21.5
Simplified21.5
if 8.216361596326438e+28 < re Initial program 42.3
rmApplied add-sqr-sqrt42.3
Applied *-un-lft-identity42.3
Applied times-frac42.3
Taylor expanded around inf 12.1
Final simplification17.3
herbie shell --seed 2020105
(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))))