\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 -8.4283330823776827 \cdot 10^{116}:\\
\;\;\;\;\frac{1}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}} \cdot \frac{\left(-1 \cdot \log \left(\frac{-1}{re}\right)\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 -3.9704250822075291 \cdot 10^{-222}:\\
\;\;\;\;\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 6.10198222113209448 \cdot 10^{-198}:\\
\;\;\;\;\frac{\log im}{\log base}\\
\mathbf{elif}\;re \le 8121789251388552:\\
\;\;\;\;\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 \left(\frac{1}{re}\right) \cdot \log \left(\frac{1}{base}\right) + \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 temp;
if ((re <= -8.428333082377683e+116)) {
temp = ((1.0 / sqrt(((log(base) * log(base)) + (0.0 * 0.0)))) * ((((-1.0 * log((-1.0 / re))) * log(base)) + (atan2(im, re) * 0.0)) / sqrt(((log(base) * log(base)) + (0.0 * 0.0)))));
} else {
double temp_1;
if ((re <= -3.970425082207529e-222)) {
temp_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 temp_2;
if ((re <= 6.1019822211320945e-198)) {
temp_2 = (log(im) / log(base));
} else {
double temp_3;
if ((re <= 8121789251388552.0)) {
temp_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 {
temp_3 = ((1.0 / sqrt(((log(base) * log(base)) + (0.0 * 0.0)))) * (((log((1.0 / re)) * log((1.0 / base))) + (atan2(im, re) * 0.0)) / sqrt(((log(base) * log(base)) + (0.0 * 0.0)))));
}
temp_2 = temp_3;
}
temp_1 = temp_2;
}
temp = temp_1;
}
return temp;
}



Bits error versus re



Bits error versus im



Bits error versus base
Results
if re < -8.428333082377683e+116Initial program 55.6
rmApplied add-sqr-sqrt55.6
Applied *-un-lft-identity55.6
Applied times-frac55.6
Taylor expanded around -inf 64.0
Simplified8.2
if -8.428333082377683e+116 < re < -3.970425082207529e-222 or 6.1019822211320945e-198 < re < 8121789251388552.0Initial program 19.6
rmApplied add-sqr-sqrt19.6
Applied *-un-lft-identity19.6
Applied times-frac19.6
if -3.970425082207529e-222 < re < 6.1019822211320945e-198Initial program 30.2
Taylor expanded around 0 33.0
if 8121789251388552.0 < re Initial program 42.4
rmApplied add-sqr-sqrt42.4
Applied *-un-lft-identity42.4
Applied times-frac42.4
Taylor expanded around inf 13.6
Final simplification18.7
herbie shell --seed 2020066
(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))))