Average Error: 33.3 → 22.8
Time: 10.2s
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 -1.5068937976222738 \cdot 10^{-116}:\\ \;\;\;\;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)\\ \mathbf{elif}\;x.re \le -3.00237938327388454 \cdot 10^{-187}:\\ \;\;\;\;e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - \log \left(e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\right)} \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 -5.937031289622716 \cdot 10^{-309}:\\ \;\;\;\;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)\\ \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 -1.5068937976222738 \cdot 10^{-116}:\\
\;\;\;\;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)\\

\mathbf{elif}\;x.re \le -3.00237938327388454 \cdot 10^{-187}:\\
\;\;\;\;e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - \log \left(e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\right)} \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 -5.937031289622716 \cdot 10^{-309}:\\
\;\;\;\;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)\\

\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 r19676 = x_re;
        double r19677 = r19676 * r19676;
        double r19678 = x_im;
        double r19679 = r19678 * r19678;
        double r19680 = r19677 + r19679;
        double r19681 = sqrt(r19680);
        double r19682 = log(r19681);
        double r19683 = y_re;
        double r19684 = r19682 * r19683;
        double r19685 = atan2(r19678, r19676);
        double r19686 = y_im;
        double r19687 = r19685 * r19686;
        double r19688 = r19684 - r19687;
        double r19689 = exp(r19688);
        double r19690 = r19682 * r19686;
        double r19691 = r19685 * r19683;
        double r19692 = r19690 + r19691;
        double r19693 = sin(r19692);
        double r19694 = r19689 * r19693;
        return r19694;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r19695 = x_re;
        double r19696 = -1.5068937976222738e-116;
        bool r19697 = r19695 <= r19696;
        double r19698 = r19695 * r19695;
        double r19699 = x_im;
        double r19700 = r19699 * r19699;
        double r19701 = r19698 + r19700;
        double r19702 = sqrt(r19701);
        double r19703 = log(r19702);
        double r19704 = y_re;
        double r19705 = r19703 * r19704;
        double r19706 = atan2(r19699, r19695);
        double r19707 = y_im;
        double r19708 = r19706 * r19707;
        double r19709 = r19705 - r19708;
        double r19710 = exp(r19709);
        double r19711 = r19706 * r19704;
        double r19712 = -1.0;
        double r19713 = r19712 / r19695;
        double r19714 = log(r19713);
        double r19715 = r19707 * r19714;
        double r19716 = r19711 - r19715;
        double r19717 = sin(r19716);
        double r19718 = r19710 * r19717;
        double r19719 = -3.0023793832738845e-187;
        bool r19720 = r19695 <= r19719;
        double r19721 = exp(r19708);
        double r19722 = log(r19721);
        double r19723 = r19705 - r19722;
        double r19724 = exp(r19723);
        double r19725 = r19703 * r19707;
        double r19726 = r19725 + r19711;
        double r19727 = sin(r19726);
        double r19728 = r19724 * r19727;
        double r19729 = -5.937031289622716e-309;
        bool r19730 = r19695 <= r19729;
        double r19731 = 1.0;
        double r19732 = r19731 / r19695;
        double r19733 = log(r19732);
        double r19734 = r19707 * r19733;
        double r19735 = r19711 - r19734;
        double r19736 = sin(r19735);
        double r19737 = r19710 * r19736;
        double r19738 = r19730 ? r19718 : r19737;
        double r19739 = r19720 ? r19728 : r19738;
        double r19740 = r19697 ? r19718 : r19739;
        return r19740;
}

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 < -1.5068937976222738e-116 or -3.0023793832738845e-187 < x.re < -5.937031289622716e-309

    1. Initial program 32.3

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

      \[\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)}\]

    if -1.5068937976222738e-116 < x.re < -3.0023793832738845e-187

    1. Initial program 21.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. Using strategy rm
    3. Applied add-log-exp23.2

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

    1. Initial program 35.3

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \le -1.5068937976222738 \cdot 10^{-116}:\\ \;\;\;\;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)\\ \mathbf{elif}\;x.re \le -3.00237938327388454 \cdot 10^{-187}:\\ \;\;\;\;e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - \log \left(e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\right)} \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 -5.937031289622716 \cdot 10^{-309}:\\ \;\;\;\;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)\\ \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 2020083 
(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)))))