Average Error: 33.2 → 5.6
Time: 16.4s
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 r15122 = x_re;
        double r15123 = r15122 * r15122;
        double r15124 = x_im;
        double r15125 = r15124 * r15124;
        double r15126 = r15123 + r15125;
        double r15127 = sqrt(r15126);
        double r15128 = log(r15127);
        double r15129 = y_re;
        double r15130 = r15128 * r15129;
        double r15131 = atan2(r15124, r15122);
        double r15132 = y_im;
        double r15133 = r15131 * r15132;
        double r15134 = r15130 - r15133;
        double r15135 = exp(r15134);
        double r15136 = r15128 * r15132;
        double r15137 = r15131 * r15129;
        double r15138 = r15136 + r15137;
        double r15139 = cos(r15138);
        double r15140 = r15135 * r15139;
        return r15140;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r15141 = y_re;
        double r15142 = -7.937272784933259e-16;
        bool r15143 = r15141 <= r15142;
        double r15144 = 2.687600014275229e-11;
        bool r15145 = r15141 <= r15144;
        double r15146 = !r15145;
        bool r15147 = r15143 || r15146;
        double r15148 = x_re;
        double r15149 = r15148 * r15148;
        double r15150 = x_im;
        double r15151 = r15150 * r15150;
        double r15152 = r15149 + r15151;
        double r15153 = sqrt(r15152);
        double r15154 = log(r15153);
        double r15155 = r15154 * r15141;
        double r15156 = atan2(r15150, r15148);
        double r15157 = y_im;
        double r15158 = r15156 * r15157;
        double r15159 = r15155 - r15158;
        double r15160 = exp(r15159);
        double r15161 = -r15158;
        double r15162 = exp(r15161);
        double r15163 = r15147 ? r15160 : r15162;
        return r15163;
}

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)))))