\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0}{\log base \cdot \log base + 0 \cdot 0}
\begin{array}{l}
t_0 := \log \left(\frac{1}{base}\right)\\
\mathbf{if}\;re \leq -1.2172902275687481 \cdot 10^{+98}:\\
\;\;\;\;-\frac{\log \left(\frac{-1}{re}\right) \cdot \sqrt[3]{-1}}{t_0}\\
\mathbf{elif}\;re \leq -1.2637342420410735 \cdot 10^{-145}:\\
\;\;\;\;-\frac{\log \left(\sqrt{{re}^{2} + {im}^{2}}\right)}{t_0}\\
\mathbf{else}:\\
\;\;\;\;-\frac{\log \left(\frac{1}{im}\right)}{\log base}\\
\end{array}
(FPCore (re im base) :precision binary64 (/ (+ (* (log (sqrt (+ (* re re) (* im im)))) (log base)) (* (atan2 im re) 0.0)) (+ (* (log base) (log base)) (* 0.0 0.0))))
(FPCore (re im base)
:precision binary64
(let* ((t_0 (log (/ 1.0 base))))
(if (<= re -1.2172902275687481e+98)
(- (/ (* (log (/ -1.0 re)) (cbrt -1.0)) t_0))
(if (<= re -1.2637342420410735e-145)
(- (/ (log (sqrt (+ (pow re 2.0) (pow im 2.0)))) t_0))
(- (/ (log (/ 1.0 im)) (log base)))))))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 t_0 = log(1.0 / base);
double tmp;
if (re <= -1.2172902275687481e+98) {
tmp = -((log(-1.0 / re) * cbrt(-1.0)) / t_0);
} else if (re <= -1.2637342420410735e-145) {
tmp = -(log(sqrt(pow(re, 2.0) + pow(im, 2.0))) / t_0);
} else {
tmp = -(log(1.0 / im) / log(base));
}
return tmp;
}



Bits error versus re



Bits error versus im



Bits error versus base
Results
if re < -1.2172902275687481e98Initial program 50.8
Simplified50.8
Taylor expanded around -inf 5.0
Simplified5.0
rmApplied add-cbrt-cube_binary645.3
Simplified5.3
Taylor expanded around -inf 5.3
Simplified5.3
Taylor expanded around inf 5.0
if -1.2172902275687481e98 < re < -1.2637342420410735e-145Initial program 11.9
Simplified11.8
Taylor expanded around inf 11.8
if -1.2637342420410735e-145 < re Initial program 33.0
Simplified33.0
Taylor expanded around inf 6.1
Final simplification7.3
herbie shell --seed 2021207
(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))))