Average Error: 33.2 → 5.6
Time: 7.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 -7.9372727849332594 \cdot 10^{-16} \lor \neg \left(y.re \le 2.687600014275229 \cdot 10^{-11}\right):\\ \;\;\;\;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 1\\ \mathbf{else}:\\ \;\;\;\;e^{\left(-\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im\right) - 0} \cdot 1\\ \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 -7.9372727849332594 \cdot 10^{-16} \lor \neg \left(y.re \le 2.687600014275229 \cdot 10^{-11}\right):\\
\;\;\;\;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 1\\

\mathbf{else}:\\
\;\;\;\;e^{\left(-\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im\right) - 0} \cdot 1\\

\end{array}
double f(double x_re, double x_im, double y_re, double y_im) {
        double r12890 = x_re;
        double r12891 = r12890 * r12890;
        double r12892 = x_im;
        double r12893 = r12892 * r12892;
        double r12894 = r12891 + r12893;
        double r12895 = sqrt(r12894);
        double r12896 = log(r12895);
        double r12897 = y_re;
        double r12898 = r12896 * r12897;
        double r12899 = atan2(r12892, r12890);
        double r12900 = y_im;
        double r12901 = r12899 * r12900;
        double r12902 = r12898 - r12901;
        double r12903 = exp(r12902);
        double r12904 = r12896 * r12900;
        double r12905 = r12899 * r12897;
        double r12906 = r12904 + r12905;
        double r12907 = cos(r12906);
        double r12908 = r12903 * r12907;
        return r12908;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r12909 = y_re;
        double r12910 = -7.937272784933259e-16;
        bool r12911 = r12909 <= r12910;
        double r12912 = 2.687600014275229e-11;
        bool r12913 = r12909 <= r12912;
        double r12914 = !r12913;
        bool r12915 = r12911 || r12914;
        double r12916 = x_re;
        double r12917 = r12916 * r12916;
        double r12918 = x_im;
        double r12919 = r12918 * r12918;
        double r12920 = r12917 + r12919;
        double r12921 = sqrt(r12920);
        double r12922 = log(r12921);
        double r12923 = r12922 * r12909;
        double r12924 = atan2(r12918, r12916);
        double r12925 = y_im;
        double r12926 = r12924 * r12925;
        double r12927 = r12923 - r12926;
        double r12928 = exp(r12927);
        double r12929 = 1.0;
        double r12930 = r12928 * r12929;
        double r12931 = -r12926;
        double r12932 = 0.0;
        double r12933 = r12931 - r12932;
        double r12934 = exp(r12933);
        double r12935 = r12934 * r12929;
        double r12936 = r12915 ? r12930 : r12935;
        return r12936;
}

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 y.re < -7.937272784933259e-16 or 2.687600014275229e-11 < y.re

    1. Initial program 32.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. Taylor expanded around 0 5.4

      \[\leadsto 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 \color{blue}{1}\]

    if -7.937272784933259e-16 < y.re < 2.687600014275229e-11

    1. Initial program 33.8

      \[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. Taylor expanded around 0 29.8

      \[\leadsto 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 \color{blue}{1}\]
    3. Taylor expanded around -inf 33.8

      \[\leadsto \color{blue}{e^{-\left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im + y.re \cdot \log \left(\frac{-1}{x.re}\right)\right)}} \cdot 1\]
    4. Simplified33.8

      \[\leadsto \color{blue}{\frac{e^{-\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}}{{\left(\frac{-1}{x.re}\right)}^{y.re}}} \cdot 1\]
    5. Using strategy rm
    6. Applied add-exp-log64.0

      \[\leadsto \frac{e^{-\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}}{{\left(\frac{-1}{\color{blue}{e^{\log x.re}}}\right)}^{y.re}} \cdot 1\]
    7. Applied add-exp-log64.0

      \[\leadsto \frac{e^{-\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}}{{\left(\frac{\color{blue}{e^{\log -1}}}{e^{\log x.re}}\right)}^{y.re}} \cdot 1\]
    8. Applied div-exp64.0

      \[\leadsto \frac{e^{-\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}}{{\color{blue}{\left(e^{\log -1 - \log x.re}\right)}}^{y.re}} \cdot 1\]
    9. Applied pow-exp64.0

      \[\leadsto \frac{e^{-\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}}{\color{blue}{e^{\left(\log -1 - \log x.re\right) \cdot y.re}}} \cdot 1\]
    10. Applied div-exp64.0

      \[\leadsto \color{blue}{e^{\left(-\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im\right) - \left(\log -1 - \log x.re\right) \cdot y.re}} \cdot 1\]
    11. Simplified33.8

      \[\leadsto e^{\color{blue}{\left(-\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im\right) - \log \left({\left(\frac{-1}{x.re}\right)}^{y.re}\right)}} \cdot 1\]
    12. Taylor expanded around inf 5.7

      \[\leadsto e^{\left(-\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im\right) - \color{blue}{0}} \cdot 1\]
  3. Recombined 2 regimes into one program.
  4. Final simplification5.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.re \le -7.9372727849332594 \cdot 10^{-16} \lor \neg \left(y.re \le 2.687600014275229 \cdot 10^{-11}\right):\\ \;\;\;\;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 1\\ \mathbf{else}:\\ \;\;\;\;e^{\left(-\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im\right) - 0} \cdot 1\\ \end{array}\]

Reproduce

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