Average Error: 32.9 → 22.3
Time: 9.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}\;x.re \le -7.165681593660874237736352368699222560575 \cdot 10^{-209}:\\ \;\;\;\;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(-1 \cdot x.re\right) \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\\ \mathbf{elif}\;x.re \le -3.310592978427304830770646608682828536675 \cdot 10^{-228}:\\ \;\;\;\;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{elif}\;x.re \le 4.737846798663201494320426487179313346304 \cdot 10^{-310}:\\ \;\;\;\;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(-1 \cdot x.re\right) \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\\ \mathbf{else}:\\ \;\;\;\;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(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.re - y.im \cdot \log \left(\frac{1}{x.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}\;x.re \le -7.165681593660874237736352368699222560575 \cdot 10^{-209}:\\
\;\;\;\;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(-1 \cdot x.re\right) \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\\

\mathbf{elif}\;x.re \le -3.310592978427304830770646608682828536675 \cdot 10^{-228}:\\
\;\;\;\;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{elif}\;x.re \le 4.737846798663201494320426487179313346304 \cdot 10^{-310}:\\
\;\;\;\;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(-1 \cdot x.re\right) \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\\

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

\end{array}
double f(double x_re, double x_im, double y_re, double y_im) {
        double r21691 = x_re;
        double r21692 = r21691 * r21691;
        double r21693 = x_im;
        double r21694 = r21693 * r21693;
        double r21695 = r21692 + r21694;
        double r21696 = sqrt(r21695);
        double r21697 = log(r21696);
        double r21698 = y_re;
        double r21699 = r21697 * r21698;
        double r21700 = atan2(r21693, r21691);
        double r21701 = y_im;
        double r21702 = r21700 * r21701;
        double r21703 = r21699 - r21702;
        double r21704 = exp(r21703);
        double r21705 = r21697 * r21701;
        double r21706 = r21700 * r21698;
        double r21707 = r21705 + r21706;
        double r21708 = sin(r21707);
        double r21709 = r21704 * r21708;
        return r21709;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r21710 = x_re;
        double r21711 = -7.165681593660874e-209;
        bool r21712 = r21710 <= r21711;
        double r21713 = r21710 * r21710;
        double r21714 = x_im;
        double r21715 = r21714 * r21714;
        double r21716 = r21713 + r21715;
        double r21717 = sqrt(r21716);
        double r21718 = log(r21717);
        double r21719 = y_re;
        double r21720 = r21718 * r21719;
        double r21721 = atan2(r21714, r21710);
        double r21722 = y_im;
        double r21723 = r21721 * r21722;
        double r21724 = r21720 - r21723;
        double r21725 = exp(r21724);
        double r21726 = -1.0;
        double r21727 = r21726 * r21710;
        double r21728 = log(r21727);
        double r21729 = r21728 * r21722;
        double r21730 = r21721 * r21719;
        double r21731 = r21729 + r21730;
        double r21732 = sin(r21731);
        double r21733 = r21725 * r21732;
        double r21734 = -3.310592978427305e-228;
        bool r21735 = r21710 <= r21734;
        double r21736 = r21718 * r21722;
        double r21737 = r21736 + r21730;
        double r21738 = sin(r21737);
        double r21739 = r21725 * r21738;
        double r21740 = 4.7378467986632e-310;
        bool r21741 = r21710 <= r21740;
        double r21742 = 1.0;
        double r21743 = r21742 / r21710;
        double r21744 = log(r21743);
        double r21745 = r21722 * r21744;
        double r21746 = r21730 - r21745;
        double r21747 = sin(r21746);
        double r21748 = r21725 * r21747;
        double r21749 = r21741 ? r21733 : r21748;
        double r21750 = r21735 ? r21739 : r21749;
        double r21751 = r21712 ? r21733 : r21750;
        return r21751;
}

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 < -7.165681593660874e-209 or -3.310592978427305e-228 < x.re < 4.7378467986632e-310

    1. Initial program 31.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)\]
    2. Taylor expanded around -inf 20.1

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

    if -7.165681593660874e-209 < x.re < -3.310592978427305e-228

    1. Initial program 30.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 \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 4.7378467986632e-310 < x.re

    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 \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. Taylor expanded around inf 24.0

      \[\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}{\sin \left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.re - y.im \cdot \log \left(\frac{1}{x.re}\right)\right)}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification22.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \le -7.165681593660874237736352368699222560575 \cdot 10^{-209}:\\ \;\;\;\;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(-1 \cdot x.re\right) \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\\ \mathbf{elif}\;x.re \le -3.310592978427304830770646608682828536675 \cdot 10^{-228}:\\ \;\;\;\;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{elif}\;x.re \le 4.737846798663201494320426487179313346304 \cdot 10^{-310}:\\ \;\;\;\;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(-1 \cdot x.re\right) \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\\ \mathbf{else}:\\ \;\;\;\;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(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.re - y.im \cdot \log \left(\frac{1}{x.re}\right)\right)\\ \end{array}\]

Reproduce

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