Average Error: 31.0 → 16.8
Time: 23.7s
Precision: 64
\[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\log base \cdot \log base + 0.0 \cdot 0.0}\]
\[\begin{array}{l} \mathbf{if}\;im \le -8.699527506903106763121586570753262874818 \cdot 10^{148}:\\ \;\;\;\;\frac{-\log \left(\frac{-1}{im}\right)}{\log base}\\ \mathbf{elif}\;im \le 8.322808950963171226745757166064822582935 \cdot 10^{83}:\\ \;\;\;\;\frac{1}{\frac{{\left(\log base\right)}^{2} + 0.0 \cdot 0.0}{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}}\\ \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.0}{\log base \cdot \log base + 0.0 \cdot 0.0}
\begin{array}{l}
\mathbf{if}\;im \le -8.699527506903106763121586570753262874818 \cdot 10^{148}:\\
\;\;\;\;\frac{-\log \left(\frac{-1}{im}\right)}{\log base}\\

\mathbf{elif}\;im \le 8.322808950963171226745757166064822582935 \cdot 10^{83}:\\
\;\;\;\;\frac{1}{\frac{{\left(\log base\right)}^{2} + 0.0 \cdot 0.0}{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}}\\

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

\end{array}
double f(double re, double im, double base) {
        double r36488 = re;
        double r36489 = r36488 * r36488;
        double r36490 = im;
        double r36491 = r36490 * r36490;
        double r36492 = r36489 + r36491;
        double r36493 = sqrt(r36492);
        double r36494 = log(r36493);
        double r36495 = base;
        double r36496 = log(r36495);
        double r36497 = r36494 * r36496;
        double r36498 = atan2(r36490, r36488);
        double r36499 = 0.0;
        double r36500 = r36498 * r36499;
        double r36501 = r36497 + r36500;
        double r36502 = r36496 * r36496;
        double r36503 = r36499 * r36499;
        double r36504 = r36502 + r36503;
        double r36505 = r36501 / r36504;
        return r36505;
}

double f(double re, double im, double base) {
        double r36506 = im;
        double r36507 = -8.699527506903107e+148;
        bool r36508 = r36506 <= r36507;
        double r36509 = -1.0;
        double r36510 = r36509 / r36506;
        double r36511 = log(r36510);
        double r36512 = -r36511;
        double r36513 = base;
        double r36514 = log(r36513);
        double r36515 = r36512 / r36514;
        double r36516 = 8.322808950963171e+83;
        bool r36517 = r36506 <= r36516;
        double r36518 = 1.0;
        double r36519 = 2.0;
        double r36520 = pow(r36514, r36519);
        double r36521 = 0.0;
        double r36522 = r36521 * r36521;
        double r36523 = r36520 + r36522;
        double r36524 = re;
        double r36525 = r36524 * r36524;
        double r36526 = r36506 * r36506;
        double r36527 = r36525 + r36526;
        double r36528 = sqrt(r36527);
        double r36529 = log(r36528);
        double r36530 = r36529 * r36514;
        double r36531 = atan2(r36506, r36524);
        double r36532 = r36531 * r36521;
        double r36533 = r36530 + r36532;
        double r36534 = r36523 / r36533;
        double r36535 = r36518 / r36534;
        double r36536 = log(r36506);
        double r36537 = -r36536;
        double r36538 = -r36514;
        double r36539 = r36537 / r36538;
        double r36540 = r36517 ? r36535 : r36539;
        double r36541 = r36508 ? r36515 : r36540;
        return r36541;
}

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 < -8.699527506903107e+148

    1. Initial program 61.8

      \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\log base \cdot \log base + 0.0 \cdot 0.0}\]
    2. Using strategy rm
    3. Applied div-inv61.8

      \[\leadsto \color{blue}{\left(\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0\right) \cdot \frac{1}{\log base \cdot \log base + 0.0 \cdot 0.0}}\]
    4. Simplified61.8

      \[\leadsto \left(\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0\right) \cdot \color{blue}{\frac{1}{{\left(\log base\right)}^{2} + 0.0 \cdot 0.0}}\]
    5. Using strategy rm
    6. Applied flip-+61.8

      \[\leadsto \left(\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0\right) \cdot \frac{1}{\color{blue}{\frac{{\left(\log base\right)}^{2} \cdot {\left(\log base\right)}^{2} - \left(0.0 \cdot 0.0\right) \cdot \left(0.0 \cdot 0.0\right)}{{\left(\log base\right)}^{2} - 0.0 \cdot 0.0}}}\]
    7. Applied associate-/r/61.8

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

      \[\leadsto \color{blue}{\left(\left(\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0\right) \cdot \frac{1}{{\left(\log base\right)}^{2} \cdot {\left(\log base\right)}^{2} - \left(0.0 \cdot 0.0\right) \cdot \left(0.0 \cdot 0.0\right)}\right) \cdot \left({\left(\log base\right)}^{2} - 0.0 \cdot 0.0\right)}\]
    9. Simplified61.8

      \[\leadsto \color{blue}{\frac{\tan^{-1}_* \frac{im}{re} \cdot 0.0 + \log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base}{{\left(\log base\right)}^{4} - 0.0 \cdot {0.0}^{3}}} \cdot \left({\left(\log base\right)}^{2} - 0.0 \cdot 0.0\right)\]
    10. Taylor expanded around -inf 64.0

      \[\leadsto \color{blue}{-1 \cdot \frac{\log \left(\frac{-1}{im}\right)}{\log -1 - \log \left(\frac{-1}{base}\right)}}\]
    11. Simplified7.0

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

    if -8.699527506903107e+148 < im < 8.322808950963171e+83

    1. Initial program 20.6

      \[\frac{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}{\log base \cdot \log base + 0.0 \cdot 0.0}\]
    2. Using strategy rm
    3. Applied clear-num20.7

      \[\leadsto \color{blue}{\frac{1}{\frac{\log base \cdot \log base + 0.0 \cdot 0.0}{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}}}\]
    4. Simplified20.7

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

    if 8.322808950963171e+83 < im

    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.0}{\log base \cdot \log base + 0.0 \cdot 0.0}\]
    2. Using strategy rm
    3. Applied div-inv48.7

      \[\leadsto \color{blue}{\left(\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0\right) \cdot \frac{1}{\log base \cdot \log base + 0.0 \cdot 0.0}}\]
    4. Simplified48.7

      \[\leadsto \left(\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0\right) \cdot \color{blue}{\frac{1}{{\left(\log base\right)}^{2} + 0.0 \cdot 0.0}}\]
    5. Using strategy rm
    6. Applied flip-+48.7

      \[\leadsto \left(\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0\right) \cdot \frac{1}{\color{blue}{\frac{{\left(\log base\right)}^{2} \cdot {\left(\log base\right)}^{2} - \left(0.0 \cdot 0.0\right) \cdot \left(0.0 \cdot 0.0\right)}{{\left(\log base\right)}^{2} - 0.0 \cdot 0.0}}}\]
    7. Applied associate-/r/48.7

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

      \[\leadsto \color{blue}{\left(\left(\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0\right) \cdot \frac{1}{{\left(\log base\right)}^{2} \cdot {\left(\log base\right)}^{2} - \left(0.0 \cdot 0.0\right) \cdot \left(0.0 \cdot 0.0\right)}\right) \cdot \left({\left(\log base\right)}^{2} - 0.0 \cdot 0.0\right)}\]
    9. Simplified48.7

      \[\leadsto \color{blue}{\frac{\tan^{-1}_* \frac{im}{re} \cdot 0.0 + \log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base}{{\left(\log base\right)}^{4} - 0.0 \cdot {0.0}^{3}}} \cdot \left({\left(\log base\right)}^{2} - 0.0 \cdot 0.0\right)\]
    10. Taylor expanded around inf 8.9

      \[\leadsto \color{blue}{\frac{\log \left(\frac{1}{im}\right)}{\log \left(\frac{1}{base}\right)}}\]
    11. Simplified8.9

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \le -8.699527506903106763121586570753262874818 \cdot 10^{148}:\\ \;\;\;\;\frac{-\log \left(\frac{-1}{im}\right)}{\log base}\\ \mathbf{elif}\;im \le 8.322808950963171226745757166064822582935 \cdot 10^{83}:\\ \;\;\;\;\frac{1}{\frac{{\left(\log base\right)}^{2} + 0.0 \cdot 0.0}{\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base + \tan^{-1}_* \frac{im}{re} \cdot 0.0}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-\log im}{-\log base}\\ \end{array}\]

Reproduce

herbie shell --seed 2019303 
(FPCore (re im base)
  :name "math.log/2 on complex, real part"
  :precision binary64
  (/ (+ (* (log (sqrt (+ (* re re) (* im im)))) (log base)) (* (atan2 im re) 0.0)) (+ (* (log base) (log base)) (* 0.0 0.0))))