Average Error: 33.0 → 9.3
Time: 16.8s
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 -2.9876182964047036 \cdot 10^{-221}:\\ \;\;\;\;e^{-\left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im + y.re \cdot \log \left(\frac{-1}{x.re}\right)\right)}\\ \mathbf{elif}\;x.re \le 1.5512797003204989 \cdot 10^{-291} \lor \neg \left(x.re \le 2.36313137794800354 \cdot 10^{-180} \lor \neg \left(x.re \le 0.0035854875341116569\right)\right):\\ \;\;\;\;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 -2.9876182964047036 \cdot 10^{-221}:\\
\;\;\;\;e^{-\left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im + y.re \cdot \log \left(\frac{-1}{x.re}\right)\right)}\\

\mathbf{elif}\;x.re \le 1.5512797003204989 \cdot 10^{-291} \lor \neg \left(x.re \le 2.36313137794800354 \cdot 10^{-180} \lor \neg \left(x.re \le 0.0035854875341116569\right)\right):\\
\;\;\;\;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 r17803 = x_re;
        double r17804 = r17803 * r17803;
        double r17805 = x_im;
        double r17806 = r17805 * r17805;
        double r17807 = r17804 + r17806;
        double r17808 = sqrt(r17807);
        double r17809 = log(r17808);
        double r17810 = y_re;
        double r17811 = r17809 * r17810;
        double r17812 = atan2(r17805, r17803);
        double r17813 = y_im;
        double r17814 = r17812 * r17813;
        double r17815 = r17811 - r17814;
        double r17816 = exp(r17815);
        double r17817 = r17809 * r17813;
        double r17818 = r17812 * r17810;
        double r17819 = r17817 + r17818;
        double r17820 = cos(r17819);
        double r17821 = r17816 * r17820;
        return r17821;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r17822 = x_re;
        double r17823 = -2.9876182964047036e-221;
        bool r17824 = r17822 <= r17823;
        double r17825 = x_im;
        double r17826 = atan2(r17825, r17822);
        double r17827 = y_im;
        double r17828 = r17826 * r17827;
        double r17829 = y_re;
        double r17830 = -1.0;
        double r17831 = r17830 / r17822;
        double r17832 = log(r17831);
        double r17833 = r17829 * r17832;
        double r17834 = r17828 + r17833;
        double r17835 = -r17834;
        double r17836 = exp(r17835);
        double r17837 = 1.551279700320499e-291;
        bool r17838 = r17822 <= r17837;
        double r17839 = 2.3631313779480035e-180;
        bool r17840 = r17822 <= r17839;
        double r17841 = 0.003585487534111657;
        bool r17842 = r17822 <= r17841;
        double r17843 = !r17842;
        bool r17844 = r17840 || r17843;
        double r17845 = !r17844;
        bool r17846 = r17838 || r17845;
        double r17847 = r17822 * r17822;
        double r17848 = r17825 * r17825;
        double r17849 = r17847 + r17848;
        double r17850 = sqrt(r17849);
        double r17851 = log(r17850);
        double r17852 = r17851 * r17829;
        double r17853 = r17852 - r17828;
        double r17854 = exp(r17853);
        double r17855 = log(r17822);
        double r17856 = r17855 * r17829;
        double r17857 = r17856 - r17828;
        double r17858 = exp(r17857);
        double r17859 = r17846 ? r17854 : r17858;
        double r17860 = r17824 ? r17836 : r17859;
        return r17860;
}

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 < -2.9876182964047036e-221

    1. Initial program 31.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 17.9

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

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

    if -2.9876182964047036e-221 < x.re < 1.551279700320499e-291 or 2.3631313779480035e-180 < x.re < 0.003585487534111657

    1. Initial program 25.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 14.9

      \[\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 1.551279700320499e-291 < x.re < 2.3631313779480035e-180 or 0.003585487534111657 < x.re

    1. Initial program 40.0

      \[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.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 10.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 -2.9876182964047036 \cdot 10^{-221}:\\ \;\;\;\;e^{-\left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im + y.re \cdot \log \left(\frac{-1}{x.re}\right)\right)}\\ \mathbf{elif}\;x.re \le 1.5512797003204989 \cdot 10^{-291} \lor \neg \left(x.re \le 2.36313137794800354 \cdot 10^{-180} \lor \neg \left(x.re \le 0.0035854875341116569\right)\right):\\ \;\;\;\;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 2020042 
(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)))))