Average Error: 33.0 → 6.2
Time: 17.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}\;y.re \le -2.3684273757276652 \cdot 10^{74} \lor \neg \left(y.re \le 2.22216509311932745 \cdot 10^{-38}\right):\\ \;\;\;\;e^{\log \left(\cos \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right) \cdot {\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}\right) - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re} \cdot \sqrt[3]{{\left(\cos \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right)\right)}^{3}}}{e^{\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}\;y.re \le -2.3684273757276652 \cdot 10^{74} \lor \neg \left(y.re \le 2.22216509311932745 \cdot 10^{-38}\right):\\
\;\;\;\;e^{\log \left(\cos \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right) \cdot {\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}\right) - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\

\mathbf{else}:\\
\;\;\;\;\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re} \cdot \sqrt[3]{{\left(\cos \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right)\right)}^{3}}}{e^{\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 r20157 = x_re;
        double r20158 = r20157 * r20157;
        double r20159 = x_im;
        double r20160 = r20159 * r20159;
        double r20161 = r20158 + r20160;
        double r20162 = sqrt(r20161);
        double r20163 = log(r20162);
        double r20164 = y_re;
        double r20165 = r20163 * r20164;
        double r20166 = atan2(r20159, r20157);
        double r20167 = y_im;
        double r20168 = r20166 * r20167;
        double r20169 = r20165 - r20168;
        double r20170 = exp(r20169);
        double r20171 = r20163 * r20167;
        double r20172 = r20166 * r20164;
        double r20173 = r20171 + r20172;
        double r20174 = cos(r20173);
        double r20175 = r20170 * r20174;
        return r20175;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r20176 = y_re;
        double r20177 = -2.368427375727665e+74;
        bool r20178 = r20176 <= r20177;
        double r20179 = 2.2221650931193274e-38;
        bool r20180 = r20176 <= r20179;
        double r20181 = !r20180;
        bool r20182 = r20178 || r20181;
        double r20183 = x_re;
        double r20184 = x_im;
        double r20185 = hypot(r20183, r20184);
        double r20186 = log(r20185);
        double r20187 = y_im;
        double r20188 = atan2(r20184, r20183);
        double r20189 = r20188 * r20176;
        double r20190 = fma(r20186, r20187, r20189);
        double r20191 = cos(r20190);
        double r20192 = pow(r20185, r20176);
        double r20193 = r20191 * r20192;
        double r20194 = log(r20193);
        double r20195 = r20188 * r20187;
        double r20196 = r20194 - r20195;
        double r20197 = exp(r20196);
        double r20198 = 3.0;
        double r20199 = pow(r20191, r20198);
        double r20200 = cbrt(r20199);
        double r20201 = r20192 * r20200;
        double r20202 = exp(r20195);
        double r20203 = r20201 / r20202;
        double r20204 = r20182 ? r20197 : r20203;
        return r20204;
}

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 < -2.368427375727665e+74 or 2.2221650931193274e-38 < y.re

    1. Initial program 30.4

      \[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. Simplified14.2

      \[\leadsto \color{blue}{\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re} \cdot \cos \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right)}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}}}\]
    3. Using strategy rm
    4. Applied add-cbrt-cube14.2

      \[\leadsto \frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re} \cdot \color{blue}{\sqrt[3]{\left(\cos \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right) \cdot \cos \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right)\right) \cdot \cos \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right)}}}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}}\]
    5. Simplified14.2

      \[\leadsto \frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re} \cdot \sqrt[3]{\color{blue}{{\left(\cos \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right)\right)}^{3}}}}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}}\]
    6. Using strategy rm
    7. Applied add-log-exp14.2

      \[\leadsto \frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re} \cdot \sqrt[3]{{\color{blue}{\left(\log \left(e^{\cos \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right)}\right)\right)}}^{3}}}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}}\]
    8. Using strategy rm
    9. Applied add-exp-log35.1

      \[\leadsto \frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re} \cdot \color{blue}{e^{\log \left(\sqrt[3]{{\left(\log \left(e^{\cos \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right)}\right)\right)}^{3}}\right)}}}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}}\]
    10. Applied add-exp-log35.1

      \[\leadsto \frac{{\color{blue}{\left(e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)}\right)}}^{y.re} \cdot e^{\log \left(\sqrt[3]{{\left(\log \left(e^{\cos \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right)}\right)\right)}^{3}}\right)}}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}}\]
    11. Applied pow-exp35.1

      \[\leadsto \frac{\color{blue}{e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re}} \cdot e^{\log \left(\sqrt[3]{{\left(\log \left(e^{\cos \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right)}\right)\right)}^{3}}\right)}}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}}\]
    12. Applied prod-exp35.1

      \[\leadsto \frac{\color{blue}{e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re + \log \left(\sqrt[3]{{\left(\log \left(e^{\cos \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right)}\right)\right)}^{3}}\right)}}}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}}\]
    13. Applied div-exp28.7

      \[\leadsto \color{blue}{e^{\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re + \log \left(\sqrt[3]{{\left(\log \left(e^{\cos \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right)}\right)\right)}^{3}}\right)\right) - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}}\]
    14. Simplified7.9

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

    if -2.368427375727665e+74 < y.re < 2.2221650931193274e-38

    1. Initial program 34.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. Simplified5.2

      \[\leadsto \color{blue}{\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re} \cdot \cos \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right)}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}}}\]
    3. Using strategy rm
    4. Applied add-cbrt-cube5.2

      \[\leadsto \frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re} \cdot \color{blue}{\sqrt[3]{\left(\cos \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right) \cdot \cos \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right)\right) \cdot \cos \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right)}}}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}}\]
    5. Simplified5.2

      \[\leadsto \frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re} \cdot \sqrt[3]{\color{blue}{{\left(\cos \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right)\right)}^{3}}}}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification6.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.re \le -2.3684273757276652 \cdot 10^{74} \lor \neg \left(y.re \le 2.22216509311932745 \cdot 10^{-38}\right):\\ \;\;\;\;e^{\log \left(\cos \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right) \cdot {\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}\right) - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re} \cdot \sqrt[3]{{\left(\cos \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right)\right)}^{3}}}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}}\\ \end{array}\]

Reproduce

herbie shell --seed 2020042 +o rules:numerics
(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)))))