Average Error: 32.3 → 18.2
Time: 8.3s
Precision: 64
\[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\log base \cdot \log base + 0.0 \cdot 0.0}\]
\[\begin{array}{l} \mathbf{if}\;re \le -1.6143965812033716 \cdot 10^{43}:\\ \;\;\;\;\frac{\frac{\log \left(-1 \cdot re\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}\\ \mathbf{elif}\;re \le 2.51743858251528089 \cdot 10^{56}:\\ \;\;\;\;\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\left(\log base \cdot \left(2 \cdot \log \left(\sqrt[3]{base}\right)\right) + \log base \cdot \log \left(\sqrt[3]{base}\right)\right) + 0.0 \cdot 0.0}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log \left(\frac{1}{re}\right)}{\log \left(\frac{1}{base}\right)}\\ \end{array}\]
\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\log base \cdot \log base + 0.0 \cdot 0.0}
\begin{array}{l}
\mathbf{if}\;re \le -1.6143965812033716 \cdot 10^{43}:\\
\;\;\;\;\frac{\frac{\log \left(-1 \cdot re\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}\\

\mathbf{elif}\;re \le 2.51743858251528089 \cdot 10^{56}:\\
\;\;\;\;\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\left(\log base \cdot \left(2 \cdot \log \left(\sqrt[3]{base}\right)\right) + \log base \cdot \log \left(\sqrt[3]{base}\right)\right) + 0.0 \cdot 0.0}\\

\mathbf{else}:\\
\;\;\;\;\frac{\log \left(\frac{1}{re}\right)}{\log \left(\frac{1}{base}\right)}\\

\end{array}
double f(double re, double im, double base) {
        double r45950 = re;
        double r45951 = r45950 * r45950;
        double r45952 = im;
        double r45953 = r45952 * r45952;
        double r45954 = r45951 + r45953;
        double r45955 = sqrt(r45954);
        double r45956 = log(r45955);
        double r45957 = base;
        double r45958 = log(r45957);
        double r45959 = r45956 * r45958;
        double r45960 = atan2(r45952, r45950);
        double r45961 = 0.0;
        double r45962 = r45960 * r45961;
        double r45963 = r45959 + r45962;
        double r45964 = r45958 * r45958;
        double r45965 = r45961 * r45961;
        double r45966 = r45964 + r45965;
        double r45967 = r45963 / r45966;
        return r45967;
}

double f(double re, double im, double base) {
        double r45968 = re;
        double r45969 = -1.6143965812033716e+43;
        bool r45970 = r45968 <= r45969;
        double r45971 = -1.0;
        double r45972 = r45971 * r45968;
        double r45973 = log(r45972);
        double r45974 = base;
        double r45975 = log(r45974);
        double r45976 = r45973 * r45975;
        double r45977 = im;
        double r45978 = atan2(r45977, r45968);
        double r45979 = 0.0;
        double r45980 = r45978 * r45979;
        double r45981 = r45976 + r45980;
        double r45982 = r45975 * r45975;
        double r45983 = r45979 * r45979;
        double r45984 = r45982 + r45983;
        double r45985 = sqrt(r45984);
        double r45986 = r45981 / r45985;
        double r45987 = r45986 / r45985;
        double r45988 = 2.517438582515281e+56;
        bool r45989 = r45968 <= r45988;
        double r45990 = r45968 * r45968;
        double r45991 = r45977 * r45977;
        double r45992 = r45990 + r45991;
        double r45993 = sqrt(r45992);
        double r45994 = log(r45993);
        double r45995 = r45994 * r45975;
        double r45996 = r45995 + r45980;
        double r45997 = 2.0;
        double r45998 = cbrt(r45974);
        double r45999 = log(r45998);
        double r46000 = r45997 * r45999;
        double r46001 = r45975 * r46000;
        double r46002 = r45975 * r45999;
        double r46003 = r46001 + r46002;
        double r46004 = r46003 + r45983;
        double r46005 = r45996 / r46004;
        double r46006 = 1.0;
        double r46007 = r46006 / r45968;
        double r46008 = log(r46007);
        double r46009 = r46006 / r45974;
        double r46010 = log(r46009);
        double r46011 = r46008 / r46010;
        double r46012 = r45989 ? r46005 : r46011;
        double r46013 = r45970 ? r45987 : r46012;
        return r46013;
}

Error

Bits error versus re

Bits error versus im

Bits error versus base

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 3 regimes
  2. if re < -1.6143965812033716e+43

    1. Initial program 44.1

      \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\log base \cdot \log base + 0.0 \cdot 0.0}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt44.1

      \[\leadsto \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\color{blue}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0} \cdot \sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}}\]
    4. Applied associate-/r*44.1

      \[\leadsto \color{blue}{\frac{\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}}\]
    5. Taylor expanded around -inf 10.8

      \[\leadsto \frac{\frac{\log \color{blue}{\left(-1 \cdot re\right)} \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}\]

    if -1.6143965812033716e+43 < re < 2.517438582515281e+56

    1. Initial program 23.2

      \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\log base \cdot \log base + 0.0 \cdot 0.0}\]
    2. Using strategy rm
    3. Applied add-cube-cbrt23.2

      \[\leadsto \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\log base \cdot \log \color{blue}{\left(\left(\sqrt[3]{base} \cdot \sqrt[3]{base}\right) \cdot \sqrt[3]{base}\right)} + 0.0 \cdot 0.0}\]
    4. Applied log-prod23.3

      \[\leadsto \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\log base \cdot \color{blue}{\left(\log \left(\sqrt[3]{base} \cdot \sqrt[3]{base}\right) + \log \left(\sqrt[3]{base}\right)\right)} + 0.0 \cdot 0.0}\]
    5. Applied distribute-lft-in23.3

      \[\leadsto \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\color{blue}{\left(\log base \cdot \log \left(\sqrt[3]{base} \cdot \sqrt[3]{base}\right) + \log base \cdot \log \left(\sqrt[3]{base}\right)\right)} + 0.0 \cdot 0.0}\]
    6. Simplified23.3

      \[\leadsto \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\left(\color{blue}{\log base \cdot \left(2 \cdot \log \left(\sqrt[3]{base}\right)\right)} + \log base \cdot \log \left(\sqrt[3]{base}\right)\right) + 0.0 \cdot 0.0}\]

    if 2.517438582515281e+56 < re

    1. Initial program 45.4

      \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\log base \cdot \log base + 0.0 \cdot 0.0}\]
    2. Taylor expanded around inf 11.4

      \[\leadsto \color{blue}{\frac{\log \left(\frac{1}{re}\right)}{\log \left(\frac{1}{base}\right)}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification18.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \le -1.6143965812033716 \cdot 10^{43}:\\ \;\;\;\;\frac{\frac{\log \left(-1 \cdot re\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}}{\sqrt{\log base \cdot \log base + 0.0 \cdot 0.0}}\\ \mathbf{elif}\;re \le 2.51743858251528089 \cdot 10^{56}:\\ \;\;\;\;\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\left(\log base \cdot \left(2 \cdot \log \left(\sqrt[3]{base}\right)\right) + \log base \cdot \log \left(\sqrt[3]{base}\right)\right) + 0.0 \cdot 0.0}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log \left(\frac{1}{re}\right)}{\log \left(\frac{1}{base}\right)}\\ \end{array}\]

Reproduce

herbie shell --seed 2020027 
(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))))