Average Error: 33.2 → 5.6
Time: 14.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 -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}\\ \mathbf{else}:\\ \;\;\;\;e^{-\tan^{-1}_* \frac{x.im}{x.re} \cdot 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}\;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}\\

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

\end{array}
double f(double x_re, double x_im, double y_re, double y_im) {
        double r13689 = x_re;
        double r13690 = r13689 * r13689;
        double r13691 = x_im;
        double r13692 = r13691 * r13691;
        double r13693 = r13690 + r13692;
        double r13694 = sqrt(r13693);
        double r13695 = log(r13694);
        double r13696 = y_re;
        double r13697 = r13695 * r13696;
        double r13698 = atan2(r13691, r13689);
        double r13699 = y_im;
        double r13700 = r13698 * r13699;
        double r13701 = r13697 - r13700;
        double r13702 = exp(r13701);
        double r13703 = r13695 * r13699;
        double r13704 = r13698 * r13696;
        double r13705 = r13703 + r13704;
        double r13706 = cos(r13705);
        double r13707 = r13702 * r13706;
        return r13707;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r13708 = y_re;
        double r13709 = -7.937272784933259e-16;
        bool r13710 = r13708 <= r13709;
        double r13711 = 2.687600014275229e-11;
        bool r13712 = r13708 <= r13711;
        double r13713 = !r13712;
        bool r13714 = r13710 || r13713;
        double r13715 = x_re;
        double r13716 = r13715 * r13715;
        double r13717 = x_im;
        double r13718 = r13717 * r13717;
        double r13719 = r13716 + r13718;
        double r13720 = sqrt(r13719);
        double r13721 = log(r13720);
        double r13722 = r13721 * r13708;
        double r13723 = atan2(r13717, r13715);
        double r13724 = y_im;
        double r13725 = r13723 * r13724;
        double r13726 = r13722 - r13725;
        double r13727 = exp(r13726);
        double r13728 = -r13725;
        double r13729 = exp(r13728);
        double r13730 = r13714 ? r13727 : r13729;
        return r13730;
}

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{{\left(\frac{-1}{x.re}\right)}^{\left(-y.re\right)}}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}}} \cdot 1\]
    5. Using strategy rm
    6. Applied add-exp-log64.0

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

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

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

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

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

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

      \[\leadsto e^{\color{blue}{0} - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \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}\\ \mathbf{else}:\\ \;\;\;\;e^{-\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\ \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)))))