Average Error: 31.0 → 16.8
Time: 22.1s
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 r36457 = re;
        double r36458 = r36457 * r36457;
        double r36459 = im;
        double r36460 = r36459 * r36459;
        double r36461 = r36458 + r36460;
        double r36462 = sqrt(r36461);
        double r36463 = log(r36462);
        double r36464 = base;
        double r36465 = log(r36464);
        double r36466 = r36463 * r36465;
        double r36467 = atan2(r36459, r36457);
        double r36468 = 0.0;
        double r36469 = r36467 * r36468;
        double r36470 = r36466 + r36469;
        double r36471 = r36465 * r36465;
        double r36472 = r36468 * r36468;
        double r36473 = r36471 + r36472;
        double r36474 = r36470 / r36473;
        return r36474;
}

double f(double re, double im, double base) {
        double r36475 = im;
        double r36476 = -8.699527506903107e+148;
        bool r36477 = r36475 <= r36476;
        double r36478 = -1.0;
        double r36479 = r36478 / r36475;
        double r36480 = log(r36479);
        double r36481 = -r36480;
        double r36482 = base;
        double r36483 = log(r36482);
        double r36484 = r36481 / r36483;
        double r36485 = 8.322808950963171e+83;
        bool r36486 = r36475 <= r36485;
        double r36487 = 1.0;
        double r36488 = 2.0;
        double r36489 = pow(r36483, r36488);
        double r36490 = 0.0;
        double r36491 = r36490 * r36490;
        double r36492 = r36489 + r36491;
        double r36493 = re;
        double r36494 = r36493 * r36493;
        double r36495 = r36475 * r36475;
        double r36496 = r36494 + r36495;
        double r36497 = sqrt(r36496);
        double r36498 = log(r36497);
        double r36499 = r36498 * r36483;
        double r36500 = atan2(r36475, r36493);
        double r36501 = r36500 * r36490;
        double r36502 = r36499 + r36501;
        double r36503 = r36492 / r36502;
        double r36504 = r36487 / r36503;
        double r36505 = log(r36475);
        double r36506 = r36505 / r36483;
        double r36507 = r36486 ? r36504 : r36506;
        double r36508 = r36477 ? r36484 : r36507;
        return r36508;
}

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. Taylor expanded around 0 8.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))))