Average Error: 33.2 → 8.0
Time: 24.7s
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 -2.337754523786446540689559980369379310842 \cdot 10^{171}:\\ \;\;\;\;\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{else}:\\ \;\;\;\;\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{\frac{{\left({\left(e^{y.im}\right)}^{\left(\sqrt[3]{\tan^{-1}_* \frac{x.im}{x.re}} \cdot \sqrt[3]{\tan^{-1}_* \frac{x.im}{x.re}}\right)}\right)}^{\left(\sqrt[3]{\sqrt[3]{\tan^{-1}_* \frac{x.im}{x.re}}} \cdot \left(\sqrt[3]{\sqrt[3]{\tan^{-1}_* \frac{x.im}{x.re}}} \cdot \sqrt[3]{\sqrt[3]{\tan^{-1}_* \frac{x.im}{x.re}}}\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 -2.337754523786446540689559980369379310842 \cdot 10^{171}:\\
\;\;\;\;\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{else}:\\
\;\;\;\;\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{\frac{{\left({\left(e^{y.im}\right)}^{\left(\sqrt[3]{\tan^{-1}_* \frac{x.im}{x.re}} \cdot \sqrt[3]{\tan^{-1}_* \frac{x.im}{x.re}}\right)}\right)}^{\left(\sqrt[3]{\sqrt[3]{\tan^{-1}_* \frac{x.im}{x.re}}} \cdot \left(\sqrt[3]{\sqrt[3]{\tan^{-1}_* \frac{x.im}{x.re}}} \cdot \sqrt[3]{\sqrt[3]{\tan^{-1}_* \frac{x.im}{x.re}}}\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 r27700 = x_re;
        double r27701 = r27700 * r27700;
        double r27702 = x_im;
        double r27703 = r27702 * r27702;
        double r27704 = r27701 + r27703;
        double r27705 = sqrt(r27704);
        double r27706 = log(r27705);
        double r27707 = y_re;
        double r27708 = r27706 * r27707;
        double r27709 = atan2(r27702, r27700);
        double r27710 = y_im;
        double r27711 = r27709 * r27710;
        double r27712 = r27708 - r27711;
        double r27713 = exp(r27712);
        double r27714 = r27706 * r27710;
        double r27715 = r27709 * r27707;
        double r27716 = r27714 + r27715;
        double r27717 = cos(r27716);
        double r27718 = r27713 * r27717;
        return r27718;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r27719 = y_re;
        double r27720 = -2.3377545237864465e+171;
        bool r27721 = r27719 <= r27720;
        double r27722 = x_re;
        double r27723 = x_im;
        double r27724 = hypot(r27722, r27723);
        double r27725 = pow(r27724, r27719);
        double r27726 = y_im;
        double r27727 = atan2(r27723, r27722);
        double r27728 = 0.5;
        double r27729 = r27726 * r27726;
        double r27730 = r27728 * r27729;
        double r27731 = 2.0;
        double r27732 = pow(r27727, r27731);
        double r27733 = 1.0;
        double r27734 = fma(r27730, r27732, r27733);
        double r27735 = fma(r27726, r27727, r27734);
        double r27736 = log(r27724);
        double r27737 = r27719 * r27727;
        double r27738 = fma(r27726, r27736, r27737);
        double r27739 = cos(r27738);
        double r27740 = r27735 / r27739;
        double r27741 = r27725 / r27740;
        double r27742 = exp(r27726);
        double r27743 = cbrt(r27727);
        double r27744 = r27743 * r27743;
        double r27745 = pow(r27742, r27744);
        double r27746 = cbrt(r27743);
        double r27747 = r27746 * r27746;
        double r27748 = r27746 * r27747;
        double r27749 = pow(r27745, r27748);
        double r27750 = r27749 / r27739;
        double r27751 = r27725 / r27750;
        double r27752 = r27721 ? r27741 : r27751;
        return r27752;
}

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 2 regimes
  2. if y.re < -2.3377545237864465e+171

    1. Initial program 36.5

      \[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. Simplified11.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. Taylor expanded around 0 3.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. Simplified3.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 -2.3377545237864465e+171 < y.re

    1. Initial program 32.7

      \[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. Simplified8.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 add-cube-cbrt8.6

      \[\leadsto \frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{\frac{{\left(e^{y.im}\right)}^{\color{blue}{\left(\left(\sqrt[3]{\tan^{-1}_* \frac{x.im}{x.re}} \cdot \sqrt[3]{\tan^{-1}_* \frac{x.im}{x.re}}\right) \cdot \sqrt[3]{\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. Applied pow-unpow8.6

      \[\leadsto \frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{\frac{\color{blue}{{\left({\left(e^{y.im}\right)}^{\left(\sqrt[3]{\tan^{-1}_* \frac{x.im}{x.re}} \cdot \sqrt[3]{\tan^{-1}_* \frac{x.im}{x.re}}\right)}\right)}^{\left(\sqrt[3]{\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)}}\]
    6. Using strategy rm
    7. Applied add-cube-cbrt8.6

      \[\leadsto \frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{\frac{{\left({\left(e^{y.im}\right)}^{\left(\sqrt[3]{\tan^{-1}_* \frac{x.im}{x.re}} \cdot \sqrt[3]{\tan^{-1}_* \frac{x.im}{x.re}}\right)}\right)}^{\color{blue}{\left(\left(\sqrt[3]{\sqrt[3]{\tan^{-1}_* \frac{x.im}{x.re}}} \cdot \sqrt[3]{\sqrt[3]{\tan^{-1}_* \frac{x.im}{x.re}}}\right) \cdot \sqrt[3]{\sqrt[3]{\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. Recombined 2 regimes into one program.
  4. Final simplification8.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.re \le -2.337754523786446540689559980369379310842 \cdot 10^{171}:\\ \;\;\;\;\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{else}:\\ \;\;\;\;\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{\frac{{\left({\left(e^{y.im}\right)}^{\left(\sqrt[3]{\tan^{-1}_* \frac{x.im}{x.re}} \cdot \sqrt[3]{\tan^{-1}_* \frac{x.im}{x.re}}\right)}\right)}^{\left(\sqrt[3]{\sqrt[3]{\tan^{-1}_* \frac{x.im}{x.re}}} \cdot \left(\sqrt[3]{\sqrt[3]{\tan^{-1}_* \frac{x.im}{x.re}}} \cdot \sqrt[3]{\sqrt[3]{\tan^{-1}_* \frac{x.im}{x.re}}}\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 2019179 +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)))))