Average Error: 33.1 → 6.2
Time: 19.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}\;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.999999996508012301:\\ \;\;\;\;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 \mathsf{log1p}\left(\mathsf{expm1}\left(1\right)\right)}{e^{\left(\tan^{-1}_* \frac{x.im}{x.re} \cdot \left(\sqrt[3]{y.im} \cdot \sqrt[3]{y.im}\right)\right) \cdot \sqrt[3]{y.im}}}\\ \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.999999996508012301:\\
\;\;\;\;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 \mathsf{log1p}\left(\mathsf{expm1}\left(1\right)\right)}{e^{\left(\tan^{-1}_* \frac{x.im}{x.re} \cdot \left(\sqrt[3]{y.im} \cdot \sqrt[3]{y.im}\right)\right) \cdot \sqrt[3]{y.im}}}\\

\end{array}
double f(double x_re, double x_im, double y_re, double y_im) {
        double r16867 = x_re;
        double r16868 = r16867 * r16867;
        double r16869 = x_im;
        double r16870 = r16869 * r16869;
        double r16871 = r16868 + r16870;
        double r16872 = sqrt(r16871);
        double r16873 = log(r16872);
        double r16874 = y_re;
        double r16875 = r16873 * r16874;
        double r16876 = atan2(r16869, r16867);
        double r16877 = y_im;
        double r16878 = r16876 * r16877;
        double r16879 = r16875 - r16878;
        double r16880 = exp(r16879);
        double r16881 = r16873 * r16877;
        double r16882 = r16876 * r16874;
        double r16883 = r16881 + r16882;
        double r16884 = cos(r16883);
        double r16885 = r16880 * r16884;
        return r16885;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r16886 = x_re;
        double r16887 = r16886 * r16886;
        double r16888 = x_im;
        double r16889 = r16888 * r16888;
        double r16890 = r16887 + r16889;
        double r16891 = sqrt(r16890);
        double r16892 = log(r16891);
        double r16893 = y_re;
        double r16894 = r16892 * r16893;
        double r16895 = atan2(r16888, r16886);
        double r16896 = y_im;
        double r16897 = r16895 * r16896;
        double r16898 = r16894 - r16897;
        double r16899 = exp(r16898);
        double r16900 = r16892 * r16896;
        double r16901 = r16895 * r16893;
        double r16902 = r16900 + r16901;
        double r16903 = cos(r16902);
        double r16904 = r16899 * r16903;
        double r16905 = 0.9999999965080123;
        bool r16906 = r16904 <= r16905;
        double r16907 = hypot(r16886, r16888);
        double r16908 = pow(r16907, r16893);
        double r16909 = 1.0;
        double r16910 = expm1(r16909);
        double r16911 = log1p(r16910);
        double r16912 = r16908 * r16911;
        double r16913 = cbrt(r16896);
        double r16914 = r16913 * r16913;
        double r16915 = r16895 * r16914;
        double r16916 = r16915 * r16913;
        double r16917 = exp(r16916);
        double r16918 = r16912 / r16917;
        double r16919 = r16906 ? r16904 : r16918;
        return r16919;
}

Error

Bits error versus x.re

Bits error versus x.im

Bits error versus y.re

Bits error versus y.im

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

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.9999999965080123

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

    if 0.9999999965080123 < (* (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.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.5

      \[\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-cube-cbrt6.5

      \[\leadsto \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 \color{blue}{\left(\left(\sqrt[3]{y.im} \cdot \sqrt[3]{y.im}\right) \cdot \sqrt[3]{y.im}\right)}}}\]
    5. Applied associate-*r*6.5

      \[\leadsto \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^{\color{blue}{\left(\tan^{-1}_* \frac{x.im}{x.re} \cdot \left(\sqrt[3]{y.im} \cdot \sqrt[3]{y.im}\right)\right) \cdot \sqrt[3]{y.im}}}}\]
    6. Using strategy rm
    7. Applied log1p-expm1-u6.5

      \[\leadsto \frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re} \cdot \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\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)\right)}}{e^{\left(\tan^{-1}_* \frac{x.im}{x.re} \cdot \left(\sqrt[3]{y.im} \cdot \sqrt[3]{y.im}\right)\right) \cdot \sqrt[3]{y.im}}}\]
    8. Taylor expanded around 0 7.0

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

    \[\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.999999996508012301:\\ \;\;\;\;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 \mathsf{log1p}\left(\mathsf{expm1}\left(1\right)\right)}{e^{\left(\tan^{-1}_* \frac{x.im}{x.re} \cdot \left(\sqrt[3]{y.im} \cdot \sqrt[3]{y.im}\right)\right) \cdot \sqrt[3]{y.im}}}\\ \end{array}\]

Reproduce

herbie shell --seed 2020045 +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)))))