Average Error: 33.0 → 6.8
Time: 31.4s
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 \sin \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 -187416260894571862867092446642092113920 \lor \neg \left(y.re \le 1.070292808031735471360214838332236553242 \cdot 10^{-6}\right):\\ \;\;\;\;\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{\frac{\tan^{-1}_* \frac{x.im}{x.re} \cdot \left(\left(\frac{1}{2} \cdot \left(y.im \cdot y.im\right)\right) \cdot \tan^{-1}_* \frac{x.im}{x.re} + y.im\right) + 1}{\sin \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{\frac{{\left(e^{\sqrt[3]{y.im} \cdot \sqrt[3]{y.im}}\right)}^{\left(\frac{\sqrt[3]{y.im}}{\frac{2}{\tan^{-1}_* \frac{x.im}{x.re}}}\right)} \cdot \left(\sqrt{{\left(e^{y.im}\right)}^{\left(\frac{\tan^{-1}_* \frac{x.im}{x.re}}{2}\right)}} \cdot \sqrt{{\left(e^{y.im}\right)}^{\left(\frac{\tan^{-1}_* \frac{x.im}{x.re}}{2}\right)}}\right)}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sin \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right)\right)\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 \sin \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 -187416260894571862867092446642092113920 \lor \neg \left(y.re \le 1.070292808031735471360214838332236553242 \cdot 10^{-6}\right):\\
\;\;\;\;\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{\frac{\tan^{-1}_* \frac{x.im}{x.re} \cdot \left(\left(\frac{1}{2} \cdot \left(y.im \cdot y.im\right)\right) \cdot \tan^{-1}_* \frac{x.im}{x.re} + y.im\right) + 1}{\sin \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right)}}\\

\mathbf{else}:\\
\;\;\;\;\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{\frac{{\left(e^{\sqrt[3]{y.im} \cdot \sqrt[3]{y.im}}\right)}^{\left(\frac{\sqrt[3]{y.im}}{\frac{2}{\tan^{-1}_* \frac{x.im}{x.re}}}\right)} \cdot \left(\sqrt{{\left(e^{y.im}\right)}^{\left(\frac{\tan^{-1}_* \frac{x.im}{x.re}}{2}\right)}} \cdot \sqrt{{\left(e^{y.im}\right)}^{\left(\frac{\tan^{-1}_* \frac{x.im}{x.re}}{2}\right)}}\right)}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sin \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right)\right)\right)}}\\

\end{array}
double f(double x_re, double x_im, double y_re, double y_im) {
        double r34839 = x_re;
        double r34840 = r34839 * r34839;
        double r34841 = x_im;
        double r34842 = r34841 * r34841;
        double r34843 = r34840 + r34842;
        double r34844 = sqrt(r34843);
        double r34845 = log(r34844);
        double r34846 = y_re;
        double r34847 = r34845 * r34846;
        double r34848 = atan2(r34841, r34839);
        double r34849 = y_im;
        double r34850 = r34848 * r34849;
        double r34851 = r34847 - r34850;
        double r34852 = exp(r34851);
        double r34853 = r34845 * r34849;
        double r34854 = r34848 * r34846;
        double r34855 = r34853 + r34854;
        double r34856 = sin(r34855);
        double r34857 = r34852 * r34856;
        return r34857;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r34858 = y_re;
        double r34859 = -1.8741626089457186e+38;
        bool r34860 = r34858 <= r34859;
        double r34861 = 1.0702928080317355e-06;
        bool r34862 = r34858 <= r34861;
        double r34863 = !r34862;
        bool r34864 = r34860 || r34863;
        double r34865 = x_re;
        double r34866 = x_im;
        double r34867 = hypot(r34865, r34866);
        double r34868 = pow(r34867, r34858);
        double r34869 = atan2(r34866, r34865);
        double r34870 = 0.5;
        double r34871 = y_im;
        double r34872 = r34871 * r34871;
        double r34873 = r34870 * r34872;
        double r34874 = r34873 * r34869;
        double r34875 = r34874 + r34871;
        double r34876 = r34869 * r34875;
        double r34877 = 1.0;
        double r34878 = r34876 + r34877;
        double r34879 = log(r34867);
        double r34880 = r34869 * r34858;
        double r34881 = fma(r34871, r34879, r34880);
        double r34882 = sin(r34881);
        double r34883 = r34878 / r34882;
        double r34884 = r34868 / r34883;
        double r34885 = cbrt(r34871);
        double r34886 = r34885 * r34885;
        double r34887 = exp(r34886);
        double r34888 = 2.0;
        double r34889 = r34888 / r34869;
        double r34890 = r34885 / r34889;
        double r34891 = pow(r34887, r34890);
        double r34892 = exp(r34871);
        double r34893 = r34869 / r34888;
        double r34894 = pow(r34892, r34893);
        double r34895 = sqrt(r34894);
        double r34896 = r34895 * r34895;
        double r34897 = r34891 * r34896;
        double r34898 = log1p(r34882);
        double r34899 = expm1(r34898);
        double r34900 = r34897 / r34899;
        double r34901 = r34868 / r34900;
        double r34902 = r34864 ? r34884 : r34901;
        return r34902;
}

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 < -1.8741626089457186e+38 or 1.0702928080317355e-06 < y.re

    1. Initial program 31.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 \sin \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. Simplified16.0

      \[\leadsto \color{blue}{\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{\frac{{\left(e^{y.im}\right)}^{\left(\tan^{-1}_* \frac{x.im}{x.re}\right)}}{\sin \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right)}}}\]
    3. Taylor expanded around 0 9.3

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

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

    if -1.8741626089457186e+38 < y.re < 1.0702928080317355e-06

    1. Initial program 33.8

      \[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 \sin \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. Simplified6.0

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

      \[\leadsto \frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{\frac{\color{blue}{{\left(e^{y.im}\right)}^{\left(\frac{\tan^{-1}_* \frac{x.im}{x.re}}{2}\right)} \cdot {\left(e^{y.im}\right)}^{\left(\frac{\tan^{-1}_* \frac{x.im}{x.re}}{2}\right)}}}{\sin \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right)}}\]
    5. Using strategy rm
    6. Applied add-cube-cbrt6.0

      \[\leadsto \frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{\frac{{\left(e^{y.im}\right)}^{\left(\frac{\tan^{-1}_* \frac{x.im}{x.re}}{2}\right)} \cdot {\left(e^{\color{blue}{\left(\sqrt[3]{y.im} \cdot \sqrt[3]{y.im}\right) \cdot \sqrt[3]{y.im}}}\right)}^{\left(\frac{\tan^{-1}_* \frac{x.im}{x.re}}{2}\right)}}{\sin \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right)}}\]
    7. Applied exp-prod6.0

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

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

      \[\leadsto \frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{\frac{{\left(e^{y.im}\right)}^{\left(\frac{\tan^{-1}_* \frac{x.im}{x.re}}{2}\right)} \cdot {\left(e^{\sqrt[3]{y.im} \cdot \sqrt[3]{y.im}}\right)}^{\color{blue}{\left(\frac{\sqrt[3]{y.im}}{\frac{2}{\tan^{-1}_* \frac{x.im}{x.re}}}\right)}}}{\sin \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right)}}\]
    10. Using strategy rm
    11. Applied add-sqr-sqrt6.0

      \[\leadsto \frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{\frac{\color{blue}{\left(\sqrt{{\left(e^{y.im}\right)}^{\left(\frac{\tan^{-1}_* \frac{x.im}{x.re}}{2}\right)}} \cdot \sqrt{{\left(e^{y.im}\right)}^{\left(\frac{\tan^{-1}_* \frac{x.im}{x.re}}{2}\right)}}\right)} \cdot {\left(e^{\sqrt[3]{y.im} \cdot \sqrt[3]{y.im}}\right)}^{\left(\frac{\sqrt[3]{y.im}}{\frac{2}{\tan^{-1}_* \frac{x.im}{x.re}}}\right)}}{\sin \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right)}}\]
    12. Using strategy rm
    13. Applied expm1-log1p-u6.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.re \le -187416260894571862867092446642092113920 \lor \neg \left(y.re \le 1.070292808031735471360214838332236553242 \cdot 10^{-6}\right):\\ \;\;\;\;\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{\frac{\tan^{-1}_* \frac{x.im}{x.re} \cdot \left(\left(\frac{1}{2} \cdot \left(y.im \cdot y.im\right)\right) \cdot \tan^{-1}_* \frac{x.im}{x.re} + y.im\right) + 1}{\sin \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{\frac{{\left(e^{\sqrt[3]{y.im} \cdot \sqrt[3]{y.im}}\right)}^{\left(\frac{\sqrt[3]{y.im}}{\frac{2}{\tan^{-1}_* \frac{x.im}{x.re}}}\right)} \cdot \left(\sqrt{{\left(e^{y.im}\right)}^{\left(\frac{\tan^{-1}_* \frac{x.im}{x.re}}{2}\right)}} \cdot \sqrt{{\left(e^{y.im}\right)}^{\left(\frac{\tan^{-1}_* \frac{x.im}{x.re}}{2}\right)}}\right)}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sin \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right)\right)\right)}}\\ \end{array}\]

Reproduce

herbie shell --seed 2019174 +o rules:numerics
(FPCore (x.re x.im y.re y.im)
  :name "powComplex, imaginary part"
  (* (exp (- (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re) (* (atan2 x.im x.re) y.im))) (sin (+ (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.im) (* (atan2 x.im x.re) y.re)))))