Average Error: 33.4 → 9.2
Time: 32.8s
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}\;x.re \le -1.302949004176668833472564229053635370532 \cdot 10^{-91}:\\ \;\;\;\;e^{\log \left(-x.re\right) \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\ \mathbf{elif}\;x.re \le -1.103571581251483805109260078200264677162 \cdot 10^{-221}:\\ \;\;\;\;e^{y.re \cdot \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\ \mathbf{elif}\;x.re \le -3.389796225933708483567902887503554614601 \cdot 10^{-311}:\\ \;\;\;\;e^{\log \left(-x.re\right) \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\ \mathbf{else}:\\ \;\;\;\;e^{y.re \cdot \log x.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\ \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}\;x.re \le -1.302949004176668833472564229053635370532 \cdot 10^{-91}:\\
\;\;\;\;e^{\log \left(-x.re\right) \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\

\mathbf{elif}\;x.re \le -1.103571581251483805109260078200264677162 \cdot 10^{-221}:\\
\;\;\;\;e^{y.re \cdot \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\

\mathbf{elif}\;x.re \le -3.389796225933708483567902887503554614601 \cdot 10^{-311}:\\
\;\;\;\;e^{\log \left(-x.re\right) \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\

\mathbf{else}:\\
\;\;\;\;e^{y.re \cdot \log x.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\

\end{array}
double f(double x_re, double x_im, double y_re, double y_im) {
        double r1393941 = x_re;
        double r1393942 = r1393941 * r1393941;
        double r1393943 = x_im;
        double r1393944 = r1393943 * r1393943;
        double r1393945 = r1393942 + r1393944;
        double r1393946 = sqrt(r1393945);
        double r1393947 = log(r1393946);
        double r1393948 = y_re;
        double r1393949 = r1393947 * r1393948;
        double r1393950 = atan2(r1393943, r1393941);
        double r1393951 = y_im;
        double r1393952 = r1393950 * r1393951;
        double r1393953 = r1393949 - r1393952;
        double r1393954 = exp(r1393953);
        double r1393955 = r1393947 * r1393951;
        double r1393956 = r1393950 * r1393948;
        double r1393957 = r1393955 + r1393956;
        double r1393958 = cos(r1393957);
        double r1393959 = r1393954 * r1393958;
        return r1393959;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r1393960 = x_re;
        double r1393961 = -1.3029490041766688e-91;
        bool r1393962 = r1393960 <= r1393961;
        double r1393963 = -r1393960;
        double r1393964 = log(r1393963);
        double r1393965 = y_re;
        double r1393966 = r1393964 * r1393965;
        double r1393967 = y_im;
        double r1393968 = x_im;
        double r1393969 = atan2(r1393968, r1393960);
        double r1393970 = r1393967 * r1393969;
        double r1393971 = r1393966 - r1393970;
        double r1393972 = exp(r1393971);
        double r1393973 = -1.1035715812514838e-221;
        bool r1393974 = r1393960 <= r1393973;
        double r1393975 = r1393960 * r1393960;
        double r1393976 = r1393968 * r1393968;
        double r1393977 = r1393975 + r1393976;
        double r1393978 = sqrt(r1393977);
        double r1393979 = log(r1393978);
        double r1393980 = r1393965 * r1393979;
        double r1393981 = r1393980 - r1393970;
        double r1393982 = exp(r1393981);
        double r1393983 = -3.3897962259337e-311;
        bool r1393984 = r1393960 <= r1393983;
        double r1393985 = log(r1393960);
        double r1393986 = r1393965 * r1393985;
        double r1393987 = r1393986 - r1393970;
        double r1393988 = exp(r1393987);
        double r1393989 = r1393984 ? r1393972 : r1393988;
        double r1393990 = r1393974 ? r1393982 : r1393989;
        double r1393991 = r1393962 ? r1393972 : r1393990;
        return r1393991;
}

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 3 regimes
  2. if x.re < -1.3029490041766688e-91 or -1.1035715812514838e-221 < x.re < -3.3897962259337e-311

    1. Initial program 34.3

      \[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 18.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 4.3

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

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

    if -1.3029490041766688e-91 < x.re < -1.1035715812514838e-221

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

      \[\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 -3.3897962259337e-311 < x.re

    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. Taylor expanded around 0 22.1

      \[\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 12.3

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

      \[\leadsto e^{\color{blue}{y.re \cdot \log x.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}} \cdot 1\]
  3. Recombined 3 regimes into one program.
  4. Final simplification9.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \le -1.302949004176668833472564229053635370532 \cdot 10^{-91}:\\ \;\;\;\;e^{\log \left(-x.re\right) \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\ \mathbf{elif}\;x.re \le -1.103571581251483805109260078200264677162 \cdot 10^{-221}:\\ \;\;\;\;e^{y.re \cdot \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\ \mathbf{elif}\;x.re \le -3.389796225933708483567902887503554614601 \cdot 10^{-311}:\\ \;\;\;\;e^{\log \left(-x.re\right) \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\ \mathbf{else}:\\ \;\;\;\;e^{y.re \cdot \log x.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\ \end{array}\]

Reproduce

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