Average Error: 33.8 → 9.3
Time: 18.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}\;x.re \le -1.99303880436604133 \cdot 10^{-80}:\\ \;\;\;\;e^{\log \left(-x.re\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\ \mathbf{elif}\;x.re \le 2.986375179024046 \cdot 10^{-310} \lor \neg \left(x.re \le 8.899433436760234 \cdot 10^{-153}\right) \land x.re \le 5.92453119316243509 \cdot 10^{-30}:\\ \;\;\;\;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^{\log x.re \cdot y.re - \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}\;x.re \le -1.99303880436604133 \cdot 10^{-80}:\\
\;\;\;\;e^{\log \left(-x.re\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\

\mathbf{elif}\;x.re \le 2.986375179024046 \cdot 10^{-310} \lor \neg \left(x.re \le 8.899433436760234 \cdot 10^{-153}\right) \land x.re \le 5.92453119316243509 \cdot 10^{-30}:\\
\;\;\;\;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^{\log x.re \cdot y.re - \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 r16743 = x_re;
        double r16744 = r16743 * r16743;
        double r16745 = x_im;
        double r16746 = r16745 * r16745;
        double r16747 = r16744 + r16746;
        double r16748 = sqrt(r16747);
        double r16749 = log(r16748);
        double r16750 = y_re;
        double r16751 = r16749 * r16750;
        double r16752 = atan2(r16745, r16743);
        double r16753 = y_im;
        double r16754 = r16752 * r16753;
        double r16755 = r16751 - r16754;
        double r16756 = exp(r16755);
        double r16757 = r16749 * r16753;
        double r16758 = r16752 * r16750;
        double r16759 = r16757 + r16758;
        double r16760 = cos(r16759);
        double r16761 = r16756 * r16760;
        return r16761;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r16762 = x_re;
        double r16763 = -1.9930388043660413e-80;
        bool r16764 = r16762 <= r16763;
        double r16765 = -r16762;
        double r16766 = log(r16765);
        double r16767 = y_re;
        double r16768 = r16766 * r16767;
        double r16769 = x_im;
        double r16770 = atan2(r16769, r16762);
        double r16771 = y_im;
        double r16772 = r16770 * r16771;
        double r16773 = r16768 - r16772;
        double r16774 = exp(r16773);
        double r16775 = 2.98637517902405e-310;
        bool r16776 = r16762 <= r16775;
        double r16777 = 8.899433436760234e-153;
        bool r16778 = r16762 <= r16777;
        double r16779 = !r16778;
        double r16780 = 5.924531193162435e-30;
        bool r16781 = r16762 <= r16780;
        bool r16782 = r16779 && r16781;
        bool r16783 = r16776 || r16782;
        double r16784 = r16762 * r16762;
        double r16785 = r16769 * r16769;
        double r16786 = r16784 + r16785;
        double r16787 = sqrt(r16786);
        double r16788 = log(r16787);
        double r16789 = r16788 * r16767;
        double r16790 = r16789 - r16772;
        double r16791 = exp(r16790);
        double r16792 = log(r16762);
        double r16793 = r16792 * r16767;
        double r16794 = r16793 - r16772;
        double r16795 = exp(r16794);
        double r16796 = r16783 ? r16791 : r16795;
        double r16797 = r16764 ? r16774 : r16796;
        return r16797;
}

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.9930388043660413e-80

    1. Initial program 35.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 19.6

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

      \[\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. Simplified2.9

      \[\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.9930388043660413e-80 < x.re < 2.98637517902405e-310 or 8.899433436760234e-153 < x.re < 5.924531193162435e-30

    1. Initial program 23.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 13.2

      \[\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 2.98637517902405e-310 < x.re < 8.899433436760234e-153 or 5.924531193162435e-30 < x.re

    1. Initial program 39.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 24.3

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \le -1.99303880436604133 \cdot 10^{-80}:\\ \;\;\;\;e^{\log \left(-x.re\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\ \mathbf{elif}\;x.re \le 2.986375179024046 \cdot 10^{-310} \lor \neg \left(x.re \le 8.899433436760234 \cdot 10^{-153}\right) \land x.re \le 5.92453119316243509 \cdot 10^{-30}:\\ \;\;\;\;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^{\log x.re \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\ \end{array}\]

Reproduce

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