Average Error: 33.5 → 6.1
Time: 20.7s
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 -5.0951623255484542 \cdot 10^{84}:\\ \;\;\;\;\frac{1}{e^{\mathsf{fma}\left(y.im, \tan^{-1}_* \frac{x.im}{x.re}, -\log \left(\sin \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)\right)}}\\ \mathbf{elif}\;y.re \le 5.9227529112519065 \cdot 10^{-5}:\\ \;\;\;\;\frac{1}{\frac{1}{\sin \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 \frac{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}}{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}}\\ \mathbf{elif}\;y.re \le 1.4824373474369641 \cdot 10^{158}:\\ \;\;\;\;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)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{e^{\mathsf{fma}\left(y.im, \tan^{-1}_* \frac{x.im}{x.re}, -\log \left(\sin \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)\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 -5.0951623255484542 \cdot 10^{84}:\\
\;\;\;\;\frac{1}{e^{\mathsf{fma}\left(y.im, \tan^{-1}_* \frac{x.im}{x.re}, -\log \left(\sin \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)\right)}}\\

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

\mathbf{elif}\;y.re \le 1.4824373474369641 \cdot 10^{158}:\\
\;\;\;\;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)\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{e^{\mathsf{fma}\left(y.im, \tan^{-1}_* \frac{x.im}{x.re}, -\log \left(\sin \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)\right)}}\\

\end{array}
double f(double x_re, double x_im, double y_re, double y_im) {
        double r21616 = x_re;
        double r21617 = r21616 * r21616;
        double r21618 = x_im;
        double r21619 = r21618 * r21618;
        double r21620 = r21617 + r21619;
        double r21621 = sqrt(r21620);
        double r21622 = log(r21621);
        double r21623 = y_re;
        double r21624 = r21622 * r21623;
        double r21625 = atan2(r21618, r21616);
        double r21626 = y_im;
        double r21627 = r21625 * r21626;
        double r21628 = r21624 - r21627;
        double r21629 = exp(r21628);
        double r21630 = r21622 * r21626;
        double r21631 = r21625 * r21623;
        double r21632 = r21630 + r21631;
        double r21633 = sin(r21632);
        double r21634 = r21629 * r21633;
        return r21634;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r21635 = y_re;
        double r21636 = -5.095162325548454e+84;
        bool r21637 = r21635 <= r21636;
        double r21638 = 1.0;
        double r21639 = y_im;
        double r21640 = x_im;
        double r21641 = x_re;
        double r21642 = atan2(r21640, r21641);
        double r21643 = hypot(r21641, r21640);
        double r21644 = log(r21643);
        double r21645 = r21642 * r21635;
        double r21646 = fma(r21644, r21639, r21645);
        double r21647 = sin(r21646);
        double r21648 = pow(r21643, r21635);
        double r21649 = r21647 * r21648;
        double r21650 = log(r21649);
        double r21651 = -r21650;
        double r21652 = fma(r21639, r21642, r21651);
        double r21653 = exp(r21652);
        double r21654 = r21638 / r21653;
        double r21655 = 5.9227529112519065e-05;
        bool r21656 = r21635 <= r21655;
        double r21657 = r21638 / r21647;
        double r21658 = r21642 * r21639;
        double r21659 = exp(r21658);
        double r21660 = r21659 / r21648;
        double r21661 = r21657 * r21660;
        double r21662 = r21638 / r21661;
        double r21663 = 1.482437347436964e+158;
        bool r21664 = r21635 <= r21663;
        double r21665 = r21641 * r21641;
        double r21666 = r21640 * r21640;
        double r21667 = r21665 + r21666;
        double r21668 = sqrt(r21667);
        double r21669 = log(r21668);
        double r21670 = r21669 * r21635;
        double r21671 = r21670 - r21658;
        double r21672 = exp(r21671);
        double r21673 = r21669 * r21639;
        double r21674 = r21673 + r21645;
        double r21675 = sin(r21674);
        double r21676 = r21672 * r21675;
        double r21677 = r21664 ? r21676 : r21654;
        double r21678 = r21656 ? r21662 : r21677;
        double r21679 = r21637 ? r21654 : r21678;
        return r21679;
}

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 3 regimes
  2. if y.re < -5.095162325548454e+84 or 1.482437347436964e+158 < y.re

    1. Initial program 32.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. Simplified13.1

      \[\leadsto \color{blue}{\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re} \cdot \sin \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 expm1-log1p-u13.1

      \[\leadsto \frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re} \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sin \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)}}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}}\]
    5. Using strategy rm
    6. Applied clear-num13.1

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

      \[\leadsto \frac{1}{\color{blue}{\frac{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}}{\sin \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}}}}\]
    8. Using strategy rm
    9. Applied add-exp-log13.1

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

      \[\leadsto \frac{1}{\frac{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}}{\sin \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 \color{blue}{e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re}}}}\]
    11. Applied add-exp-log38.6

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

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

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

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

    if -5.095162325548454e+84 < y.re < 5.9227529112519065e-05

    1. Initial program 34.9

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

      \[\leadsto \color{blue}{\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re} \cdot \sin \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 expm1-log1p-u5.6

      \[\leadsto \frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re} \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sin \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)}}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}}\]
    5. Using strategy rm
    6. Applied clear-num5.6

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

      \[\leadsto \frac{1}{\color{blue}{\frac{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}}{\sin \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}}}}\]
    8. Using strategy rm
    9. Applied *-un-lft-identity5.6

      \[\leadsto \frac{1}{\frac{\color{blue}{1 \cdot e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}}}{\sin \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}}}\]
    10. Applied times-frac5.6

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

    if 5.9227529112519065e-05 < y.re < 1.482437347436964e+158

    1. Initial program 23.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)\]
  3. Recombined 3 regimes into one program.
  4. Final simplification6.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.re \le -5.0951623255484542 \cdot 10^{84}:\\ \;\;\;\;\frac{1}{e^{\mathsf{fma}\left(y.im, \tan^{-1}_* \frac{x.im}{x.re}, -\log \left(\sin \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)\right)}}\\ \mathbf{elif}\;y.re \le 5.9227529112519065 \cdot 10^{-5}:\\ \;\;\;\;\frac{1}{\frac{1}{\sin \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 \frac{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}}{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}}\\ \mathbf{elif}\;y.re \le 1.4824373474369641 \cdot 10^{158}:\\ \;\;\;\;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)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{e^{\mathsf{fma}\left(y.im, \tan^{-1}_* \frac{x.im}{x.re}, -\log \left(\sin \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)\right)}}\\ \end{array}\]

Reproduce

herbie shell --seed 2020043 +o rules:numerics
(FPCore (x.re x.im y.re y.im)
  :name "powComplex, imaginary part"
  :precision binary64
  (* (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)))))