\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 -3.3734405662222592 \cdot 10^{+121}:\\
\;\;\;\;-\frac{\log \left(\frac{-1}{re}\right)}{\log base}\\
\mathbf{elif}\;re \leq -7.823143127285978 \cdot 10^{-193}:\\
\;\;\;\;\frac{\log base \cdot \log \left(\sqrt{re \cdot re + im \cdot im}\right) + \tan^{-1}_* \frac{im}{re} \cdot 0}{\left(\log base \cdot \log \left(\sqrt[3]{base}\right) + 2 \cdot \left(\log base \cdot \log \left(\sqrt[3]{base}\right)\right)\right) + 0 \cdot 0}\\
\mathbf{elif}\;re \leq -1.5821814501140232 \cdot 10^{-267}:\\
\;\;\;\;\frac{\log im}{\log base}\\
\mathbf{elif}\;re \leq 800712819.842004:\\
\;\;\;\;\frac{\log base \cdot \log \left(\sqrt{re \cdot re + im \cdot im}\right) + \tan^{-1}_* \frac{im}{re} \cdot 0}{\left(\log base \cdot \log \left(\sqrt[3]{base}\right) + 2 \cdot \left(\log base \cdot \log \left(\sqrt[3]{base}\right)\right)\right) + 0 \cdot 0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\log re}{\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 (<= re -3.3734405662222592e+121)
(- (/ (log (/ -1.0 re)) (log base)))
(if (<= re -7.823143127285978e-193)
(/
(+
(* (log base) (log (sqrt (+ (* re re) (* im im)))))
(* (atan2 im re) 0.0))
(+
(+
(* (log base) (log (cbrt base)))
(* 2.0 (* (log base) (log (cbrt base)))))
(* 0.0 0.0)))
(if (<= re -1.5821814501140232e-267)
(/ (log im) (log base))
(if (<= re 800712819.842004)
(/
(+
(* (log base) (log (sqrt (+ (* re re) (* im im)))))
(* (atan2 im re) 0.0))
(+
(+
(* (log base) (log (cbrt base)))
(* 2.0 (* (log base) (log (cbrt base)))))
(* 0.0 0.0)))
(/ (log re) (log base)))))))double code(double re, double im, double base) {
return (((double) (((double) (((double) log(((double) sqrt(((double) (((double) (re * re)) + ((double) (im * im)))))))) * ((double) log(base)))) + ((double) (((double) atan2(im, re)) * 0.0)))) / ((double) (((double) (((double) log(base)) * ((double) log(base)))) + ((double) (0.0 * 0.0)))));
}
double code(double re, double im, double base) {
double tmp;
if ((re <= -3.3734405662222592e+121)) {
tmp = ((double) -((((double) log((-1.0 / re))) / ((double) log(base)))));
} else {
double tmp_1;
if ((re <= -7.823143127285978e-193)) {
tmp_1 = (((double) (((double) (((double) log(base)) * ((double) log(((double) sqrt(((double) (((double) (re * re)) + ((double) (im * im)))))))))) + ((double) (((double) atan2(im, re)) * 0.0)))) / ((double) (((double) (((double) (((double) log(base)) * ((double) log(((double) cbrt(base)))))) + ((double) (2.0 * ((double) (((double) log(base)) * ((double) log(((double) cbrt(base)))))))))) + ((double) (0.0 * 0.0)))));
} else {
double tmp_2;
if ((re <= -1.5821814501140232e-267)) {
tmp_2 = (((double) log(im)) / ((double) log(base)));
} else {
double tmp_3;
if ((re <= 800712819.842004)) {
tmp_3 = (((double) (((double) (((double) log(base)) * ((double) log(((double) sqrt(((double) (((double) (re * re)) + ((double) (im * im)))))))))) + ((double) (((double) atan2(im, re)) * 0.0)))) / ((double) (((double) (((double) (((double) log(base)) * ((double) log(((double) cbrt(base)))))) + ((double) (2.0 * ((double) (((double) log(base)) * ((double) log(((double) cbrt(base)))))))))) + ((double) (0.0 * 0.0)))));
} else {
tmp_3 = (((double) log(re)) / ((double) log(base)));
}
tmp_2 = tmp_3;
}
tmp_1 = tmp_2;
}
tmp = tmp_1;
}
return tmp;
}



Bits error versus re



Bits error versus im



Bits error versus base
Results
if re < -3.37344056622225924e121Initial program 55.5
Taylor expanded around -inf 64.0
Simplified8.3
if -3.37344056622225924e121 < re < -7.82314312728597759e-193 or -1.58218145011402322e-267 < re < 800712819.842003942Initial program 20.7
rmApplied add-cube-cbrt_binary6420.8
Applied log-prod_binary6420.8
Applied distribute-lft-in_binary6420.8
Simplified20.8
if -7.82314312728597759e-193 < re < -1.58218145011402322e-267Initial program 32.7
Taylor expanded around 0 33.6
if 800712819.842003942 < re Initial program 39.2
Taylor expanded around inf 12.4
Simplified12.4
Final simplification17.7
herbie shell --seed 2020204
(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))))