Average Error: 32.9 → 8.6
Time: 31.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 -1.8407009899098441 \cdot 10^{-06}:\\ \;\;\;\;e^{\log \left(-x.re\right) \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\ \mathbf{elif}\;x.re \le -2.9130712528480477 \cdot 10^{-164}:\\ \;\;\;\;e^{y.re \cdot \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\ \mathbf{elif}\;x.re \le -4.2640896224449 \cdot 10^{-310}:\\ \;\;\;\;e^{\log \left(-x.re\right) \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\ \mathbf{else}:\\ \;\;\;\;e^{y.re \cdot \log x.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\ \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 -1.8407009899098441 \cdot 10^{-06}:\\
\;\;\;\;e^{\log \left(-x.re\right) \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\

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

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

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

\end{array}
double f(double x_re, double x_im, double y_re, double y_im) {
        double r1436481 = x_re;
        double r1436482 = r1436481 * r1436481;
        double r1436483 = x_im;
        double r1436484 = r1436483 * r1436483;
        double r1436485 = r1436482 + r1436484;
        double r1436486 = sqrt(r1436485);
        double r1436487 = log(r1436486);
        double r1436488 = y_re;
        double r1436489 = r1436487 * r1436488;
        double r1436490 = atan2(r1436483, r1436481);
        double r1436491 = y_im;
        double r1436492 = r1436490 * r1436491;
        double r1436493 = r1436489 - r1436492;
        double r1436494 = exp(r1436493);
        double r1436495 = r1436487 * r1436491;
        double r1436496 = r1436490 * r1436488;
        double r1436497 = r1436495 + r1436496;
        double r1436498 = cos(r1436497);
        double r1436499 = r1436494 * r1436498;
        return r1436499;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r1436500 = x_re;
        double r1436501 = -1.8407009899098441e-06;
        bool r1436502 = r1436500 <= r1436501;
        double r1436503 = -r1436500;
        double r1436504 = log(r1436503);
        double r1436505 = y_re;
        double r1436506 = r1436504 * r1436505;
        double r1436507 = y_im;
        double r1436508 = x_im;
        double r1436509 = atan2(r1436508, r1436500);
        double r1436510 = r1436507 * r1436509;
        double r1436511 = r1436506 - r1436510;
        double r1436512 = exp(r1436511);
        double r1436513 = -2.9130712528480477e-164;
        bool r1436514 = r1436500 <= r1436513;
        double r1436515 = r1436500 * r1436500;
        double r1436516 = r1436508 * r1436508;
        double r1436517 = r1436515 + r1436516;
        double r1436518 = sqrt(r1436517);
        double r1436519 = log(r1436518);
        double r1436520 = r1436505 * r1436519;
        double r1436521 = r1436520 - r1436510;
        double r1436522 = exp(r1436521);
        double r1436523 = -4.2640896224449e-310;
        bool r1436524 = r1436500 <= r1436523;
        double r1436525 = log(r1436500);
        double r1436526 = r1436505 * r1436525;
        double r1436527 = r1436526 - r1436510;
        double r1436528 = exp(r1436527);
        double r1436529 = r1436524 ? r1436512 : r1436528;
        double r1436530 = r1436514 ? r1436522 : r1436529;
        double r1436531 = r1436502 ? r1436512 : r1436530;
        return r1436531;
}

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.8407009899098441e-06 or -2.9130712528480477e-164 < x.re < -4.2640896224449e-310

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

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

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

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

    if -1.8407009899098441e-06 < x.re < -2.9130712528480477e-164

    1. Initial program 15.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 \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 8.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}\]

    if -4.2640896224449e-310 < x.re

    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 \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 22.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 11.9

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \le -1.8407009899098441 \cdot 10^{-06}:\\ \;\;\;\;e^{\log \left(-x.re\right) \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\ \mathbf{elif}\;x.re \le -2.9130712528480477 \cdot 10^{-164}:\\ \;\;\;\;e^{y.re \cdot \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\ \mathbf{elif}\;x.re \le -4.2640896224449 \cdot 10^{-310}:\\ \;\;\;\;e^{\log \left(-x.re\right) \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\ \mathbf{else}:\\ \;\;\;\;e^{y.re \cdot \log x.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\ \end{array}\]

Reproduce

herbie shell --seed 2019163 
(FPCore (x.re x.im y.re y.im)
  :name "powComplex, real part"
  (* (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)))))