Average Error: 33.4 → 7.2
Time: 27.0s
Precision: 64
\[e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\]
\[\begin{array}{l} \mathbf{if}\;y.re \le -3.054997390688639940608928281895735393357 \cdot 10^{163}:\\ \;\;\;\;\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{\frac{\mathsf{fma}\left(y.im, \tan^{-1}_* \frac{x.im}{x.re}, \mathsf{fma}\left(\frac{1}{2} \cdot \left(y.im \cdot y.im\right), {\left(\tan^{-1}_* \frac{x.im}{x.re}\right)}^{2}, 1\right)\right)}{\cos \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right)}}\\ \mathbf{elif}\;y.re \le 130426541531277090057616837214952488960:\\ \;\;\;\;\left(\log \left(e^{\cos \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right)}\right) \cdot e^{\left(-\sqrt[3]{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\right) \cdot \left(\sqrt[3]{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}} \cdot \sqrt[3]{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\right)}\right) \cdot {\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}\\ \mathbf{elif}\;y.re \le 2.993058433867654662682056505364059183978 \cdot 10^{97}:\\ \;\;\;\;e^{\mathsf{fma}\left(y.re, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), \mathsf{fma}\left(-y.im, \tan^{-1}_* \frac{x.im}{x.re}, \log \left(\cos \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right)\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{\frac{\mathsf{fma}\left(y.im, \tan^{-1}_* \frac{x.im}{x.re}, \mathsf{fma}\left(\frac{1}{2} \cdot \left(y.im \cdot y.im\right), {\left(\tan^{-1}_* \frac{x.im}{x.re}\right)}^{2}, 1\right)\right)}{\cos \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right)}}\\ \end{array}\]
e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)
\begin{array}{l}
\mathbf{if}\;y.re \le -3.054997390688639940608928281895735393357 \cdot 10^{163}:\\
\;\;\;\;\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{\frac{\mathsf{fma}\left(y.im, \tan^{-1}_* \frac{x.im}{x.re}, \mathsf{fma}\left(\frac{1}{2} \cdot \left(y.im \cdot y.im\right), {\left(\tan^{-1}_* \frac{x.im}{x.re}\right)}^{2}, 1\right)\right)}{\cos \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right)}}\\

\mathbf{elif}\;y.re \le 130426541531277090057616837214952488960:\\
\;\;\;\;\left(\log \left(e^{\cos \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right)}\right) \cdot e^{\left(-\sqrt[3]{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\right) \cdot \left(\sqrt[3]{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}} \cdot \sqrt[3]{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\right)}\right) \cdot {\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}\\

\mathbf{elif}\;y.re \le 2.993058433867654662682056505364059183978 \cdot 10^{97}:\\
\;\;\;\;e^{\mathsf{fma}\left(y.re, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), \mathsf{fma}\left(-y.im, \tan^{-1}_* \frac{x.im}{x.re}, \log \left(\cos \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right)\right)\right)\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{\frac{\mathsf{fma}\left(y.im, \tan^{-1}_* \frac{x.im}{x.re}, \mathsf{fma}\left(\frac{1}{2} \cdot \left(y.im \cdot y.im\right), {\left(\tan^{-1}_* \frac{x.im}{x.re}\right)}^{2}, 1\right)\right)}{\cos \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right)}}\\

\end{array}
double f(double x_re, double x_im, double y_re, double y_im) {
        double r29471 = x_re;
        double r29472 = r29471 * r29471;
        double r29473 = x_im;
        double r29474 = r29473 * r29473;
        double r29475 = r29472 + r29474;
        double r29476 = sqrt(r29475);
        double r29477 = log(r29476);
        double r29478 = y_re;
        double r29479 = r29477 * r29478;
        double r29480 = atan2(r29473, r29471);
        double r29481 = y_im;
        double r29482 = r29480 * r29481;
        double r29483 = r29479 - r29482;
        double r29484 = exp(r29483);
        double r29485 = r29477 * r29481;
        double r29486 = r29480 * r29478;
        double r29487 = r29485 + r29486;
        double r29488 = cos(r29487);
        double r29489 = r29484 * r29488;
        return r29489;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r29490 = y_re;
        double r29491 = -3.05499739068864e+163;
        bool r29492 = r29490 <= r29491;
        double r29493 = x_re;
        double r29494 = x_im;
        double r29495 = hypot(r29493, r29494);
        double r29496 = pow(r29495, r29490);
        double r29497 = y_im;
        double r29498 = atan2(r29494, r29493);
        double r29499 = 0.5;
        double r29500 = r29497 * r29497;
        double r29501 = r29499 * r29500;
        double r29502 = 2.0;
        double r29503 = pow(r29498, r29502);
        double r29504 = 1.0;
        double r29505 = fma(r29501, r29503, r29504);
        double r29506 = fma(r29497, r29498, r29505);
        double r29507 = log(r29495);
        double r29508 = r29490 * r29498;
        double r29509 = fma(r29497, r29507, r29508);
        double r29510 = cos(r29509);
        double r29511 = r29506 / r29510;
        double r29512 = r29496 / r29511;
        double r29513 = 1.3042654153127709e+38;
        bool r29514 = r29490 <= r29513;
        double r29515 = exp(r29510);
        double r29516 = log(r29515);
        double r29517 = r29497 * r29498;
        double r29518 = cbrt(r29517);
        double r29519 = -r29518;
        double r29520 = r29518 * r29518;
        double r29521 = r29519 * r29520;
        double r29522 = exp(r29521);
        double r29523 = r29516 * r29522;
        double r29524 = r29523 * r29496;
        double r29525 = 2.9930584338676547e+97;
        bool r29526 = r29490 <= r29525;
        double r29527 = -r29497;
        double r29528 = log(r29510);
        double r29529 = fma(r29527, r29498, r29528);
        double r29530 = fma(r29490, r29507, r29529);
        double r29531 = exp(r29530);
        double r29532 = r29526 ? r29531 : r29512;
        double r29533 = r29514 ? r29524 : r29532;
        double r29534 = r29492 ? r29512 : r29533;
        return r29534;
}

Error

Bits error versus x.re

Bits error versus x.im

Bits error versus y.re

Bits error versus y.im

Derivation

  1. Split input into 3 regimes
  2. if y.re < -3.05499739068864e+163 or 2.9930584338676547e+97 < y.re

    1. Initial program 31.1

      \[e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\]
    2. Simplified17.0

      \[\leadsto \color{blue}{\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{\frac{{\left(e^{y.im}\right)}^{\left(\tan^{-1}_* \frac{x.im}{x.re}\right)}}{\cos \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right)}}}\]
    3. Taylor expanded around 0 7.5

      \[\leadsto \frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{\frac{\color{blue}{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re} + \left(\frac{1}{2} \cdot \left({y.im}^{2} \cdot {\left(\tan^{-1}_* \frac{x.im}{x.re}\right)}^{2}\right) + 1\right)}}{\cos \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right)}}\]
    4. Simplified7.5

      \[\leadsto \frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{\frac{\color{blue}{\mathsf{fma}\left(y.im, \tan^{-1}_* \frac{x.im}{x.re}, \mathsf{fma}\left(\frac{1}{2} \cdot \left(y.im \cdot y.im\right), {\left(\tan^{-1}_* \frac{x.im}{x.re}\right)}^{2}, 1\right)\right)}}{\cos \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right)}}\]

    if -3.05499739068864e+163 < y.re < 1.3042654153127709e+38

    1. Initial program 34.4

      \[e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\]
    2. Simplified6.9

      \[\leadsto \color{blue}{\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{\frac{{\left(e^{y.im}\right)}^{\left(\tan^{-1}_* \frac{x.im}{x.re}\right)}}{\cos \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right)}}}\]
    3. Using strategy rm
    4. Applied div-inv6.9

      \[\leadsto \color{blue}{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re} \cdot \frac{1}{\frac{{\left(e^{y.im}\right)}^{\left(\tan^{-1}_* \frac{x.im}{x.re}\right)}}{\cos \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right)}}}\]
    5. Simplified6.3

      \[\leadsto {\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re} \cdot \color{blue}{\left(e^{-\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right)\right)}\]
    6. Using strategy rm
    7. Applied add-cube-cbrt6.3

      \[\leadsto {\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re} \cdot \left(e^{-\color{blue}{\left(\sqrt[3]{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \sqrt[3]{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\right) \cdot \sqrt[3]{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}}} \cdot \cos \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right)\right)\]
    8. Using strategy rm
    9. Applied add-log-exp6.3

      \[\leadsto {\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re} \cdot \left(e^{-\left(\sqrt[3]{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \sqrt[3]{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\right) \cdot \sqrt[3]{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}} \cdot \color{blue}{\log \left(e^{\cos \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right)}\right)}\right)\]

    if 1.3042654153127709e+38 < y.re < 2.9930584338676547e+97

    1. Initial program 23.6

      \[e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\]
    2. Simplified27.6

      \[\leadsto \color{blue}{\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{\frac{{\left(e^{y.im}\right)}^{\left(\tan^{-1}_* \frac{x.im}{x.re}\right)}}{\cos \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right)}}}\]
    3. Using strategy rm
    4. Applied div-inv27.6

      \[\leadsto \color{blue}{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re} \cdot \frac{1}{\frac{{\left(e^{y.im}\right)}^{\left(\tan^{-1}_* \frac{x.im}{x.re}\right)}}{\cos \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right)}}}\]
    5. Simplified26.9

      \[\leadsto {\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re} \cdot \color{blue}{\left(e^{-\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right)\right)}\]
    6. Using strategy rm
    7. Applied add-exp-log43.5

      \[\leadsto {\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re} \cdot \left(e^{-\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \color{blue}{e^{\log \left(\cos \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right)\right)}}\right)\]
    8. Applied prod-exp43.5

      \[\leadsto {\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re} \cdot \color{blue}{e^{\left(-\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im\right) + \log \left(\cos \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right)\right)}}\]
    9. Applied add-exp-log43.5

      \[\leadsto {\color{blue}{\left(e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)}\right)}}^{y.re} \cdot e^{\left(-\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im\right) + \log \left(\cos \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right)\right)}\]
    10. Applied pow-exp43.5

      \[\leadsto \color{blue}{e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re}} \cdot e^{\left(-\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im\right) + \log \left(\cos \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right)\right)}\]
    11. Applied prod-exp30.3

      \[\leadsto \color{blue}{e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re + \left(\left(-\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im\right) + \log \left(\cos \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right)\right)\right)}}\]
    12. Simplified30.3

      \[\leadsto e^{\color{blue}{\mathsf{fma}\left(y.re, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), \mathsf{fma}\left(-y.im, \tan^{-1}_* \frac{x.im}{x.re}, \log \left(\cos \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right)\right)\right)\right)}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification7.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.re \le -3.054997390688639940608928281895735393357 \cdot 10^{163}:\\ \;\;\;\;\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{\frac{\mathsf{fma}\left(y.im, \tan^{-1}_* \frac{x.im}{x.re}, \mathsf{fma}\left(\frac{1}{2} \cdot \left(y.im \cdot y.im\right), {\left(\tan^{-1}_* \frac{x.im}{x.re}\right)}^{2}, 1\right)\right)}{\cos \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right)}}\\ \mathbf{elif}\;y.re \le 130426541531277090057616837214952488960:\\ \;\;\;\;\left(\log \left(e^{\cos \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right)}\right) \cdot e^{\left(-\sqrt[3]{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\right) \cdot \left(\sqrt[3]{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}} \cdot \sqrt[3]{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\right)}\right) \cdot {\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}\\ \mathbf{elif}\;y.re \le 2.993058433867654662682056505364059183978 \cdot 10^{97}:\\ \;\;\;\;e^{\mathsf{fma}\left(y.re, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), \mathsf{fma}\left(-y.im, \tan^{-1}_* \frac{x.im}{x.re}, \log \left(\cos \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right)\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{\frac{\mathsf{fma}\left(y.im, \tan^{-1}_* \frac{x.im}{x.re}, \mathsf{fma}\left(\frac{1}{2} \cdot \left(y.im \cdot y.im\right), {\left(\tan^{-1}_* \frac{x.im}{x.re}\right)}^{2}, 1\right)\right)}{\cos \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right)}}\\ \end{array}\]

Reproduce

herbie shell --seed 2019195 +o rules:numerics
(FPCore (x.re x.im y.re y.im)
  :name "powComplex, real part"
  (* (exp (- (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re) (* (atan2 x.im x.re) y.im))) (cos (+ (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.im) (* (atan2 x.im x.re) y.re)))))