Average Error: 33.1 → 7.6
Time: 32.1s
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 -1.060367367938334988739868328111448647633 \cdot 10^{-6}:\\ \;\;\;\;\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{\frac{\mathsf{fma}\left(y.im, \tan^{-1}_* \frac{x.im}{x.re}, \mathsf{fma}\left({\left(\tan^{-1}_* \frac{x.im}{x.re}\right)}^{2} \cdot \left(y.im \cdot y.im\right), \frac{1}{2}, 1\right)\right)}{\sin \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right)}}\\ \mathbf{elif}\;y.re \le 7.350469407454487235492861935126640560156 \cdot 10^{-6}:\\ \;\;\;\;\left(\sin \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), \sqrt[3]{y.re} \cdot \left(\left(\sqrt[3]{y.re} \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) \cdot \sqrt[3]{y.re}\right)\right)\right) \cdot {\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}\right) \cdot e^{\left(-\tan^{-1}_* \frac{x.im}{x.re}\right) \cdot y.im}\\ \mathbf{elif}\;y.re \le 6.712004652234251392357409592474477077753 \cdot 10^{157}:\\ \;\;\;\;\sin \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re} + y.im \cdot \log \left(\sqrt{x.im \cdot x.im + x.re \cdot x.re}\right)\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}:\\ \;\;\;\;\log \left({\left(e^{\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{{\left(e^{\tan^{-1}_* \frac{x.im}{x.re}}\right)}^{y.im}}}\right)}^{\left(\sin \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re \cdot \tan^{-1}_* \frac{x.im}{x.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 -1.060367367938334988739868328111448647633 \cdot 10^{-6}:\\
\;\;\;\;\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{\frac{\mathsf{fma}\left(y.im, \tan^{-1}_* \frac{x.im}{x.re}, \mathsf{fma}\left({\left(\tan^{-1}_* \frac{x.im}{x.re}\right)}^{2} \cdot \left(y.im \cdot y.im\right), \frac{1}{2}, 1\right)\right)}{\sin \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right)}}\\

\mathbf{elif}\;y.re \le 7.350469407454487235492861935126640560156 \cdot 10^{-6}:\\
\;\;\;\;\left(\sin \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), \sqrt[3]{y.re} \cdot \left(\left(\sqrt[3]{y.re} \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) \cdot \sqrt[3]{y.re}\right)\right)\right) \cdot {\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}\right) \cdot e^{\left(-\tan^{-1}_* \frac{x.im}{x.re}\right) \cdot y.im}\\

\mathbf{elif}\;y.re \le 6.712004652234251392357409592474477077753 \cdot 10^{157}:\\
\;\;\;\;\sin \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re} + y.im \cdot \log \left(\sqrt{x.im \cdot x.im + x.re \cdot x.re}\right)\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}:\\
\;\;\;\;\log \left({\left(e^{\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{{\left(e^{\tan^{-1}_* \frac{x.im}{x.re}}\right)}^{y.im}}}\right)}^{\left(\sin \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right)\right)}\right)\\

\end{array}
double f(double x_re, double x_im, double y_re, double y_im) {
        double r34121 = x_re;
        double r34122 = r34121 * r34121;
        double r34123 = x_im;
        double r34124 = r34123 * r34123;
        double r34125 = r34122 + r34124;
        double r34126 = sqrt(r34125);
        double r34127 = log(r34126);
        double r34128 = y_re;
        double r34129 = r34127 * r34128;
        double r34130 = atan2(r34123, r34121);
        double r34131 = y_im;
        double r34132 = r34130 * r34131;
        double r34133 = r34129 - r34132;
        double r34134 = exp(r34133);
        double r34135 = r34127 * r34131;
        double r34136 = r34130 * r34128;
        double r34137 = r34135 + r34136;
        double r34138 = sin(r34137);
        double r34139 = r34134 * r34138;
        return r34139;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r34140 = y_re;
        double r34141 = -1.060367367938335e-06;
        bool r34142 = r34140 <= r34141;
        double r34143 = x_re;
        double r34144 = x_im;
        double r34145 = hypot(r34143, r34144);
        double r34146 = pow(r34145, r34140);
        double r34147 = y_im;
        double r34148 = atan2(r34144, r34143);
        double r34149 = 2.0;
        double r34150 = pow(r34148, r34149);
        double r34151 = r34147 * r34147;
        double r34152 = r34150 * r34151;
        double r34153 = 0.5;
        double r34154 = 1.0;
        double r34155 = fma(r34152, r34153, r34154);
        double r34156 = fma(r34147, r34148, r34155);
        double r34157 = log(r34145);
        double r34158 = r34140 * r34148;
        double r34159 = fma(r34147, r34157, r34158);
        double r34160 = sin(r34159);
        double r34161 = r34156 / r34160;
        double r34162 = r34146 / r34161;
        double r34163 = 7.350469407454487e-06;
        bool r34164 = r34140 <= r34163;
        double r34165 = cbrt(r34140);
        double r34166 = r34165 * r34148;
        double r34167 = r34166 * r34165;
        double r34168 = r34165 * r34167;
        double r34169 = fma(r34147, r34157, r34168);
        double r34170 = sin(r34169);
        double r34171 = r34170 * r34146;
        double r34172 = -r34148;
        double r34173 = r34172 * r34147;
        double r34174 = exp(r34173);
        double r34175 = r34171 * r34174;
        double r34176 = 6.712004652234251e+157;
        bool r34177 = r34140 <= r34176;
        double r34178 = r34144 * r34144;
        double r34179 = r34143 * r34143;
        double r34180 = r34178 + r34179;
        double r34181 = sqrt(r34180);
        double r34182 = log(r34181);
        double r34183 = r34147 * r34182;
        double r34184 = r34158 + r34183;
        double r34185 = sin(r34184);
        double r34186 = r34140 * r34182;
        double r34187 = r34147 * r34148;
        double r34188 = r34186 - r34187;
        double r34189 = exp(r34188);
        double r34190 = r34185 * r34189;
        double r34191 = exp(r34148);
        double r34192 = pow(r34191, r34147);
        double r34193 = r34146 / r34192;
        double r34194 = exp(r34193);
        double r34195 = pow(r34194, r34160);
        double r34196 = log(r34195);
        double r34197 = r34177 ? r34190 : r34196;
        double r34198 = r34164 ? r34175 : r34197;
        double r34199 = r34142 ? r34162 : r34198;
        return r34199;
}

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 4 regimes
  2. if y.re < -1.060367367938335e-06

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

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

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

      \[\leadsto \frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{\frac{\color{blue}{\mathsf{fma}\left(y.im, \tan^{-1}_* \frac{x.im}{x.re}, \mathsf{fma}\left({\left(\tan^{-1}_* \frac{x.im}{x.re}\right)}^{2} \cdot \left(y.im \cdot y.im\right), \frac{1}{2}, 1\right)\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)}}\]

    if -1.060367367938335e-06 < y.re < 7.350469407454487e-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. Simplified5.9

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

      \[\leadsto \frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{\color{blue}{{\left(e^{y.im}\right)}^{\left(\tan^{-1}_* \frac{x.im}{x.re}\right)} \cdot \frac{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)}}}\]
    5. Applied *-un-lft-identity5.9

      \[\leadsto \frac{{\color{blue}{\left(1 \cdot \mathsf{hypot}\left(x.re, x.im\right)\right)}}^{y.re}}{{\left(e^{y.im}\right)}^{\left(\tan^{-1}_* \frac{x.im}{x.re}\right)} \cdot \frac{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)}}\]
    6. Applied unpow-prod-down5.9

      \[\leadsto \frac{\color{blue}{{1}^{y.re} \cdot {\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}}{{\left(e^{y.im}\right)}^{\left(\tan^{-1}_* \frac{x.im}{x.re}\right)} \cdot \frac{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)}}\]
    7. Applied times-frac5.9

      \[\leadsto \color{blue}{\frac{{1}^{y.re}}{{\left(e^{y.im}\right)}^{\left(\tan^{-1}_* \frac{x.im}{x.re}\right)}} \cdot \frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{\frac{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)}}}\]
    8. Simplified5.4

      \[\leadsto \color{blue}{e^{-\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}} \cdot \frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{\frac{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)}}\]
    9. Simplified5.4

      \[\leadsto e^{-\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \color{blue}{\left({\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re} \cdot \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)}\]
    10. Using strategy rm
    11. Applied add-cube-cbrt5.7

      \[\leadsto e^{-\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \left({\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re} \cdot \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 \color{blue}{\left(\left(\sqrt[3]{y.re} \cdot \sqrt[3]{y.re}\right) \cdot \sqrt[3]{y.re}\right)}\right)\right)\right)\]
    12. Applied associate-*r*5.7

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

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

    if 7.350469407454487e-06 < y.re < 6.712004652234251e+157

    1. Initial program 26.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 \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)\]

    if 6.712004652234251e+157 < y.re

    1. Initial program 19.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 \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. Simplified19.3

      \[\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 add-log-exp19.3

      \[\leadsto \color{blue}{\log \left(e^{\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)}}}\right)}\]
    5. Simplified15.0

      \[\leadsto \log \color{blue}{\left({\left(e^{\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{{\left(e^{\tan^{-1}_* \frac{x.im}{x.re}}\right)}^{y.im}}}\right)}^{\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 4 regimes into one program.
  4. Final simplification7.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.re \le -1.060367367938334988739868328111448647633 \cdot 10^{-6}:\\ \;\;\;\;\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{\frac{\mathsf{fma}\left(y.im, \tan^{-1}_* \frac{x.im}{x.re}, \mathsf{fma}\left({\left(\tan^{-1}_* \frac{x.im}{x.re}\right)}^{2} \cdot \left(y.im \cdot y.im\right), \frac{1}{2}, 1\right)\right)}{\sin \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right)}}\\ \mathbf{elif}\;y.re \le 7.350469407454487235492861935126640560156 \cdot 10^{-6}:\\ \;\;\;\;\left(\sin \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), \sqrt[3]{y.re} \cdot \left(\left(\sqrt[3]{y.re} \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) \cdot \sqrt[3]{y.re}\right)\right)\right) \cdot {\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}\right) \cdot e^{\left(-\tan^{-1}_* \frac{x.im}{x.re}\right) \cdot y.im}\\ \mathbf{elif}\;y.re \le 6.712004652234251392357409592474477077753 \cdot 10^{157}:\\ \;\;\;\;\sin \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re} + y.im \cdot \log \left(\sqrt{x.im \cdot x.im + x.re \cdot x.re}\right)\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}:\\ \;\;\;\;\log \left({\left(e^{\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{{\left(e^{\tan^{-1}_* \frac{x.im}{x.re}}\right)}^{y.im}}}\right)}^{\left(\sin \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right)\right)}\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019194 +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)))))