Average Error: 30.7 → 0.2
Time: 2.6m
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 -2.274314522136351 \cdot 10^{-15}:\\ \;\;\;\;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 -2.274314522136351 \cdot 10^{-15}:\\
\;\;\;\;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 r964893 = x_re;
        double r964894 = r964893 * r964893;
        double r964895 = x_im;
        double r964896 = r964895 * r964895;
        double r964897 = r964894 + r964896;
        double r964898 = sqrt(r964897);
        double r964899 = log(r964898);
        double r964900 = y_re;
        double r964901 = r964899 * r964900;
        double r964902 = atan2(r964895, r964893);
        double r964903 = y_im;
        double r964904 = r964902 * r964903;
        double r964905 = r964901 - r964904;
        double r964906 = exp(r964905);
        double r964907 = r964899 * r964903;
        double r964908 = r964902 * r964900;
        double r964909 = r964907 + r964908;
        double r964910 = cos(r964909);
        double r964911 = r964906 * r964910;
        return r964911;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r964912 = y_re;
        double r964913 = -2.274314522136351e-15;
        bool r964914 = r964912 <= r964913;
        double r964915 = x_im;
        double r964916 = r964915 * r964915;
        double r964917 = x_re;
        double r964918 = r964917 * r964917;
        double r964919 = r964916 + r964918;
        double r964920 = sqrt(r964919);
        double r964921 = log(r964920);
        double r964922 = r964921 * r964912;
        double r964923 = atan2(r964915, r964917);
        double r964924 = y_im;
        double r964925 = r964923 * r964924;
        double r964926 = r964922 - r964925;
        double r964927 = exp(r964926);
        double r964928 = -r964917;
        double r964929 = log(r964928);
        double r964930 = r964912 * r964929;
        double r964931 = r964930 - r964925;
        double r964932 = exp(r964931);
        double r964933 = r964914 ? r964927 : r964932;
        return r964933;
}

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 < -2.274314522136351e-15

    1. Initial program 37.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 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 -2.274314522136351e-15 < y.re

    1. Initial program 27.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 25.0

      \[\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.1

      \[\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.1

      \[\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 -2.274314522136351 \cdot 10^{-15}:\\ \;\;\;\;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 2019128 
(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)))))