Average Error: 31.0 → 17.2
Time: 59.2s
Precision: 64
\[\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 \le -1.4436943356181515 \cdot 10^{+77}:\\ \;\;\;\;\frac{-\log \left(\frac{-1}{re}\right)}{\log base}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log \left(\sqrt{im \cdot im + re \cdot re}\right)}{\frac{\log base \cdot \log base}{\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}{\log base \cdot \log base + 0 \cdot 0}
\begin{array}{l}
\mathbf{if}\;re \le -1.4436943356181515 \cdot 10^{+77}:\\
\;\;\;\;\frac{-\log \left(\frac{-1}{re}\right)}{\log base}\\

\mathbf{else}:\\
\;\;\;\;\frac{\log \left(\sqrt{im \cdot im + re \cdot re}\right)}{\frac{\log base \cdot \log base}{\log base}}\\

\end{array}
double f(double re, double im, double base) {
        double r1735107 = re;
        double r1735108 = r1735107 * r1735107;
        double r1735109 = im;
        double r1735110 = r1735109 * r1735109;
        double r1735111 = r1735108 + r1735110;
        double r1735112 = sqrt(r1735111);
        double r1735113 = log(r1735112);
        double r1735114 = base;
        double r1735115 = log(r1735114);
        double r1735116 = r1735113 * r1735115;
        double r1735117 = atan2(r1735109, r1735107);
        double r1735118 = 0.0;
        double r1735119 = r1735117 * r1735118;
        double r1735120 = r1735116 + r1735119;
        double r1735121 = r1735115 * r1735115;
        double r1735122 = r1735118 * r1735118;
        double r1735123 = r1735121 + r1735122;
        double r1735124 = r1735120 / r1735123;
        return r1735124;
}

double f(double re, double im, double base) {
        double r1735125 = re;
        double r1735126 = -1.4436943356181515e+77;
        bool r1735127 = r1735125 <= r1735126;
        double r1735128 = -1.0;
        double r1735129 = r1735128 / r1735125;
        double r1735130 = log(r1735129);
        double r1735131 = -r1735130;
        double r1735132 = base;
        double r1735133 = log(r1735132);
        double r1735134 = r1735131 / r1735133;
        double r1735135 = im;
        double r1735136 = r1735135 * r1735135;
        double r1735137 = r1735125 * r1735125;
        double r1735138 = r1735136 + r1735137;
        double r1735139 = sqrt(r1735138);
        double r1735140 = log(r1735139);
        double r1735141 = r1735133 * r1735133;
        double r1735142 = r1735141 / r1735133;
        double r1735143 = r1735140 / r1735142;
        double r1735144 = r1735127 ? r1735134 : r1735143;
        return r1735144;
}

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 2 regimes
  2. if re < -1.4436943356181515e+77

    1. Initial program 46.9

      \[\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}\]
    2. Simplified46.9

      \[\leadsto \color{blue}{\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base}{\log base \cdot \log base}}\]
    3. Taylor expanded around -inf 62.8

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

      \[\leadsto \color{blue}{-\frac{\log \left(\frac{-1}{re}\right)}{\log base}}\]
    5. Taylor expanded around -inf 62.8

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

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

    if -1.4436943356181515e+77 < re

    1. Initial program 21.5

      \[\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}\]
    2. Simplified21.5

      \[\leadsto \color{blue}{\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base}{\log base \cdot \log base}}\]
    3. Using strategy rm
    4. Applied associate-/l*21.4

      \[\leadsto \color{blue}{\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\frac{\log base \cdot \log base}{\log base}}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification17.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \le -1.4436943356181515 \cdot 10^{+77}:\\ \;\;\;\;\frac{-\log \left(\frac{-1}{re}\right)}{\log base}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log \left(\sqrt{im \cdot im + re \cdot re}\right)}{\frac{\log base \cdot \log base}{\log base}}\\ \end{array}\]

Reproduce

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