Average Error: 31.0 → 17.1
Time: 17.7s
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.4571941010285686 \cdot 10^{+94}:\\ \;\;\;\;\log \left(-re\right) \cdot \frac{1}{\log base}\\ \mathbf{elif}\;re \le 1.2874468181519675 \cdot 10^{+101}:\\ \;\;\;\;\frac{\tan^{-1}_* \frac{im}{re} \cdot 0 + \log \left(\sqrt{im \cdot im + re \cdot re}\right) \cdot \log base}{\log base \cdot \log \left(\sqrt[3]{base}\right) + \log \left(\sqrt[3]{base} \cdot \sqrt[3]{base}\right) \cdot \log base}\\ \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}{\log base \cdot \log base + 0 \cdot 0}
\begin{array}{l}
\mathbf{if}\;re \le -1.4571941010285686 \cdot 10^{+94}:\\
\;\;\;\;\log \left(-re\right) \cdot \frac{1}{\log base}\\

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

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

\end{array}
double f(double re, double im, double base) {
        double r758517 = re;
        double r758518 = r758517 * r758517;
        double r758519 = im;
        double r758520 = r758519 * r758519;
        double r758521 = r758518 + r758520;
        double r758522 = sqrt(r758521);
        double r758523 = log(r758522);
        double r758524 = base;
        double r758525 = log(r758524);
        double r758526 = r758523 * r758525;
        double r758527 = atan2(r758519, r758517);
        double r758528 = 0.0;
        double r758529 = r758527 * r758528;
        double r758530 = r758526 + r758529;
        double r758531 = r758525 * r758525;
        double r758532 = r758528 * r758528;
        double r758533 = r758531 + r758532;
        double r758534 = r758530 / r758533;
        return r758534;
}

double f(double re, double im, double base) {
        double r758535 = re;
        double r758536 = -1.4571941010285686e+94;
        bool r758537 = r758535 <= r758536;
        double r758538 = -r758535;
        double r758539 = log(r758538);
        double r758540 = 1.0;
        double r758541 = base;
        double r758542 = log(r758541);
        double r758543 = r758540 / r758542;
        double r758544 = r758539 * r758543;
        double r758545 = 1.2874468181519675e+101;
        bool r758546 = r758535 <= r758545;
        double r758547 = im;
        double r758548 = atan2(r758547, r758535);
        double r758549 = 0.0;
        double r758550 = r758548 * r758549;
        double r758551 = r758547 * r758547;
        double r758552 = r758535 * r758535;
        double r758553 = r758551 + r758552;
        double r758554 = sqrt(r758553);
        double r758555 = log(r758554);
        double r758556 = r758555 * r758542;
        double r758557 = r758550 + r758556;
        double r758558 = cbrt(r758541);
        double r758559 = log(r758558);
        double r758560 = r758542 * r758559;
        double r758561 = r758558 * r758558;
        double r758562 = log(r758561);
        double r758563 = r758562 * r758542;
        double r758564 = r758560 + r758563;
        double r758565 = r758557 / r758564;
        double r758566 = log(r758535);
        double r758567 = r758566 / r758542;
        double r758568 = r758546 ? r758565 : r758567;
        double r758569 = r758537 ? r758544 : r758568;
        return r758569;
}

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.4571941010285686e+94

    1. Initial program 48.7

      \[\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. Simplified48.7

      \[\leadsto \color{blue}{\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}{\log base}}\]
    3. Using strategy rm
    4. Applied div-inv48.7

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

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

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

    if -1.4571941010285686e+94 < re < 1.2874468181519675e+101

    1. Initial program 21.6

      \[\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. Using strategy rm
    3. Applied add-cube-cbrt21.6

      \[\leadsto \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 \color{blue}{\left(\left(\sqrt[3]{base} \cdot \sqrt[3]{base}\right) \cdot \sqrt[3]{base}\right)} + 0 \cdot 0}\]
    4. Applied log-prod21.6

      \[\leadsto \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 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 \cdot 0}\]
    5. Applied distribute-rgt-in21.6

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

    if 1.2874468181519675e+101 < re

    1. Initial program 49.8

      \[\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. Simplified49.8

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \le -1.4571941010285686 \cdot 10^{+94}:\\ \;\;\;\;\log \left(-re\right) \cdot \frac{1}{\log base}\\ \mathbf{elif}\;re \le 1.2874468181519675 \cdot 10^{+101}:\\ \;\;\;\;\frac{\tan^{-1}_* \frac{im}{re} \cdot 0 + \log \left(\sqrt{im \cdot im + re \cdot re}\right) \cdot \log base}{\log base \cdot \log \left(\sqrt[3]{base}\right) + \log \left(\sqrt[3]{base} \cdot \sqrt[3]{base}\right) \cdot \log base}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log re}{\log base}\\ \end{array}\]

Reproduce

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