Average Error: 30.8 → 0.3
Time: 2.4m
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 -787531631.566583:\\ \;\;\;\;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 r458935 = x_re;
        double r458936 = r458935 * r458935;
        double r458937 = x_im;
        double r458938 = r458937 * r458937;
        double r458939 = r458936 + r458938;
        double r458940 = sqrt(r458939);
        double r458941 = log(r458940);
        double r458942 = y_re;
        double r458943 = r458941 * r458942;
        double r458944 = atan2(r458937, r458935);
        double r458945 = y_im;
        double r458946 = r458944 * r458945;
        double r458947 = r458943 - r458946;
        double r458948 = exp(r458947);
        double r458949 = r458941 * r458945;
        double r458950 = r458944 * r458942;
        double r458951 = r458949 + r458950;
        double r458952 = cos(r458951);
        double r458953 = r458948 * r458952;
        return r458953;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r458954 = y_re;
        double r458955 = -787531631.566583;
        bool r458956 = r458954 <= r458955;
        double r458957 = x_im;
        double r458958 = r458957 * r458957;
        double r458959 = x_re;
        double r458960 = r458959 * r458959;
        double r458961 = r458958 + r458960;
        double r458962 = sqrt(r458961);
        double r458963 = log(r458962);
        double r458964 = r458963 * r458954;
        double r458965 = atan2(r458957, r458959);
        double r458966 = y_im;
        double r458967 = r458965 * r458966;
        double r458968 = r458964 - r458967;
        double r458969 = exp(r458968);
        double r458970 = -r458959;
        double r458971 = log(r458970);
        double r458972 = r458954 * r458971;
        double r458973 = r458972 - r458967;
        double r458974 = exp(r458973);
        double r458975 = r458956 ? r458969 : r458974;
        return r458975;
}

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 -787531631.566583:\\
\;\;\;\;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}

Error

Bits error versus x.re

Bits error versus x.im

Bits error versus y.re

Bits error versus y.im

Derivation

  1. Split input into 2 regimes
  2. if y.re < -787531631.566583

    1. Initial program 36.2

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

      \[\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 -787531631.566583 < y.re

    1. Initial program 28.2

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.re \le -787531631.566583:\\ \;\;\;\;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 2019102 
(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)))))