Average Error: 33.4 → 9.8
Time: 27.3s
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 -8.347507979969241486948742852688964966035 \cdot 10^{-8}:\\ \;\;\;\;e^{\left(-y.re \cdot \log \left(\frac{-1}{x.re}\right)\right) - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\ \mathbf{elif}\;x.re \le -1.975264043799633099791098579532233442478 \cdot 10^{-108}:\\ \;\;\;\;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 \log \left(e^{\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)}\right)\\ \mathbf{elif}\;x.re \le 3.349147583948195403848168882003582715971 \cdot 10^{-310}:\\ \;\;\;\;e^{\left(-y.re \cdot \log \left(\frac{-1}{x.re}\right)\right) - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\ \mathbf{else}:\\ \;\;\;\;e^{\log x.re \cdot y.re - \log \left(e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\right)}\\ \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 -8.347507979969241486948742852688964966035 \cdot 10^{-8}:\\
\;\;\;\;e^{\left(-y.re \cdot \log \left(\frac{-1}{x.re}\right)\right) - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\

\mathbf{elif}\;x.re \le -1.975264043799633099791098579532233442478 \cdot 10^{-108}:\\
\;\;\;\;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 \log \left(e^{\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)}\right)\\

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

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

\end{array}
double f(double x_re, double x_im, double y_re, double y_im) {
        double r22991 = x_re;
        double r22992 = r22991 * r22991;
        double r22993 = x_im;
        double r22994 = r22993 * r22993;
        double r22995 = r22992 + r22994;
        double r22996 = sqrt(r22995);
        double r22997 = log(r22996);
        double r22998 = y_re;
        double r22999 = r22997 * r22998;
        double r23000 = atan2(r22993, r22991);
        double r23001 = y_im;
        double r23002 = r23000 * r23001;
        double r23003 = r22999 - r23002;
        double r23004 = exp(r23003);
        double r23005 = r22997 * r23001;
        double r23006 = r23000 * r22998;
        double r23007 = r23005 + r23006;
        double r23008 = cos(r23007);
        double r23009 = r23004 * r23008;
        return r23009;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r23010 = x_re;
        double r23011 = -8.347507979969241e-08;
        bool r23012 = r23010 <= r23011;
        double r23013 = y_re;
        double r23014 = -1.0;
        double r23015 = r23014 / r23010;
        double r23016 = log(r23015);
        double r23017 = r23013 * r23016;
        double r23018 = -r23017;
        double r23019 = x_im;
        double r23020 = atan2(r23019, r23010);
        double r23021 = y_im;
        double r23022 = r23020 * r23021;
        double r23023 = r23018 - r23022;
        double r23024 = exp(r23023);
        double r23025 = -1.975264043799633e-108;
        bool r23026 = r23010 <= r23025;
        double r23027 = r23010 * r23010;
        double r23028 = r23019 * r23019;
        double r23029 = r23027 + r23028;
        double r23030 = sqrt(r23029);
        double r23031 = log(r23030);
        double r23032 = r23031 * r23013;
        double r23033 = r23032 - r23022;
        double r23034 = exp(r23033);
        double r23035 = r23031 * r23021;
        double r23036 = r23020 * r23013;
        double r23037 = r23035 + r23036;
        double r23038 = cos(r23037);
        double r23039 = exp(r23038);
        double r23040 = log(r23039);
        double r23041 = r23034 * r23040;
        double r23042 = 3.3491475839482e-310;
        bool r23043 = r23010 <= r23042;
        double r23044 = log(r23010);
        double r23045 = r23044 * r23013;
        double r23046 = exp(r23022);
        double r23047 = log(r23046);
        double r23048 = r23045 - r23047;
        double r23049 = exp(r23048);
        double r23050 = r23043 ? r23024 : r23049;
        double r23051 = r23026 ? r23041 : r23050;
        double r23052 = r23012 ? r23024 : r23051;
        return r23052;
}

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 < -8.347507979969241e-08 or -1.975264043799633e-108 < x.re < 3.3491475839482e-310

    1. Initial program 34.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 18.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 4.9

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

      \[\leadsto e^{\color{blue}{\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 -8.347507979969241e-08 < x.re < -1.975264043799633e-108

    1. Initial program 17.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. Using strategy rm
    3. Applied add-log-exp17.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}{\log \left(e^{\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)}\right)}\]

    if 3.3491475839482e-310 < x.re

    1. Initial program 35.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 22.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. Using strategy rm
    4. Applied add-log-exp24.8

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \le -8.347507979969241486948742852688964966035 \cdot 10^{-8}:\\ \;\;\;\;e^{\left(-y.re \cdot \log \left(\frac{-1}{x.re}\right)\right) - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\ \mathbf{elif}\;x.re \le -1.975264043799633099791098579532233442478 \cdot 10^{-108}:\\ \;\;\;\;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 \log \left(e^{\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)}\right)\\ \mathbf{elif}\;x.re \le 3.349147583948195403848168882003582715971 \cdot 10^{-310}:\\ \;\;\;\;e^{\left(-y.re \cdot \log \left(\frac{-1}{x.re}\right)\right) - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\ \mathbf{else}:\\ \;\;\;\;e^{\log x.re \cdot y.re - \log \left(e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\right)}\\ \end{array}\]

Reproduce

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