\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.47908061050294571 \cdot 10^{108}:\\
\;\;\;\;\frac{\log \left(\frac{-1}{re}\right)}{\frac{0 + \log base}{-1}}\\
\mathbf{elif}\;re \le 7.02369283710352736 \cdot 10^{90}:\\
\;\;\;\;\frac{\left(\frac{1}{4} \cdot \left({\left(\log base\right)}^{2} \cdot \log \left(re \cdot re + im \cdot im\right)\right)\right) \cdot \log \left(re \cdot re + im \cdot im\right) - \left(\tan^{-1}_* \frac{im}{re} \cdot 0.0\right) \cdot \left(\tan^{-1}_* \frac{im}{re} \cdot 0.0\right)}{\left(\frac{1}{2} \cdot \left(\log \left(re \cdot re + im \cdot im\right) \cdot \log base\right) - \tan^{-1}_* \frac{im}{re} \cdot 0.0\right) \cdot \left(0.0 \cdot 0.0 + {\left(\log base\right)}^{2}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\log base \cdot \log re + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\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 <= -3.4790806105029457e+108)) {
VAR = (log((-1.0 / re)) / ((0.0 + log(base)) / -1.0));
} else {
double VAR_1;
if ((re <= 7.023692837103527e+90)) {
VAR_1 = ((((0.25 * (pow(log(base), 2.0) * log(((re * re) + (im * im))))) * log(((re * re) + (im * im)))) - ((atan2(im, re) * 0.0) * (atan2(im, re) * 0.0))) / (((0.5 * (log(((re * re) + (im * im))) * log(base))) - (atan2(im, re) * 0.0)) * ((0.0 * 0.0) + pow(log(base), 2.0))));
} else {
VAR_1 = (((log(base) * log(re)) + (atan2(im, re) * 0.0)) / ((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 < -3.4790806105029457e+108Initial program 52.5
Taylor expanded around -inf 64.0
Simplified9.1
if -3.4790806105029457e+108 < re < 7.023692837103527e+90Initial program 21.3
rmApplied pow1/221.3
Applied log-pow21.3
Applied associate-*l*21.3
rmApplied flip-+21.3
Applied associate-/l/21.4
Simplified21.4
rmApplied *-commutative21.4
Applied associate-*r*21.4
Applied associate-*r*21.4
Simplified21.4
if 7.023692837103527e+90 < re Initial program 50.9
Taylor expanded around inf 10.4
Simplified10.4
Final simplification17.5
herbie shell --seed 2020071
(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))))