\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 -2.1045401481442277 \cdot 10^{+128}:\\
\;\;\;\;\frac{\log \left(-re\right)}{\log base}\\
\mathbf{elif}\;re \leq -1.9933387775564622 \cdot 10^{-274}:\\
\;\;\;\;1.5 \cdot \frac{\log \left(\sqrt[3]{re \cdot re + im \cdot im}\right)}{\log base}\\
\mathbf{elif}\;re \leq 2.4998168956729745 \cdot 10^{-273}:\\
\;\;\;\;\frac{1.5 \cdot \log \left({im}^{0.6666666666666666}\right)}{\log base}\\
\mathbf{elif}\;re \leq 8.116903149692801 \cdot 10^{+57}:\\
\;\;\;\;1.5 \cdot \frac{\log \left(\sqrt[3]{re \cdot re + im \cdot im}\right)}{\log base}\\
\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 -2.1045401481442277e+128)
(/ (log (- re)) (log base))
(if (<= re -1.9933387775564622e-274)
(* 1.5 (/ (log (cbrt (+ (* re re) (* im im)))) (log base)))
(if (<= re 2.4998168956729745e-273)
(/ (* 1.5 (log (pow im 0.6666666666666666))) (log base))
(if (<= re 8.116903149692801e+57)
(* 1.5 (/ (log (cbrt (+ (* re re) (* im im)))) (log base)))
(/ (log re) (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 (re <= -2.1045401481442277e+128) {
tmp = log(-re) / log(base);
} else if (re <= -1.9933387775564622e-274) {
tmp = 1.5 * (log(cbrt((re * re) + (im * im))) / log(base));
} else if (re <= 2.4998168956729745e-273) {
tmp = (1.5 * log(pow(im, 0.6666666666666666))) / log(base);
} else if (re <= 8.116903149692801e+57) {
tmp = 1.5 * (log(cbrt((re * re) + (im * im))) / log(base));
} else {
tmp = log(re) / log(base);
}
return tmp;
}



Bits error versus re



Bits error versus im



Bits error versus base
Results
if re < -2.10454014814422774e128Initial program 56.1
Simplified56.0
Taylor expanded around -inf 9.0
Simplified9.0
if -2.10454014814422774e128 < re < -1.99333877755646224e-274 or 2.4998168956729745e-273 < re < 8.1169031496928011e57Initial program 20.8
Simplified20.7
rmApplied pow1/2_binary6420.7
Applied log-pow_binary6420.7
Applied associate-/l*_binary6420.8
rmApplied add-cube-cbrt_binary6420.8
Applied log-prod_binary6420.8
Simplified20.8
rmApplied *-un-lft-identity_binary6420.8
Applied pow1_binary6420.8
Applied log-pow_binary6420.8
Applied times-frac_binary6420.8
Applied *-un-lft-identity_binary6420.8
Applied times-frac_binary6420.8
Simplified20.8
Simplified20.8
rmApplied pow1_binary6420.8
Applied log-pow_binary6420.8
Applied times-frac_binary6420.8
Simplified20.8
if -1.99333877755646224e-274 < re < 2.4998168956729745e-273Initial program 34.8
Simplified34.7
rmApplied pow1/2_binary6434.7
Applied log-pow_binary6434.7
Applied associate-/l*_binary6434.7
rmApplied add-cube-cbrt_binary6434.7
Applied log-prod_binary6434.7
Simplified34.7
rmApplied *-un-lft-identity_binary6434.7
Applied pow1_binary6434.7
Applied log-pow_binary6434.7
Applied times-frac_binary6434.7
Applied *-un-lft-identity_binary6434.7
Applied times-frac_binary6434.7
Simplified34.7
Simplified34.7
Taylor expanded around 0 34.5
if 8.1169031496928011e57 < re Initial program 46.7
Simplified46.6
Taylor expanded around inf 10.8
Final simplification17.9
herbie shell --seed 2020219
(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))))