Average Error: 33.2 → 5.7
Time: 17.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}\;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) \le 0.827210254356576136:\\ \;\;\;\;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)\\ \mathbf{else}:\\ \;\;\;\;\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re} \cdot \sqrt[3]{{\left(\cos \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right)\right)}^{3}}}{e^{\left(\sqrt[3]{\tan^{-1}_* \frac{x.im}{x.re}} \cdot \sqrt[3]{\tan^{-1}_* \frac{x.im}{x.re}}\right) \cdot \left(\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) \cdot y.im\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}\;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) \le 0.827210254356576136:\\
\;\;\;\;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)\\

\mathbf{else}:\\
\;\;\;\;\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re} \cdot \sqrt[3]{{\left(\cos \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right)\right)}^{3}}}{e^{\left(\sqrt[3]{\tan^{-1}_* \frac{x.im}{x.re}} \cdot \sqrt[3]{\tan^{-1}_* \frac{x.im}{x.re}}\right) \cdot \left(\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) \cdot y.im\right)}}\\

\end{array}
double f(double x_re, double x_im, double y_re, double y_im) {
        double r14988 = x_re;
        double r14989 = r14988 * r14988;
        double r14990 = x_im;
        double r14991 = r14990 * r14990;
        double r14992 = r14989 + r14991;
        double r14993 = sqrt(r14992);
        double r14994 = log(r14993);
        double r14995 = y_re;
        double r14996 = r14994 * r14995;
        double r14997 = atan2(r14990, r14988);
        double r14998 = y_im;
        double r14999 = r14997 * r14998;
        double r15000 = r14996 - r14999;
        double r15001 = exp(r15000);
        double r15002 = r14994 * r14998;
        double r15003 = r14997 * r14995;
        double r15004 = r15002 + r15003;
        double r15005 = cos(r15004);
        double r15006 = r15001 * r15005;
        return r15006;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r15007 = x_re;
        double r15008 = r15007 * r15007;
        double r15009 = x_im;
        double r15010 = r15009 * r15009;
        double r15011 = r15008 + r15010;
        double r15012 = sqrt(r15011);
        double r15013 = log(r15012);
        double r15014 = y_re;
        double r15015 = r15013 * r15014;
        double r15016 = atan2(r15009, r15007);
        double r15017 = y_im;
        double r15018 = r15016 * r15017;
        double r15019 = r15015 - r15018;
        double r15020 = exp(r15019);
        double r15021 = r15013 * r15017;
        double r15022 = r15016 * r15014;
        double r15023 = r15021 + r15022;
        double r15024 = cos(r15023);
        double r15025 = r15020 * r15024;
        double r15026 = 0.8272102543565761;
        bool r15027 = r15025 <= r15026;
        double r15028 = hypot(r15007, r15009);
        double r15029 = pow(r15028, r15014);
        double r15030 = log(r15028);
        double r15031 = fma(r15030, r15017, r15022);
        double r15032 = cos(r15031);
        double r15033 = 3.0;
        double r15034 = pow(r15032, r15033);
        double r15035 = cbrt(r15034);
        double r15036 = r15029 * r15035;
        double r15037 = cbrt(r15016);
        double r15038 = r15037 * r15037;
        double r15039 = cbrt(r15037);
        double r15040 = r15039 * r15039;
        double r15041 = r15040 * r15039;
        double r15042 = r15041 * r15017;
        double r15043 = r15038 * r15042;
        double r15044 = exp(r15043);
        double r15045 = r15036 / r15044;
        double r15046 = r15027 ? r15025 : r15045;
        return r15046;
}

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 (* (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)))) < 0.8272102543565761

    1. Initial program 3.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)\]

    if 0.8272102543565761 < (* (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))))

    1. Initial program 46.0

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

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

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

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

      \[\leadsto \frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re} \cdot \sqrt[3]{{\left(\cos \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right)\right)}^{3}}}{e^{\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)} \cdot y.im}}\]
    8. Applied associate-*l*6.6

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

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

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

Reproduce

herbie shell --seed 2020047 +o rules:numerics
(FPCore (x.re x.im y.re y.im)
  :name "powComplex, real part"
  :precision binary64
  (* (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)))))