Average Error: 30.9 → 17.5
Time: 1.2m
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 -6.319225497138611 \cdot 10^{+155}:\\ \;\;\;\;\frac{\frac{\log \left(\frac{-1}{re}\right)}{\left(\log base \cdot \log base\right) \cdot \log base} \cdot \left(\left(\log base \cdot \log base\right) \cdot \left(\log base \cdot \log base\right)\right)}{-\left(\log base \cdot \log base - \log base \cdot 0\right)}\\ \mathbf{elif}\;im \le -9.784975811452057 \cdot 10^{+64}:\\ \;\;\;\;\frac{1}{\frac{\log base}{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}}\\ \mathbf{elif}\;im \le -3.7539404597618837 \cdot 10^{+52}:\\ \;\;\;\;\left(\log base \cdot \log base - \log base \cdot 0\right) \cdot \frac{-\frac{\log \left(\frac{-1}{re}\right)}{\log base \cdot \log base}}{\log base}\\ \mathbf{elif}\;im \le -1.5129456424795354 \cdot 10^{-88}:\\ \;\;\;\;\frac{1}{\frac{\log base}{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}}\\ \mathbf{elif}\;im \le 2.125432684072948 \cdot 10^{-114}:\\ \;\;\;\;\left(\log base \cdot \log base - \log base \cdot 0\right) \cdot \frac{-\frac{\log \left(\frac{-1}{re}\right)}{\log base \cdot \log base}}{\log base}\\ \mathbf{elif}\;im \le 1.731637496866189 \cdot 10^{-54}:\\ \;\;\;\;\frac{1}{\frac{\log base}{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}}\\ \mathbf{elif}\;im \le 1.3029063758199714 \cdot 10^{-09}:\\ \;\;\;\;\frac{\frac{\log \left(\frac{-1}{re}\right)}{\left(\log \left(\sqrt[3]{base}\right) \cdot \log base + \log \left(\sqrt[3]{base}\right) \cdot \log base\right) + \log \left(\sqrt[3]{base}\right) \cdot \log base}}{\log base} \cdot \left(-\left(\log base \cdot \log base - \log base \cdot 0\right)\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 -6.319225497138611 \cdot 10^{+155}:\\
\;\;\;\;\frac{\frac{\log \left(\frac{-1}{re}\right)}{\left(\log base \cdot \log base\right) \cdot \log base} \cdot \left(\left(\log base \cdot \log base\right) \cdot \left(\log base \cdot \log base\right)\right)}{-\left(\log base \cdot \log base - \log base \cdot 0\right)}\\

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

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

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

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

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

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

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

\end{array}
double f(double re, double im, double base) {
        double r1644661 = re;
        double r1644662 = r1644661 * r1644661;
        double r1644663 = im;
        double r1644664 = r1644663 * r1644663;
        double r1644665 = r1644662 + r1644664;
        double r1644666 = sqrt(r1644665);
        double r1644667 = log(r1644666);
        double r1644668 = base;
        double r1644669 = log(r1644668);
        double r1644670 = r1644667 * r1644669;
        double r1644671 = atan2(r1644663, r1644661);
        double r1644672 = 0.0;
        double r1644673 = r1644671 * r1644672;
        double r1644674 = r1644670 + r1644673;
        double r1644675 = r1644669 * r1644669;
        double r1644676 = r1644672 * r1644672;
        double r1644677 = r1644675 + r1644676;
        double r1644678 = r1644674 / r1644677;
        return r1644678;
}

double f(double re, double im, double base) {
        double r1644679 = im;
        double r1644680 = -6.319225497138611e+155;
        bool r1644681 = r1644679 <= r1644680;
        double r1644682 = -1.0;
        double r1644683 = re;
        double r1644684 = r1644682 / r1644683;
        double r1644685 = log(r1644684);
        double r1644686 = base;
        double r1644687 = log(r1644686);
        double r1644688 = r1644687 * r1644687;
        double r1644689 = r1644688 * r1644687;
        double r1644690 = r1644685 / r1644689;
        double r1644691 = r1644688 * r1644688;
        double r1644692 = r1644690 * r1644691;
        double r1644693 = 0.0;
        double r1644694 = r1644687 * r1644693;
        double r1644695 = r1644688 - r1644694;
        double r1644696 = -r1644695;
        double r1644697 = r1644692 / r1644696;
        double r1644698 = -9.784975811452057e+64;
        bool r1644699 = r1644679 <= r1644698;
        double r1644700 = 1.0;
        double r1644701 = r1644683 * r1644683;
        double r1644702 = r1644679 * r1644679;
        double r1644703 = r1644701 + r1644702;
        double r1644704 = sqrt(r1644703);
        double r1644705 = log(r1644704);
        double r1644706 = r1644687 / r1644705;
        double r1644707 = r1644700 / r1644706;
        double r1644708 = -3.7539404597618837e+52;
        bool r1644709 = r1644679 <= r1644708;
        double r1644710 = r1644685 / r1644688;
        double r1644711 = -r1644710;
        double r1644712 = r1644711 / r1644687;
        double r1644713 = r1644695 * r1644712;
        double r1644714 = -1.5129456424795354e-88;
        bool r1644715 = r1644679 <= r1644714;
        double r1644716 = 2.125432684072948e-114;
        bool r1644717 = r1644679 <= r1644716;
        double r1644718 = 1.731637496866189e-54;
        bool r1644719 = r1644679 <= r1644718;
        double r1644720 = 1.3029063758199714e-09;
        bool r1644721 = r1644679 <= r1644720;
        double r1644722 = cbrt(r1644686);
        double r1644723 = log(r1644722);
        double r1644724 = r1644723 * r1644687;
        double r1644725 = r1644724 + r1644724;
        double r1644726 = r1644725 + r1644724;
        double r1644727 = r1644685 / r1644726;
        double r1644728 = r1644727 / r1644687;
        double r1644729 = r1644728 * r1644696;
        double r1644730 = log(r1644679);
        double r1644731 = r1644730 / r1644687;
        double r1644732 = r1644721 ? r1644729 : r1644731;
        double r1644733 = r1644719 ? r1644707 : r1644732;
        double r1644734 = r1644717 ? r1644713 : r1644733;
        double r1644735 = r1644715 ? r1644707 : r1644734;
        double r1644736 = r1644709 ? r1644713 : r1644735;
        double r1644737 = r1644699 ? r1644707 : r1644736;
        double r1644738 = r1644681 ? r1644697 : r1644737;
        return r1644738;
}

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 5 regimes
  2. if im < -6.319225497138611e+155

    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. Simplified50.8

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

      \[\leadsto -\frac{\log \left(\frac{-1}{re}\right)}{\color{blue}{\frac{{0}^{3} + {\left(\log base\right)}^{3}}{0 \cdot 0 + \left(\log base \cdot \log base - 0 \cdot \log base\right)}}}\]
    7. Applied associate-/r/50.8

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

      \[\leadsto -\color{blue}{\frac{\frac{\log \left(\frac{-1}{re}\right)}{\log base \cdot \log base}}{\log base}} \cdot \left(0 \cdot 0 + \left(\log base \cdot \log base - 0 \cdot \log base\right)\right)\]
    9. Using strategy rm
    10. Applied flip-+50.8

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

      \[\leadsto -\color{blue}{\frac{\frac{\frac{\log \left(\frac{-1}{re}\right)}{\log base \cdot \log base}}{\log base} \cdot \left(\left(0 \cdot 0\right) \cdot \left(0 \cdot 0\right) - \left(\log base \cdot \log base - 0 \cdot \log base\right) \cdot \left(\log base \cdot \log base - 0 \cdot \log base\right)\right)}{0 \cdot 0 - \left(\log base \cdot \log base - 0 \cdot \log base\right)}}\]
    12. Simplified50.8

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

    if -6.319225497138611e+155 < im < -9.784975811452057e+64 or -3.7539404597618837e+52 < im < -1.5129456424795354e-88 or 2.125432684072948e-114 < im < 1.731637496866189e-54

    1. Initial program 16.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. Simplified16.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 clear-num16.4

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

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

    if -9.784975811452057e+64 < im < -3.7539404597618837e+52 or -1.5129456424795354e-88 < im < 2.125432684072948e-114

    1. Initial program 26.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. Simplified26.4

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

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

      \[\leadsto -\frac{\log \left(\frac{-1}{re}\right)}{\color{blue}{\frac{{0}^{3} + {\left(\log base\right)}^{3}}{0 \cdot 0 + \left(\log base \cdot \log base - 0 \cdot \log base\right)}}}\]
    7. Applied associate-/r/9.3

      \[\leadsto -\color{blue}{\frac{\log \left(\frac{-1}{re}\right)}{{0}^{3} + {\left(\log base\right)}^{3}} \cdot \left(0 \cdot 0 + \left(\log base \cdot \log base - 0 \cdot \log base\right)\right)}\]
    8. Simplified9.2

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

    if 1.731637496866189e-54 < im < 1.3029063758199714e-09

    1. Initial program 18.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. Simplified18.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. Simplified22.0

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

      \[\leadsto -\frac{\log \left(\frac{-1}{re}\right)}{\color{blue}{\frac{{0}^{3} + {\left(\log base\right)}^{3}}{0 \cdot 0 + \left(\log base \cdot \log base - 0 \cdot \log base\right)}}}\]
    7. Applied associate-/r/22.1

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

      \[\leadsto -\color{blue}{\frac{\frac{\log \left(\frac{-1}{re}\right)}{\log base \cdot \log base}}{\log base}} \cdot \left(0 \cdot 0 + \left(\log base \cdot \log base - 0 \cdot \log base\right)\right)\]
    9. Using strategy rm
    10. Applied add-cube-cbrt22.0

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

      \[\leadsto -\frac{\frac{\log \left(\frac{-1}{re}\right)}{\log base \cdot \color{blue}{\left(\log \left(\sqrt[3]{base} \cdot \sqrt[3]{base}\right) + \log \left(\sqrt[3]{base}\right)\right)}}}{\log base} \cdot \left(0 \cdot 0 + \left(\log base \cdot \log base - 0 \cdot \log base\right)\right)\]
    12. Applied distribute-lft-in22.1

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

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

    if 1.3029063758199714e-09 < im

    1. Initial program 37.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. Simplified37.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 0 13.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \le -6.319225497138611 \cdot 10^{+155}:\\ \;\;\;\;\frac{\frac{\log \left(\frac{-1}{re}\right)}{\left(\log base \cdot \log base\right) \cdot \log base} \cdot \left(\left(\log base \cdot \log base\right) \cdot \left(\log base \cdot \log base\right)\right)}{-\left(\log base \cdot \log base - \log base \cdot 0\right)}\\ \mathbf{elif}\;im \le -9.784975811452057 \cdot 10^{+64}:\\ \;\;\;\;\frac{1}{\frac{\log base}{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}}\\ \mathbf{elif}\;im \le -3.7539404597618837 \cdot 10^{+52}:\\ \;\;\;\;\left(\log base \cdot \log base - \log base \cdot 0\right) \cdot \frac{-\frac{\log \left(\frac{-1}{re}\right)}{\log base \cdot \log base}}{\log base}\\ \mathbf{elif}\;im \le -1.5129456424795354 \cdot 10^{-88}:\\ \;\;\;\;\frac{1}{\frac{\log base}{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}}\\ \mathbf{elif}\;im \le 2.125432684072948 \cdot 10^{-114}:\\ \;\;\;\;\left(\log base \cdot \log base - \log base \cdot 0\right) \cdot \frac{-\frac{\log \left(\frac{-1}{re}\right)}{\log base \cdot \log base}}{\log base}\\ \mathbf{elif}\;im \le 1.731637496866189 \cdot 10^{-54}:\\ \;\;\;\;\frac{1}{\frac{\log base}{\log \left(\sqrt{re \cdot re + im \cdot im}\right)}}\\ \mathbf{elif}\;im \le 1.3029063758199714 \cdot 10^{-09}:\\ \;\;\;\;\frac{\frac{\log \left(\frac{-1}{re}\right)}{\left(\log \left(\sqrt[3]{base}\right) \cdot \log base + \log \left(\sqrt[3]{base}\right) \cdot \log base\right) + \log \left(\sqrt[3]{base}\right) \cdot \log base}}{\log base} \cdot \left(-\left(\log base \cdot \log base - \log base \cdot 0\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\log im}{\log base}\\ \end{array}\]

Reproduce

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