Average Error: 33.4 → 9.3
Time: 7.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 \cos \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 -5.65906301650669112 \cdot 10^{-103}:\\ \;\;\;\;e^{-1 \cdot \left(y.re \cdot \log \left(\frac{-1}{x.re}\right)\right) - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot 1\\ \mathbf{elif}\;x.re \le -1.6437379089044384 \cdot 10^{-170}:\\ \;\;\;\;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 1\\ \mathbf{elif}\;x.re \le 3.961302673999136 \cdot 10^{-310}:\\ \;\;\;\;e^{-1 \cdot \left(y.re \cdot \log \left(\frac{-1}{x.re}\right)\right) - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot 1\\ \mathbf{else}:\\ \;\;\;\;e^{\log x.re \cdot y.re - \log \left(e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\right)} \cdot 1\\ \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 \cos \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 -5.65906301650669112 \cdot 10^{-103}:\\
\;\;\;\;e^{-1 \cdot \left(y.re \cdot \log \left(\frac{-1}{x.re}\right)\right) - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot 1\\

\mathbf{elif}\;x.re \le -1.6437379089044384 \cdot 10^{-170}:\\
\;\;\;\;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 1\\

\mathbf{elif}\;x.re \le 3.961302673999136 \cdot 10^{-310}:\\
\;\;\;\;e^{-1 \cdot \left(y.re \cdot \log \left(\frac{-1}{x.re}\right)\right) - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot 1\\

\mathbf{else}:\\
\;\;\;\;e^{\log x.re \cdot y.re - \log \left(e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\right)} \cdot 1\\

\end{array}
double f(double x_re, double x_im, double y_re, double y_im) {
        double r12494 = x_re;
        double r12495 = r12494 * r12494;
        double r12496 = x_im;
        double r12497 = r12496 * r12496;
        double r12498 = r12495 + r12497;
        double r12499 = sqrt(r12498);
        double r12500 = log(r12499);
        double r12501 = y_re;
        double r12502 = r12500 * r12501;
        double r12503 = atan2(r12496, r12494);
        double r12504 = y_im;
        double r12505 = r12503 * r12504;
        double r12506 = r12502 - r12505;
        double r12507 = exp(r12506);
        double r12508 = r12500 * r12504;
        double r12509 = r12503 * r12501;
        double r12510 = r12508 + r12509;
        double r12511 = cos(r12510);
        double r12512 = r12507 * r12511;
        return r12512;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r12513 = x_re;
        double r12514 = -5.659063016506691e-103;
        bool r12515 = r12513 <= r12514;
        double r12516 = -1.0;
        double r12517 = y_re;
        double r12518 = r12516 / r12513;
        double r12519 = log(r12518);
        double r12520 = r12517 * r12519;
        double r12521 = r12516 * r12520;
        double r12522 = x_im;
        double r12523 = atan2(r12522, r12513);
        double r12524 = y_im;
        double r12525 = r12523 * r12524;
        double r12526 = r12521 - r12525;
        double r12527 = exp(r12526);
        double r12528 = 1.0;
        double r12529 = r12527 * r12528;
        double r12530 = -1.6437379089044384e-170;
        bool r12531 = r12513 <= r12530;
        double r12532 = r12513 * r12513;
        double r12533 = r12522 * r12522;
        double r12534 = r12532 + r12533;
        double r12535 = sqrt(r12534);
        double r12536 = log(r12535);
        double r12537 = r12536 * r12517;
        double r12538 = exp(r12525);
        double r12539 = log(r12538);
        double r12540 = r12537 - r12539;
        double r12541 = exp(r12540);
        double r12542 = r12541 * r12528;
        double r12543 = 3.96130267399914e-310;
        bool r12544 = r12513 <= r12543;
        double r12545 = log(r12513);
        double r12546 = r12545 * r12517;
        double r12547 = r12546 - r12539;
        double r12548 = exp(r12547);
        double r12549 = r12548 * r12528;
        double r12550 = r12544 ? r12529 : r12549;
        double r12551 = r12531 ? r12542 : r12550;
        double r12552 = r12515 ? r12529 : r12551;
        return r12552;
}

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 < -5.659063016506691e-103 or -1.6437379089044384e-170 < x.re < 3.96130267399914e-310

    1. Initial program 34.4

      \[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 \cos \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 0 18.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}{1}\]
    3. Taylor expanded around -inf 5.2

      \[\leadsto e^{\color{blue}{-1 \cdot \left(y.re \cdot \log \left(\frac{-1}{x.re}\right)\right)} - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot 1\]

    if -5.659063016506691e-103 < x.re < -1.6437379089044384e-170

    1. Initial program 18.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 \cos \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 0 11.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 \color{blue}{1}\]
    3. Using strategy rm
    4. Applied add-log-exp14.1

      \[\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 1\]

    if 3.96130267399914e-310 < x.re

    1. Initial program 34.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 \cos \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 0 21.5

      \[\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}{1}\]
    3. Using strategy rm
    4. Applied add-log-exp23.6

      \[\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 1\]
    5. Taylor expanded around inf 12.3

      \[\leadsto e^{\log \color{blue}{x.re} \cdot y.re - \log \left(e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\right)} \cdot 1\]
  3. Recombined 3 regimes into one program.
  4. Final simplification9.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \le -5.65906301650669112 \cdot 10^{-103}:\\ \;\;\;\;e^{-1 \cdot \left(y.re \cdot \log \left(\frac{-1}{x.re}\right)\right) - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot 1\\ \mathbf{elif}\;x.re \le -1.6437379089044384 \cdot 10^{-170}:\\ \;\;\;\;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 1\\ \mathbf{elif}\;x.re \le 3.961302673999136 \cdot 10^{-310}:\\ \;\;\;\;e^{-1 \cdot \left(y.re \cdot \log \left(\frac{-1}{x.re}\right)\right) - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot 1\\ \mathbf{else}:\\ \;\;\;\;e^{\log x.re \cdot y.re - \log \left(e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\right)} \cdot 1\\ \end{array}\]

Reproduce

herbie shell --seed 2020018 
(FPCore (x.re x.im y.re y.im)
  :name "powComplex, real part"
  :precision binary64
  (* (exp (- (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re) (* (atan2 x.im x.re) y.im))) (cos (+ (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.im) (* (atan2 x.im x.re) y.re)))))