Average Error: 33.2 → 9.4
Time: 8.5s
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.924435760338944727609254209791819129719 \cdot 10^{-310}:\\ \;\;\;\;e^{-1 \cdot \left(y.re \cdot \log \left(\frac{-1}{x.re}\right)\right) - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot 1\\ \mathbf{else}:\\ \;\;\;\;e^{\log x.re \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot 1\\ \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.924435760338944727609254209791819129719 \cdot 10^{-310}:\\
\;\;\;\;e^{-1 \cdot \left(y.re \cdot \log \left(\frac{-1}{x.re}\right)\right) - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot 1\\

\mathbf{else}:\\
\;\;\;\;e^{\log x.re \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot 1\\

\end{array}
double f(double x_re, double x_im, double y_re, double y_im) {
        double r16787 = x_re;
        double r16788 = r16787 * r16787;
        double r16789 = x_im;
        double r16790 = r16789 * r16789;
        double r16791 = r16788 + r16790;
        double r16792 = sqrt(r16791);
        double r16793 = log(r16792);
        double r16794 = y_re;
        double r16795 = r16793 * r16794;
        double r16796 = atan2(r16789, r16787);
        double r16797 = y_im;
        double r16798 = r16796 * r16797;
        double r16799 = r16795 - r16798;
        double r16800 = exp(r16799);
        double r16801 = r16793 * r16797;
        double r16802 = r16796 * r16794;
        double r16803 = r16801 + r16802;
        double r16804 = cos(r16803);
        double r16805 = r16800 * r16804;
        return r16805;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r16806 = x_re;
        double r16807 = 1.92443576033894e-310;
        bool r16808 = r16806 <= r16807;
        double r16809 = -1.0;
        double r16810 = y_re;
        double r16811 = r16809 / r16806;
        double r16812 = log(r16811);
        double r16813 = r16810 * r16812;
        double r16814 = r16809 * r16813;
        double r16815 = x_im;
        double r16816 = atan2(r16815, r16806);
        double r16817 = y_im;
        double r16818 = r16816 * r16817;
        double r16819 = r16814 - r16818;
        double r16820 = exp(r16819);
        double r16821 = 1.0;
        double r16822 = r16820 * r16821;
        double r16823 = log(r16806);
        double r16824 = r16823 * r16810;
        double r16825 = r16824 - r16818;
        double r16826 = exp(r16825);
        double r16827 = r16826 * r16821;
        double r16828 = r16808 ? r16822 : r16827;
        return r16828;
}

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 x.re < 1.92443576033894e-310

    1. Initial program 31.6

      \[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 16.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 6.4

      \[\leadsto e^{\color{blue}{-1 \cdot \left(y.re \cdot \log \left(\frac{-1}{x.re}\right)\right)} - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot 1\]

    if 1.92443576033894e-310 < x.re

    1. Initial program 34.7

      \[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 22.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}\]
    3. Taylor expanded around inf 12.3

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

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

Reproduce

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