\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}\;im \leq -2.081558982118848 \cdot 10^{+59}:\\
\;\;\;\;\frac{\log \left(-im\right)}{\log base}\\
\mathbf{elif}\;im \leq -1.7324615588834855 \cdot 10^{-199}:\\
\;\;\;\;\frac{\log \left(\left|\sqrt[3]{re \cdot re + im \cdot im}\right| \cdot \sqrt{\sqrt[3]{re \cdot re + im \cdot im}}\right)}{\log base}\\
\mathbf{elif}\;im \leq 5.57434679198083 \cdot 10^{-283}:\\
\;\;\;\;\frac{0.5}{\frac{\log base}{-2 \cdot \log \left(\frac{-1}{re}\right)}}\\
\mathbf{elif}\;im \leq 2.5433593506319202 \cdot 10^{-253}:\\
\;\;\;\;\frac{0.5}{-0.5 \cdot \frac{\log base}{-\log re}}\\
\mathbf{elif}\;im \leq 4.089819462125776 \cdot 10^{-231}:\\
\;\;\;\;\frac{0.5}{\frac{\log base}{-2 \cdot \log \left(\frac{-1}{re}\right)}}\\
\mathbf{elif}\;im \leq 2.3592751430097664 \cdot 10^{+82}:\\
\;\;\;\;\frac{\log \left(\left|\sqrt[3]{re \cdot re + im \cdot im}\right| \cdot \sqrt{\sqrt[3]{re \cdot re + im \cdot im}}\right)}{\log base}\\
\mathbf{else}:\\
\;\;\;\;\frac{\log im}{\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
(if (<= im -2.081558982118848e+59)
(/ (log (- im)) (log base))
(if (<= im -1.7324615588834855e-199)
(/
(log
(*
(fabs (cbrt (+ (* re re) (* im im))))
(sqrt (cbrt (+ (* re re) (* im im))))))
(log base))
(if (<= im 5.57434679198083e-283)
(/ 0.5 (/ (log base) (* -2.0 (log (/ -1.0 re)))))
(if (<= im 2.5433593506319202e-253)
(/ 0.5 (* -0.5 (/ (log base) (- (log re)))))
(if (<= im 4.089819462125776e-231)
(/ 0.5 (/ (log base) (* -2.0 (log (/ -1.0 re)))))
(if (<= im 2.3592751430097664e+82)
(/
(log
(*
(fabs (cbrt (+ (* re re) (* im im))))
(sqrt (cbrt (+ (* re re) (* im im))))))
(log base))
(/ (log 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 tmp;
if (im <= -2.081558982118848e+59) {
tmp = log(-im) / log(base);
} else if (im <= -1.7324615588834855e-199) {
tmp = log(fabs(cbrt((re * re) + (im * im))) * sqrt(cbrt((re * re) + (im * im)))) / log(base);
} else if (im <= 5.57434679198083e-283) {
tmp = 0.5 / (log(base) / (-2.0 * log(-1.0 / re)));
} else if (im <= 2.5433593506319202e-253) {
tmp = 0.5 / (-0.5 * (log(base) / -log(re)));
} else if (im <= 4.089819462125776e-231) {
tmp = 0.5 / (log(base) / (-2.0 * log(-1.0 / re)));
} else if (im <= 2.3592751430097664e+82) {
tmp = log(fabs(cbrt((re * re) + (im * im))) * sqrt(cbrt((re * re) + (im * im)))) / log(base);
} else {
tmp = log(im) / log(base);
}
return tmp;
}



Bits error versus re



Bits error versus im



Bits error versus base
Results
if im < -2.0815589821188481e59Initial program 45.5
Simplified45.4
Taylor expanded around -inf 11.0
if -2.0815589821188481e59 < im < -1.7324615588834855e-199 or 4.0898194621257763e-231 < im < 2.35927514300976641e82Initial program 17.8
Simplified17.8
rmApplied add-cube-cbrt_binary64_45417.8
Applied sqrt-prod_binary64_43517.8
Simplified17.8
if -1.7324615588834855e-199 < im < 5.57434679198083037e-283 or 2.5433593506319202e-253 < im < 4.0898194621257763e-231Initial program 32.7
Simplified32.6
rmApplied pow1/2_binary64_49932.6
Applied log-pow_binary64_50832.6
Applied associate-/l*_binary64_36432.7
Taylor expanded around -inf 34.9
if 5.57434679198083037e-283 < im < 2.5433593506319202e-253Initial program 30.5
Simplified30.5
rmApplied pow1/2_binary64_49930.5
Applied log-pow_binary64_50830.5
Applied associate-/l*_binary64_36430.5
Taylor expanded around inf 31.2
Simplified31.1
if 2.35927514300976641e82 < im Initial program 47.9
Simplified47.8
Taylor expanded around 0 9.0
Final simplification17.3
herbie shell --seed 2021022
(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))))