Average Error: 31.6 → 18.6
Time: 2.1m
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}\;im \le -5.735447606728807 \cdot 10^{+130}:\\ \;\;\;\;\frac{\frac{-1}{\log base}}{\frac{1}{\log \left(\frac{-1}{re}\right)}}\\ \mathbf{elif}\;im \le -1.2998224613174538 \cdot 10^{-117}:\\ \;\;\;\;\frac{\log \left(\sqrt{im \cdot im + re \cdot re}\right)}{\log base}\\ \mathbf{elif}\;im \le 1.0068101208598963 \cdot 10^{-09}:\\ \;\;\;\;\frac{\frac{-1}{\log base}}{\frac{1}{\log \left(\frac{-1}{re}\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log im}{\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}\;im \le -5.735447606728807 \cdot 10^{+130}:\\
\;\;\;\;\frac{\frac{-1}{\log base}}{\frac{1}{\log \left(\frac{-1}{re}\right)}}\\

\mathbf{elif}\;im \le -1.2998224613174538 \cdot 10^{-117}:\\
\;\;\;\;\frac{\log \left(\sqrt{im \cdot im + re \cdot re}\right)}{\log base}\\

\mathbf{elif}\;im \le 1.0068101208598963 \cdot 10^{-09}:\\
\;\;\;\;\frac{\frac{-1}{\log base}}{\frac{1}{\log \left(\frac{-1}{re}\right)}}\\

\mathbf{else}:\\
\;\;\;\;\frac{\log im}{\log base}\\

\end{array}
double f(double re, double im, double base) {
        double r2914392 = re;
        double r2914393 = r2914392 * r2914392;
        double r2914394 = im;
        double r2914395 = r2914394 * r2914394;
        double r2914396 = r2914393 + r2914395;
        double r2914397 = sqrt(r2914396);
        double r2914398 = log(r2914397);
        double r2914399 = base;
        double r2914400 = log(r2914399);
        double r2914401 = r2914398 * r2914400;
        double r2914402 = atan2(r2914394, r2914392);
        double r2914403 = 0.0;
        double r2914404 = r2914402 * r2914403;
        double r2914405 = r2914401 + r2914404;
        double r2914406 = r2914400 * r2914400;
        double r2914407 = r2914403 * r2914403;
        double r2914408 = r2914406 + r2914407;
        double r2914409 = r2914405 / r2914408;
        return r2914409;
}

double f(double re, double im, double base) {
        double r2914410 = im;
        double r2914411 = -5.735447606728807e+130;
        bool r2914412 = r2914410 <= r2914411;
        double r2914413 = -1.0;
        double r2914414 = base;
        double r2914415 = log(r2914414);
        double r2914416 = r2914413 / r2914415;
        double r2914417 = 1.0;
        double r2914418 = re;
        double r2914419 = r2914413 / r2914418;
        double r2914420 = log(r2914419);
        double r2914421 = r2914417 / r2914420;
        double r2914422 = r2914416 / r2914421;
        double r2914423 = -1.2998224613174538e-117;
        bool r2914424 = r2914410 <= r2914423;
        double r2914425 = r2914410 * r2914410;
        double r2914426 = r2914418 * r2914418;
        double r2914427 = r2914425 + r2914426;
        double r2914428 = sqrt(r2914427);
        double r2914429 = log(r2914428);
        double r2914430 = r2914429 / r2914415;
        double r2914431 = 1.0068101208598963e-09;
        bool r2914432 = r2914410 <= r2914431;
        double r2914433 = log(r2914410);
        double r2914434 = r2914433 / r2914415;
        double r2914435 = r2914432 ? r2914422 : r2914434;
        double r2914436 = r2914424 ? r2914430 : r2914435;
        double r2914437 = r2914412 ? r2914422 : r2914436;
        return r2914437;
}

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 im < -5.735447606728807e+130 or -1.2998224613174538e-117 < im < 1.0068101208598963e-09

    1. Initial program 34.0

      \[\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. Simplified34.0

      \[\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. Simplified21.9

      \[\leadsto \color{blue}{-\frac{\log \left(\frac{-1}{re}\right)}{\log base}}\]
    5. Using strategy rm
    6. Applied clear-num22.0

      \[\leadsto -\color{blue}{\frac{1}{\frac{\log base}{\log \left(\frac{-1}{re}\right)}}}\]
    7. Using strategy rm
    8. Applied div-inv22.0

      \[\leadsto -\frac{1}{\color{blue}{\log base \cdot \frac{1}{\log \left(\frac{-1}{re}\right)}}}\]
    9. Applied associate-/r*22.0

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

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

    if -5.735447606728807e+130 < im < -1.2998224613174538e-117

    1. Initial program 15.2

      \[\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. Simplified15.2

      \[\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 times-frac15.1

      \[\leadsto \color{blue}{\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log base} \cdot \frac{\log base}{\log base}}\]
    5. Simplified15.1

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

    if 1.0068101208598963e-09 < im

    1. Initial program 39.3

      \[\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. Simplified39.3

      \[\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 0 14.1

      \[\leadsto \color{blue}{\frac{\log im}{\log base}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification18.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \le -5.735447606728807 \cdot 10^{+130}:\\ \;\;\;\;\frac{\frac{-1}{\log base}}{\frac{1}{\log \left(\frac{-1}{re}\right)}}\\ \mathbf{elif}\;im \le -1.2998224613174538 \cdot 10^{-117}:\\ \;\;\;\;\frac{\log \left(\sqrt{im \cdot im + re \cdot re}\right)}{\log base}\\ \mathbf{elif}\;im \le 1.0068101208598963 \cdot 10^{-09}:\\ \;\;\;\;\frac{\frac{-1}{\log base}}{\frac{1}{\log \left(\frac{-1}{re}\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log im}{\log base}\\ \end{array}\]

Reproduce

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