Average Error: 32.1 → 18.0
Time: 14.9s
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 -2.941271494123403150212192649236485986394 \cdot 10^{82}:\\ \;\;\;\;\frac{\log \left(\frac{-1}{im}\right)}{{\left(\log base\right)}^{3}} \cdot \left(0.0 \cdot 0.0 - {\left(\log base\right)}^{2}\right)\\ \mathbf{elif}\;im \le -1.056135040441817993361662182816155280925 \cdot 10^{-243}:\\ \;\;\;\;\frac{\tan^{-1}_* \frac{im}{re} \cdot 0.0 + \log base \cdot \log \left(\sqrt{re \cdot re + im \cdot im}\right)}{{0.0}^{3} \cdot 0.0 - {\left({\left(\log base\right)}^{2}\right)}^{\left(\sqrt{4}\right)}} \cdot \left(0.0 \cdot 0.0 - {\left(\log base\right)}^{2}\right)\\ \mathbf{elif}\;im \le 1.684512098288392462211092787468027207826 \cdot 10^{-238}:\\ \;\;\;\;\frac{-\log re}{-\log base}\\ \mathbf{elif}\;im \le 3.283081512447868836362935755252953007161 \cdot 10^{107}:\\ \;\;\;\;\frac{\frac{{\left(\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base\right)}^{3} + {\left(\tan^{-1}_* \frac{im}{re} \cdot 0.0\right)}^{3}}{0.0 \cdot 0.0 + {\left(\log base\right)}^{2}}}{\left(\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base\right) \cdot \left(\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base\right) + \left(\left(\tan^{-1}_* \frac{im}{re} \cdot 0.0\right) \cdot \left(\tan^{-1}_* \frac{im}{re} \cdot 0.0\right) - \left(\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base\right) \cdot \left(\tan^{-1}_* \frac{im}{re} \cdot 0.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.0}{\log base \cdot \log base + 0.0 \cdot 0.0}
\begin{array}{l}
\mathbf{if}\;im \le -2.941271494123403150212192649236485986394 \cdot 10^{82}:\\
\;\;\;\;\frac{\log \left(\frac{-1}{im}\right)}{{\left(\log base\right)}^{3}} \cdot \left(0.0 \cdot 0.0 - {\left(\log base\right)}^{2}\right)\\

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

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

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

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

\end{array}
double f(double re, double im, double base) {
        double r44388 = re;
        double r44389 = r44388 * r44388;
        double r44390 = im;
        double r44391 = r44390 * r44390;
        double r44392 = r44389 + r44391;
        double r44393 = sqrt(r44392);
        double r44394 = log(r44393);
        double r44395 = base;
        double r44396 = log(r44395);
        double r44397 = r44394 * r44396;
        double r44398 = atan2(r44390, r44388);
        double r44399 = 0.0;
        double r44400 = r44398 * r44399;
        double r44401 = r44397 + r44400;
        double r44402 = r44396 * r44396;
        double r44403 = r44399 * r44399;
        double r44404 = r44402 + r44403;
        double r44405 = r44401 / r44404;
        return r44405;
}

double f(double re, double im, double base) {
        double r44406 = im;
        double r44407 = -2.941271494123403e+82;
        bool r44408 = r44406 <= r44407;
        double r44409 = -1.0;
        double r44410 = r44409 / r44406;
        double r44411 = log(r44410);
        double r44412 = base;
        double r44413 = log(r44412);
        double r44414 = 3.0;
        double r44415 = pow(r44413, r44414);
        double r44416 = r44411 / r44415;
        double r44417 = 0.0;
        double r44418 = r44417 * r44417;
        double r44419 = 2.0;
        double r44420 = pow(r44413, r44419);
        double r44421 = r44418 - r44420;
        double r44422 = r44416 * r44421;
        double r44423 = -1.056135040441818e-243;
        bool r44424 = r44406 <= r44423;
        double r44425 = re;
        double r44426 = atan2(r44406, r44425);
        double r44427 = r44426 * r44417;
        double r44428 = r44425 * r44425;
        double r44429 = r44406 * r44406;
        double r44430 = r44428 + r44429;
        double r44431 = sqrt(r44430);
        double r44432 = log(r44431);
        double r44433 = r44413 * r44432;
        double r44434 = r44427 + r44433;
        double r44435 = pow(r44417, r44414);
        double r44436 = r44435 * r44417;
        double r44437 = 4.0;
        double r44438 = sqrt(r44437);
        double r44439 = pow(r44420, r44438);
        double r44440 = r44436 - r44439;
        double r44441 = r44434 / r44440;
        double r44442 = r44441 * r44421;
        double r44443 = 1.6845120982883925e-238;
        bool r44444 = r44406 <= r44443;
        double r44445 = log(r44425);
        double r44446 = -r44445;
        double r44447 = -r44413;
        double r44448 = r44446 / r44447;
        double r44449 = 3.283081512447869e+107;
        bool r44450 = r44406 <= r44449;
        double r44451 = r44432 * r44413;
        double r44452 = pow(r44451, r44414);
        double r44453 = pow(r44427, r44414);
        double r44454 = r44452 + r44453;
        double r44455 = r44418 + r44420;
        double r44456 = r44454 / r44455;
        double r44457 = r44451 * r44451;
        double r44458 = r44427 * r44427;
        double r44459 = r44451 * r44427;
        double r44460 = r44458 - r44459;
        double r44461 = r44457 + r44460;
        double r44462 = r44456 / r44461;
        double r44463 = log(r44406);
        double r44464 = r44463 / r44413;
        double r44465 = r44450 ? r44462 : r44464;
        double r44466 = r44444 ? r44448 : r44465;
        double r44467 = r44424 ? r44442 : r44466;
        double r44468 = r44408 ? r44422 : r44467;
        return r44468;
}

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 < -2.941271494123403e+82

    1. Initial program 48.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 div-inv48.6

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

      \[\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}{0.0 \cdot 0.0 + {\left(\log base\right)}^{2}}}\]
    5. Using strategy rm
    6. Applied flip-+48.6

      \[\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(0.0 \cdot 0.0\right) \cdot \left(0.0 \cdot 0.0\right) - {\left(\log base\right)}^{2} \cdot {\left(\log base\right)}^{2}}{0.0 \cdot 0.0 - {\left(\log base\right)}^{2}}}}\]
    7. Applied associate-/r/48.6

      \[\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(0.0 \cdot 0.0\right) \cdot \left(0.0 \cdot 0.0\right) - {\left(\log base\right)}^{2} \cdot {\left(\log base\right)}^{2}} \cdot \left(0.0 \cdot 0.0 - {\left(\log base\right)}^{2}\right)\right)}\]
    8. Applied associate-*r*48.6

      \[\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(0.0 \cdot 0.0\right) \cdot \left(0.0 \cdot 0.0\right) - {\left(\log base\right)}^{2} \cdot {\left(\log base\right)}^{2}}\right) \cdot \left(0.0 \cdot 0.0 - {\left(\log base\right)}^{2}\right)}\]
    9. Simplified48.6

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

      \[\leadsto \color{blue}{\frac{\log \left(\frac{-1}{im}\right)}{{\left(\log -1 - \log \left(\frac{-1}{base}\right)\right)}^{3}}} \cdot \left(0.0 \cdot 0.0 - {\left(\log base\right)}^{2}\right)\]
    11. Simplified9.5

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

    if -2.941271494123403e+82 < im < -1.056135040441818e-243

    1. Initial program 21.0

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

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

      \[\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}{0.0 \cdot 0.0 + {\left(\log base\right)}^{2}}}\]
    5. Using strategy rm
    6. Applied flip-+21.1

      \[\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(0.0 \cdot 0.0\right) \cdot \left(0.0 \cdot 0.0\right) - {\left(\log base\right)}^{2} \cdot {\left(\log base\right)}^{2}}{0.0 \cdot 0.0 - {\left(\log base\right)}^{2}}}}\]
    7. Applied associate-/r/21.1

      \[\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(0.0 \cdot 0.0\right) \cdot \left(0.0 \cdot 0.0\right) - {\left(\log base\right)}^{2} \cdot {\left(\log base\right)}^{2}} \cdot \left(0.0 \cdot 0.0 - {\left(\log base\right)}^{2}\right)\right)}\]
    8. Applied associate-*r*21.1

      \[\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(0.0 \cdot 0.0\right) \cdot \left(0.0 \cdot 0.0\right) - {\left(\log base\right)}^{2} \cdot {\left(\log base\right)}^{2}}\right) \cdot \left(0.0 \cdot 0.0 - {\left(\log base\right)}^{2}\right)}\]
    9. Simplified21.1

      \[\leadsto \color{blue}{\frac{\tan^{-1}_* \frac{im}{re} \cdot 0.0 + \log base \cdot \log \left(\sqrt{re \cdot re + im \cdot im}\right)}{{0.0}^{3} \cdot 0.0 - {\left(\log base\right)}^{4}}} \cdot \left(0.0 \cdot 0.0 - {\left(\log base\right)}^{2}\right)\]
    10. Using strategy rm
    11. Applied add-sqr-sqrt21.1

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

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

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

    if -1.056135040441818e-243 < im < 1.6845120982883925e-238

    1. Initial program 30.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. Taylor expanded around inf 32.7

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

      \[\leadsto \color{blue}{\frac{-\log re}{-\log base}}\]

    if 1.6845120982883925e-238 < im < 3.283081512447869e+107

    1. Initial program 20.3

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

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

      \[\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}{0.0 \cdot 0.0 + {\left(\log base\right)}^{2}}}\]
    5. Using strategy rm
    6. Applied flip3-+20.4

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

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

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

    if 3.283081512447869e+107 < im

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \le -2.941271494123403150212192649236485986394 \cdot 10^{82}:\\ \;\;\;\;\frac{\log \left(\frac{-1}{im}\right)}{{\left(\log base\right)}^{3}} \cdot \left(0.0 \cdot 0.0 - {\left(\log base\right)}^{2}\right)\\ \mathbf{elif}\;im \le -1.056135040441817993361662182816155280925 \cdot 10^{-243}:\\ \;\;\;\;\frac{\tan^{-1}_* \frac{im}{re} \cdot 0.0 + \log base \cdot \log \left(\sqrt{re \cdot re + im \cdot im}\right)}{{0.0}^{3} \cdot 0.0 - {\left({\left(\log base\right)}^{2}\right)}^{\left(\sqrt{4}\right)}} \cdot \left(0.0 \cdot 0.0 - {\left(\log base\right)}^{2}\right)\\ \mathbf{elif}\;im \le 1.684512098288392462211092787468027207826 \cdot 10^{-238}:\\ \;\;\;\;\frac{-\log re}{-\log base}\\ \mathbf{elif}\;im \le 3.283081512447868836362935755252953007161 \cdot 10^{107}:\\ \;\;\;\;\frac{\frac{{\left(\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base\right)}^{3} + {\left(\tan^{-1}_* \frac{im}{re} \cdot 0.0\right)}^{3}}{0.0 \cdot 0.0 + {\left(\log base\right)}^{2}}}{\left(\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base\right) \cdot \left(\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base\right) + \left(\left(\tan^{-1}_* \frac{im}{re} \cdot 0.0\right) \cdot \left(\tan^{-1}_* \frac{im}{re} \cdot 0.0\right) - \left(\log \left(\sqrt{re \cdot re + im \cdot im}\right) \cdot \log base\right) \cdot \left(\tan^{-1}_* \frac{im}{re} \cdot 0.0\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log im}{\log base}\\ \end{array}\]

Reproduce

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