Average Error: 31.0 → 17.5
Time: 1.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 -4.641395323766435 \cdot 10^{+157}:\\ \;\;\;\;\frac{-\sqrt[3]{\left(\log \left(\frac{-1}{re}\right) \cdot \log \left(\frac{-1}{re}\right)\right) \cdot \log \left(\frac{-1}{re}\right)}}{\log base}\\ \mathbf{elif}\;im \le -5.446977075069018 \cdot 10^{-152}:\\ \;\;\;\;\frac{\log \left(\sqrt{im \cdot im + re \cdot re}\right)}{\log base}\\ \mathbf{elif}\;im \le 7.993197017950823 \cdot 10^{-143}:\\ \;\;\;\;\frac{-1}{\frac{\log base}{\log \left(\frac{-1}{re}\right)}}\\ \mathbf{elif}\;im \le 2.310383428093748 \cdot 10^{+153}:\\ \;\;\;\;\frac{\log base \cdot \log \left(\sqrt{im \cdot im + re \cdot re}\right)}{\log \left(\sqrt[3]{base} \cdot \sqrt[3]{base}\right) \cdot \log base + \log \left(\sqrt[3]{base}\right) \cdot \log base}\\ \mathbf{elif}\;im \le 1.65518060911004 \cdot 10^{+177}:\\ \;\;\;\;\frac{-1}{\log base} \cdot \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 -4.641395323766435 \cdot 10^{+157}:\\
\;\;\;\;\frac{-\sqrt[3]{\left(\log \left(\frac{-1}{re}\right) \cdot \log \left(\frac{-1}{re}\right)\right) \cdot \log \left(\frac{-1}{re}\right)}}{\log base}\\

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

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

\mathbf{elif}\;im \le 2.310383428093748 \cdot 10^{+153}:\\
\;\;\;\;\frac{\log base \cdot \log \left(\sqrt{im \cdot im + re \cdot re}\right)}{\log \left(\sqrt[3]{base} \cdot \sqrt[3]{base}\right) \cdot \log base + \log \left(\sqrt[3]{base}\right) \cdot \log base}\\

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

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

\end{array}
double f(double re, double im, double base) {
        double r1998644 = re;
        double r1998645 = r1998644 * r1998644;
        double r1998646 = im;
        double r1998647 = r1998646 * r1998646;
        double r1998648 = r1998645 + r1998647;
        double r1998649 = sqrt(r1998648);
        double r1998650 = log(r1998649);
        double r1998651 = base;
        double r1998652 = log(r1998651);
        double r1998653 = r1998650 * r1998652;
        double r1998654 = atan2(r1998646, r1998644);
        double r1998655 = 0.0;
        double r1998656 = r1998654 * r1998655;
        double r1998657 = r1998653 + r1998656;
        double r1998658 = r1998652 * r1998652;
        double r1998659 = r1998655 * r1998655;
        double r1998660 = r1998658 + r1998659;
        double r1998661 = r1998657 / r1998660;
        return r1998661;
}

double f(double re, double im, double base) {
        double r1998662 = im;
        double r1998663 = -4.641395323766435e+157;
        bool r1998664 = r1998662 <= r1998663;
        double r1998665 = -1.0;
        double r1998666 = re;
        double r1998667 = r1998665 / r1998666;
        double r1998668 = log(r1998667);
        double r1998669 = r1998668 * r1998668;
        double r1998670 = r1998669 * r1998668;
        double r1998671 = cbrt(r1998670);
        double r1998672 = -r1998671;
        double r1998673 = base;
        double r1998674 = log(r1998673);
        double r1998675 = r1998672 / r1998674;
        double r1998676 = -5.446977075069018e-152;
        bool r1998677 = r1998662 <= r1998676;
        double r1998678 = r1998662 * r1998662;
        double r1998679 = r1998666 * r1998666;
        double r1998680 = r1998678 + r1998679;
        double r1998681 = sqrt(r1998680);
        double r1998682 = log(r1998681);
        double r1998683 = r1998682 / r1998674;
        double r1998684 = 7.993197017950823e-143;
        bool r1998685 = r1998662 <= r1998684;
        double r1998686 = r1998674 / r1998668;
        double r1998687 = r1998665 / r1998686;
        double r1998688 = 2.310383428093748e+153;
        bool r1998689 = r1998662 <= r1998688;
        double r1998690 = r1998674 * r1998682;
        double r1998691 = cbrt(r1998673);
        double r1998692 = r1998691 * r1998691;
        double r1998693 = log(r1998692);
        double r1998694 = r1998693 * r1998674;
        double r1998695 = log(r1998691);
        double r1998696 = r1998695 * r1998674;
        double r1998697 = r1998694 + r1998696;
        double r1998698 = r1998690 / r1998697;
        double r1998699 = 1.65518060911004e+177;
        bool r1998700 = r1998662 <= r1998699;
        double r1998701 = r1998665 / r1998674;
        double r1998702 = r1998701 * r1998668;
        double r1998703 = log(r1998662);
        double r1998704 = r1998703 / r1998674;
        double r1998705 = r1998700 ? r1998702 : r1998704;
        double r1998706 = r1998689 ? r1998698 : r1998705;
        double r1998707 = r1998685 ? r1998687 : r1998706;
        double r1998708 = r1998677 ? r1998683 : r1998707;
        double r1998709 = r1998664 ? r1998675 : r1998708;
        return r1998709;
}

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 6 regimes
  2. if im < -4.641395323766435e+157

    1. Initial program 62.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. Simplified62.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. Simplified52.7

      \[\leadsto \color{blue}{-\frac{\log \left(\frac{-1}{re}\right)}{0 + \log base}}\]
    5. Using strategy rm
    6. Applied add-cbrt-cube52.7

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

    if -4.641395323766435e+157 < im < -5.446977075069018e-152

    1. Initial program 15.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. Simplified15.8

      \[\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-/r*15.7

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

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

    if -5.446977075069018e-152 < im < 7.993197017950823e-143

    1. Initial program 30.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. Simplified30.1

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

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

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

      \[\leadsto -\frac{\color{blue}{1 \cdot \log \left(\frac{-1}{re}\right)}}{0 + \log base}\]
    8. Applied associate-/l*7.1

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

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

    if 7.993197017950823e-143 < im < 2.310383428093748e+153

    1. Initial program 15.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. Simplified15.6

      \[\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 add-cube-cbrt15.7

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

      \[\leadsto \frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base}{\log base \cdot \color{blue}{\left(\log \left(\sqrt[3]{base} \cdot \sqrt[3]{base}\right) + \log \left(\sqrt[3]{base}\right)\right)}}\]
    6. Applied distribute-rgt-in15.7

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

    if 2.310383428093748e+153 < im < 1.65518060911004e+177

    1. Initial program 58.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. Simplified58.8

      \[\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. Simplified45.6

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

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

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

    if 1.65518060911004e+177 < im

    1. Initial program 62.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. Simplified62.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 0 5.6

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \le -4.641395323766435 \cdot 10^{+157}:\\ \;\;\;\;\frac{-\sqrt[3]{\left(\log \left(\frac{-1}{re}\right) \cdot \log \left(\frac{-1}{re}\right)\right) \cdot \log \left(\frac{-1}{re}\right)}}{\log base}\\ \mathbf{elif}\;im \le -5.446977075069018 \cdot 10^{-152}:\\ \;\;\;\;\frac{\log \left(\sqrt{im \cdot im + re \cdot re}\right)}{\log base}\\ \mathbf{elif}\;im \le 7.993197017950823 \cdot 10^{-143}:\\ \;\;\;\;\frac{-1}{\frac{\log base}{\log \left(\frac{-1}{re}\right)}}\\ \mathbf{elif}\;im \le 2.310383428093748 \cdot 10^{+153}:\\ \;\;\;\;\frac{\log base \cdot \log \left(\sqrt{im \cdot im + re \cdot re}\right)}{\log \left(\sqrt[3]{base} \cdot \sqrt[3]{base}\right) \cdot \log base + \log \left(\sqrt[3]{base}\right) \cdot \log base}\\ \mathbf{elif}\;im \le 1.65518060911004 \cdot 10^{+177}:\\ \;\;\;\;\frac{-1}{\log base} \cdot \log \left(\frac{-1}{re}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\log im}{\log base}\\ \end{array}\]

Reproduce

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