Average Error: 30.9 → 0.2
Time: 2.5m
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 -3.248526094834859 \cdot 10^{-13}:\\ \;\;\;\;e^{\log \left(\sqrt{x.im \cdot x.im + x.re \cdot x.re}\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\ \mathbf{else}:\\ \;\;\;\;e^{y.re \cdot \log \left(-x.re\right) - \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 -3.248526094834859 \cdot 10^{-13}:\\
\;\;\;\;e^{\log \left(\sqrt{x.im \cdot x.im + x.re \cdot x.re}\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\

\mathbf{else}:\\
\;\;\;\;e^{y.re \cdot \log \left(-x.re\right) - \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 r966695 = x_re;
        double r966696 = r966695 * r966695;
        double r966697 = x_im;
        double r966698 = r966697 * r966697;
        double r966699 = r966696 + r966698;
        double r966700 = sqrt(r966699);
        double r966701 = log(r966700);
        double r966702 = y_re;
        double r966703 = r966701 * r966702;
        double r966704 = atan2(r966697, r966695);
        double r966705 = y_im;
        double r966706 = r966704 * r966705;
        double r966707 = r966703 - r966706;
        double r966708 = exp(r966707);
        double r966709 = r966701 * r966705;
        double r966710 = r966704 * r966702;
        double r966711 = r966709 + r966710;
        double r966712 = cos(r966711);
        double r966713 = r966708 * r966712;
        return r966713;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r966714 = y_re;
        double r966715 = -3.248526094834859e-13;
        bool r966716 = r966714 <= r966715;
        double r966717 = x_im;
        double r966718 = r966717 * r966717;
        double r966719 = x_re;
        double r966720 = r966719 * r966719;
        double r966721 = r966718 + r966720;
        double r966722 = sqrt(r966721);
        double r966723 = log(r966722);
        double r966724 = r966723 * r966714;
        double r966725 = atan2(r966717, r966719);
        double r966726 = y_im;
        double r966727 = r966725 * r966726;
        double r966728 = r966724 - r966727;
        double r966729 = exp(r966728);
        double r966730 = -r966719;
        double r966731 = log(r966730);
        double r966732 = r966714 * r966731;
        double r966733 = r966732 - r966727;
        double r966734 = exp(r966733);
        double r966735 = r966716 ? r966729 : r966734;
        return r966735;
}

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 < -3.248526094834859e-13

    1. Initial program 36.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 0.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}\]

    if -3.248526094834859e-13 < y.re

    1. Initial program 28.1

      \[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 25.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 0.2

      \[\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. Simplified0.2

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

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

Reproduce

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