Average Error: 30.5 → 16.7
Time: 33.9s
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 -3.6968101048126143 \cdot 10^{+124}:\\ \;\;\;\;\frac{-1}{\frac{\log base}{\log \left(\frac{-1}{re}\right)}}\\ \mathbf{elif}\;re \le -3.1320614430937276 \cdot 10^{-251}:\\ \;\;\;\;\frac{1}{\log base} \cdot \log \left(\sqrt{im \cdot im + re \cdot re}\right)\\ \mathbf{elif}\;re \le 3.674093895449681 \cdot 10^{-292}:\\ \;\;\;\;\frac{\log im}{\log base}\\ \mathbf{elif}\;re \le 2.812956885343136 \cdot 10^{+65}:\\ \;\;\;\;\frac{1}{\log base} \cdot \log \left(\sqrt{im \cdot im + re \cdot re}\right)\\ \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 -3.6968101048126143 \cdot 10^{+124}:\\
\;\;\;\;\frac{-1}{\frac{\log base}{\log \left(\frac{-1}{re}\right)}}\\

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

\mathbf{elif}\;re \le 3.674093895449681 \cdot 10^{-292}:\\
\;\;\;\;\frac{\log im}{\log base}\\

\mathbf{elif}\;re \le 2.812956885343136 \cdot 10^{+65}:\\
\;\;\;\;\frac{1}{\log base} \cdot \log \left(\sqrt{im \cdot im + re \cdot re}\right)\\

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

\end{array}
double f(double re, double im, double base) {
        double r2326627 = re;
        double r2326628 = r2326627 * r2326627;
        double r2326629 = im;
        double r2326630 = r2326629 * r2326629;
        double r2326631 = r2326628 + r2326630;
        double r2326632 = sqrt(r2326631);
        double r2326633 = log(r2326632);
        double r2326634 = base;
        double r2326635 = log(r2326634);
        double r2326636 = r2326633 * r2326635;
        double r2326637 = atan2(r2326629, r2326627);
        double r2326638 = 0.0;
        double r2326639 = r2326637 * r2326638;
        double r2326640 = r2326636 + r2326639;
        double r2326641 = r2326635 * r2326635;
        double r2326642 = r2326638 * r2326638;
        double r2326643 = r2326641 + r2326642;
        double r2326644 = r2326640 / r2326643;
        return r2326644;
}

double f(double re, double im, double base) {
        double r2326645 = re;
        double r2326646 = -3.6968101048126143e+124;
        bool r2326647 = r2326645 <= r2326646;
        double r2326648 = -1.0;
        double r2326649 = base;
        double r2326650 = log(r2326649);
        double r2326651 = r2326648 / r2326645;
        double r2326652 = log(r2326651);
        double r2326653 = r2326650 / r2326652;
        double r2326654 = r2326648 / r2326653;
        double r2326655 = -3.1320614430937276e-251;
        bool r2326656 = r2326645 <= r2326655;
        double r2326657 = 1.0;
        double r2326658 = r2326657 / r2326650;
        double r2326659 = im;
        double r2326660 = r2326659 * r2326659;
        double r2326661 = r2326645 * r2326645;
        double r2326662 = r2326660 + r2326661;
        double r2326663 = sqrt(r2326662);
        double r2326664 = log(r2326663);
        double r2326665 = r2326658 * r2326664;
        double r2326666 = 3.674093895449681e-292;
        bool r2326667 = r2326645 <= r2326666;
        double r2326668 = log(r2326659);
        double r2326669 = r2326668 / r2326650;
        double r2326670 = 2.812956885343136e+65;
        bool r2326671 = r2326645 <= r2326670;
        double r2326672 = log(r2326645);
        double r2326673 = -r2326650;
        double r2326674 = r2326672 / r2326673;
        double r2326675 = -r2326674;
        double r2326676 = r2326671 ? r2326665 : r2326675;
        double r2326677 = r2326667 ? r2326669 : r2326676;
        double r2326678 = r2326656 ? r2326665 : r2326677;
        double r2326679 = r2326647 ? r2326654 : r2326678;
        return r2326679;
}

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 4 regimes
  2. if re < -3.6968101048126143e+124

    1. Initial program 54.1

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

      \[\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 div-inv54.1

      \[\leadsto \color{blue}{\left(\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base\right) \cdot \frac{1}{\log base \cdot \log base}}\]
    5. 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)}}\]
    6. Simplified8.5

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

    if -3.6968101048126143e+124 < re < -3.1320614430937276e-251 or 3.674093895449681e-292 < re < 2.812956885343136e+65

    1. Initial program 19.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. Simplified19.3

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

      \[\leadsto \color{blue}{\left(\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base\right) \cdot \frac{1}{\log base \cdot \log base}}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity19.3

      \[\leadsto \left(\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base\right) \cdot \frac{\color{blue}{1 \cdot 1}}{\log base \cdot \log base}\]
    7. Applied times-frac19.4

      \[\leadsto \left(\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base\right) \cdot \color{blue}{\left(\frac{1}{\log base} \cdot \frac{1}{\log base}\right)}\]
    8. Applied associate-*r*19.3

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

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

    if -3.1320614430937276e-251 < re < 3.674093895449681e-292

    1. Initial program 31.4

      \[\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. Simplified31.4

      \[\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 div-inv31.4

      \[\leadsto \color{blue}{\left(\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base\right) \cdot \frac{1}{\log base \cdot \log base}}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity31.4

      \[\leadsto \left(\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base\right) \cdot \frac{\color{blue}{1 \cdot 1}}{\log base \cdot \log base}\]
    7. Applied times-frac31.5

      \[\leadsto \left(\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base\right) \cdot \color{blue}{\left(\frac{1}{\log base} \cdot \frac{1}{\log base}\right)}\]
    8. Applied associate-*r*31.4

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

      \[\leadsto \color{blue}{\log \left(\sqrt{re \cdot re + im \cdot im}\right)} \cdot \frac{1}{\log base}\]
    10. Taylor expanded around 0 32.7

      \[\leadsto \color{blue}{\frac{\log im}{\log base}}\]

    if 2.812956885343136e+65 < re

    1. Initial program 45.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. Simplified45.5

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \le -3.6968101048126143 \cdot 10^{+124}:\\ \;\;\;\;\frac{-1}{\frac{\log base}{\log \left(\frac{-1}{re}\right)}}\\ \mathbf{elif}\;re \le -3.1320614430937276 \cdot 10^{-251}:\\ \;\;\;\;\frac{1}{\log base} \cdot \log \left(\sqrt{im \cdot im + re \cdot re}\right)\\ \mathbf{elif}\;re \le 3.674093895449681 \cdot 10^{-292}:\\ \;\;\;\;\frac{\log im}{\log base}\\ \mathbf{elif}\;re \le 2.812956885343136 \cdot 10^{+65}:\\ \;\;\;\;\frac{1}{\log base} \cdot \log \left(\sqrt{im \cdot im + re \cdot re}\right)\\ \mathbf{else}:\\ \;\;\;\;-\frac{\log re}{-\log base}\\ \end{array}\]

Reproduce

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