\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}
\mathbf{if}\;re \leq -6.103568674686091 \cdot 10^{+152}:\\
\;\;\;\;\frac{0.5}{\frac{\log base}{\log \left(\frac{-1}{re}\right) \cdot -2}}\\
\mathbf{elif}\;re \leq 7.28857737127815 \cdot 10^{+119}:\\
\;\;\;\;\frac{\log base \cdot \log \left(\sqrt{re \cdot re + im \cdot im}\right) + \tan^{-1}_* \frac{im}{re} \cdot 0}{\log base \cdot \log base}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{\frac{\log base}{2 \cdot \log re}}\\
\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
(if (<= re -6.103568674686091e+152)
(/ 0.5 (/ (log base) (* (log (/ -1.0 re)) -2.0)))
(if (<= re 7.28857737127815e+119)
(/
(+
(* (log base) (log (sqrt (+ (* re re) (* im im)))))
(* (atan2 im re) 0.0))
(* (log base) (log base)))
(/ 0.5 (/ (log base) (* 2.0 (log re)))))))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 tmp;
if (re <= -6.103568674686091e+152) {
tmp = 0.5 / (log(base) / (log(-1.0 / re) * -2.0));
} else if (re <= 7.28857737127815e+119) {
tmp = ((log(base) * log(sqrt((re * re) + (im * im)))) + (atan2(im, re) * 0.0)) / (log(base) * log(base));
} else {
tmp = 0.5 / (log(base) / (2.0 * log(re)));
}
return tmp;
}



Bits error versus re



Bits error versus im



Bits error versus base
Results
if re < -6.1035686746860911e152Initial program 63.8
Simplified63.8
rmApplied pow1/2_binary6463.8
Applied log-pow_binary6463.8
Applied associate-/l*_binary6463.8
Taylor expanded around -inf 7.5
Simplified7.5
if -6.1035686746860911e152 < re < 7.28857737127814954e119Initial program 21.4
if 7.28857737127814954e119 < re Initial program 55.8
Simplified55.7
rmApplied pow1/2_binary6455.7
Applied log-pow_binary6455.7
Applied associate-/l*_binary6455.8
Taylor expanded around inf 8.7
Simplified8.7
Final simplification17.6
herbie shell --seed 2020253
(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))))