Average Error: 32.2 → 9.6
Time: 35.9s
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 -4.1355045148069 \cdot 10^{-310}:\\ \;\;\;\;e^{\log \left(-x.re\right) \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\ \mathbf{elif}\;x.re \le 1.4989257856483083 \cdot 10^{-40}:\\ \;\;\;\;e^{y.re \cdot \log x.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\ \mathbf{elif}\;x.re \le 4.8030355459155164 \cdot 10^{+88}:\\ \;\;\;\;\cos \left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.re + \log x.re \cdot y.im\right) \cdot e^{y.re \cdot \log \left(\sqrt{x.im \cdot x.im + x.re \cdot x.re}\right) - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\ \mathbf{else}:\\ \;\;\;\;e^{y.re \cdot \log x.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\ \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 -4.1355045148069 \cdot 10^{-310}:\\
\;\;\;\;e^{\log \left(-x.re\right) \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\

\mathbf{elif}\;x.re \le 1.4989257856483083 \cdot 10^{-40}:\\
\;\;\;\;e^{y.re \cdot \log x.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\

\mathbf{elif}\;x.re \le 4.8030355459155164 \cdot 10^{+88}:\\
\;\;\;\;\cos \left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.re + \log x.re \cdot y.im\right) \cdot e^{y.re \cdot \log \left(\sqrt{x.im \cdot x.im + x.re \cdot x.re}\right) - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\

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

\end{array}
double f(double x_re, double x_im, double y_re, double y_im) {
        double r1025891 = x_re;
        double r1025892 = r1025891 * r1025891;
        double r1025893 = x_im;
        double r1025894 = r1025893 * r1025893;
        double r1025895 = r1025892 + r1025894;
        double r1025896 = sqrt(r1025895);
        double r1025897 = log(r1025896);
        double r1025898 = y_re;
        double r1025899 = r1025897 * r1025898;
        double r1025900 = atan2(r1025893, r1025891);
        double r1025901 = y_im;
        double r1025902 = r1025900 * r1025901;
        double r1025903 = r1025899 - r1025902;
        double r1025904 = exp(r1025903);
        double r1025905 = r1025897 * r1025901;
        double r1025906 = r1025900 * r1025898;
        double r1025907 = r1025905 + r1025906;
        double r1025908 = cos(r1025907);
        double r1025909 = r1025904 * r1025908;
        return r1025909;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r1025910 = x_re;
        double r1025911 = -4.1355045148069e-310;
        bool r1025912 = r1025910 <= r1025911;
        double r1025913 = -r1025910;
        double r1025914 = log(r1025913);
        double r1025915 = y_re;
        double r1025916 = r1025914 * r1025915;
        double r1025917 = y_im;
        double r1025918 = x_im;
        double r1025919 = atan2(r1025918, r1025910);
        double r1025920 = r1025917 * r1025919;
        double r1025921 = r1025916 - r1025920;
        double r1025922 = exp(r1025921);
        double r1025923 = 1.4989257856483083e-40;
        bool r1025924 = r1025910 <= r1025923;
        double r1025925 = log(r1025910);
        double r1025926 = r1025915 * r1025925;
        double r1025927 = r1025926 - r1025920;
        double r1025928 = exp(r1025927);
        double r1025929 = 4.8030355459155164e+88;
        bool r1025930 = r1025910 <= r1025929;
        double r1025931 = r1025919 * r1025915;
        double r1025932 = r1025925 * r1025917;
        double r1025933 = r1025931 + r1025932;
        double r1025934 = cos(r1025933);
        double r1025935 = r1025918 * r1025918;
        double r1025936 = r1025910 * r1025910;
        double r1025937 = r1025935 + r1025936;
        double r1025938 = sqrt(r1025937);
        double r1025939 = log(r1025938);
        double r1025940 = r1025915 * r1025939;
        double r1025941 = r1025940 - r1025920;
        double r1025942 = exp(r1025941);
        double r1025943 = r1025934 * r1025942;
        double r1025944 = r1025930 ? r1025943 : r1025928;
        double r1025945 = r1025924 ? r1025928 : r1025944;
        double r1025946 = r1025912 ? r1025922 : r1025945;
        return r1025946;
}

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 < -4.1355045148069e-310

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

      \[\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. Simplified5.9

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

    if -4.1355045148069e-310 < x.re < 1.4989257856483083e-40 or 4.8030355459155164e+88 < x.re

    1. Initial program 36.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 23.7

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

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

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

    if 1.4989257856483083e-40 < x.re < 4.8030355459155164e+88

    1. Initial program 21.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. Using strategy rm
    3. Applied insert-posit1621.4

      \[\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 \cos \left(\log \color{blue}{\left(\left(\left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)\right)\right)} \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\]
    4. Taylor expanded around inf 14.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}{\cos \left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.re - y.im \cdot \log \left(\frac{1}{x.re}\right)\right)}\]
    5. Simplified14.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}{\cos \left(\log x.re \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification9.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \le -4.1355045148069 \cdot 10^{-310}:\\ \;\;\;\;e^{\log \left(-x.re\right) \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\ \mathbf{elif}\;x.re \le 1.4989257856483083 \cdot 10^{-40}:\\ \;\;\;\;e^{y.re \cdot \log x.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\ \mathbf{elif}\;x.re \le 4.8030355459155164 \cdot 10^{+88}:\\ \;\;\;\;\cos \left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.re + \log x.re \cdot y.im\right) \cdot e^{y.re \cdot \log \left(\sqrt{x.im \cdot x.im + x.re \cdot x.re}\right) - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\ \mathbf{else}:\\ \;\;\;\;e^{y.re \cdot \log x.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\ \end{array}\]

Reproduce

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