\frac{\tan^{-1}_* \frac{im}{re} \cdot \log base - \log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot 0}{\log base \cdot \log base + 0 \cdot 0}
-\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\tan^{-1}_* \frac{im}{re}}{-\log base}\right)\right)
(FPCore (re im base) :precision binary64 (/ (- (* (atan2 im re) (log base)) (* (log (sqrt (+ (* re re) (* im im)))) 0.0)) (+ (* (log base) (log base)) (* 0.0 0.0))))
(FPCore (re im base) :precision binary64 (- (log1p (expm1 (/ (atan2 im re) (- (log base)))))))
double code(double re, double im, double base) {
return ((atan2(im, re) * log(base)) - (log(sqrt((re * re) + (im * im))) * 0.0)) / ((log(base) * log(base)) + (0.0 * 0.0));
}
double code(double re, double im, double base) {
return -log1p(expm1(atan2(im, re) / -log(base)));
}



Bits error versus re



Bits error versus im



Bits error versus base
Results
Initial program 31.9
Simplified0.3
Taylor expanded in base around inf 0.3
Applied add-cube-cbrt_binary640.3
Applied add-cube-cbrt_binary640.3
Applied times-frac_binary640.3
Applied log-prod_binary640.4
Simplified0.4
Simplified0.4
Applied log1p-expm1-u_binary640.4
Simplified0.3
Final simplification0.3
herbie shell --seed 2022067
(FPCore (re im base)
:name "math.log/2 on complex, imaginary part"
:precision binary64
(/ (- (* (atan2 im re) (log base)) (* (log (sqrt (+ (* re re) (* im im)))) 0.0)) (+ (* (log base) (log base)) (* 0.0 0.0))))