Average Error: 31.8 → 17.5
Time: 22.9s
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 -8.113334361781795614086386524572079665577 \cdot 10^{60}:\\ \;\;\;\;\frac{\log \left(\frac{-1}{re}\right)}{\log base} \cdot -1\\ \mathbf{elif}\;re \le 1.175287900420155614094294619868397805098 \cdot 10^{71}:\\ \;\;\;\;\frac{\log base \cdot \log \left(\sqrt{im \cdot im + re \cdot re}\right) + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\left(\log base \cdot \log \left(\sqrt[3]{base}\right) + \left(\log base + \log base\right) \cdot \log \left(\sqrt[3]{base}\right)\right) + 0.0 \cdot 0.0}\\ \mathbf{else}:\\ \;\;\;\;\frac{-\log re}{-\log base}\\ \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 -8.113334361781795614086386524572079665577 \cdot 10^{60}:\\
\;\;\;\;\frac{\log \left(\frac{-1}{re}\right)}{\log base} \cdot -1\\

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

\mathbf{else}:\\
\;\;\;\;\frac{-\log re}{-\log base}\\

\end{array}
double f(double re, double im, double base) {
        double r2854778 = re;
        double r2854779 = r2854778 * r2854778;
        double r2854780 = im;
        double r2854781 = r2854780 * r2854780;
        double r2854782 = r2854779 + r2854781;
        double r2854783 = sqrt(r2854782);
        double r2854784 = log(r2854783);
        double r2854785 = base;
        double r2854786 = log(r2854785);
        double r2854787 = r2854784 * r2854786;
        double r2854788 = atan2(r2854780, r2854778);
        double r2854789 = 0.0;
        double r2854790 = r2854788 * r2854789;
        double r2854791 = r2854787 + r2854790;
        double r2854792 = r2854786 * r2854786;
        double r2854793 = r2854789 * r2854789;
        double r2854794 = r2854792 + r2854793;
        double r2854795 = r2854791 / r2854794;
        return r2854795;
}

double f(double re, double im, double base) {
        double r2854796 = re;
        double r2854797 = -8.113334361781796e+60;
        bool r2854798 = r2854796 <= r2854797;
        double r2854799 = -1.0;
        double r2854800 = r2854799 / r2854796;
        double r2854801 = log(r2854800);
        double r2854802 = base;
        double r2854803 = log(r2854802);
        double r2854804 = r2854801 / r2854803;
        double r2854805 = r2854804 * r2854799;
        double r2854806 = 1.1752879004201556e+71;
        bool r2854807 = r2854796 <= r2854806;
        double r2854808 = im;
        double r2854809 = r2854808 * r2854808;
        double r2854810 = r2854796 * r2854796;
        double r2854811 = r2854809 + r2854810;
        double r2854812 = sqrt(r2854811);
        double r2854813 = log(r2854812);
        double r2854814 = r2854803 * r2854813;
        double r2854815 = atan2(r2854808, r2854796);
        double r2854816 = 0.0;
        double r2854817 = r2854815 * r2854816;
        double r2854818 = r2854814 + r2854817;
        double r2854819 = cbrt(r2854802);
        double r2854820 = log(r2854819);
        double r2854821 = r2854803 * r2854820;
        double r2854822 = r2854803 + r2854803;
        double r2854823 = r2854822 * r2854820;
        double r2854824 = r2854821 + r2854823;
        double r2854825 = r2854816 * r2854816;
        double r2854826 = r2854824 + r2854825;
        double r2854827 = r2854818 / r2854826;
        double r2854828 = log(r2854796);
        double r2854829 = -r2854828;
        double r2854830 = -r2854803;
        double r2854831 = r2854829 / r2854830;
        double r2854832 = r2854807 ? r2854827 : r2854831;
        double r2854833 = r2854798 ? r2854805 : r2854832;
        return r2854833;
}

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 < -8.113334361781796e+60

    1. Initial program 46.0

      \[\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 64.0

      \[\leadsto \color{blue}{-1 \cdot \frac{\log \left(\frac{-1}{re}\right)}{\log -1 - \log \left(\frac{-1}{base}\right)}}\]
    3. Simplified9.9

      \[\leadsto \color{blue}{-1 \cdot \frac{\log \left(\frac{-1}{re}\right)}{0 + \log base}}\]

    if -8.113334361781796e+60 < re < 1.1752879004201556e+71

    1. Initial program 22.3

      \[\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-cbrt22.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 \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-prod22.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-in22.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. Simplified22.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 \left(\sqrt[3]{base}\right) \cdot \left(\log base + \log base\right)} + \log base \cdot \log \left(\sqrt[3]{base}\right)\right) + 0.0 \cdot 0.0}\]

    if 1.1752879004201556e+71 < re

    1. Initial program 46.8

      \[\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 10.6

      \[\leadsto \color{blue}{\frac{\log \left(\frac{1}{re}\right)}{\log \left(\frac{1}{base}\right)}}\]
    3. Simplified10.5

      \[\leadsto \color{blue}{-\frac{\log re}{-\log base}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification17.5

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

Reproduce

herbie shell --seed 2019170 
(FPCore (re im base)
  :name "math.log/2 on complex, real part"
  (/ (+ (* (log (sqrt (+ (* re re) (* im im)))) (log base)) (* (atan2 im re) 0.0)) (+ (* (log base) (log base)) (* 0.0 0.0))))