Average Error: 32.9 → 9.5
Time: 6.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.58261459807967753 \cdot 10^{-289}:\\ \;\;\;\;e^{-\left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im + y.re \cdot \log \left(\frac{-1}{x.re}\right)\right)} \cdot 1\\ \mathbf{elif}\;x.re \le 1.8121822807764002 \cdot 10^{-45}:\\ \;\;\;\;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 1\\ \mathbf{else}:\\ \;\;\;\;e^{\log x.re \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \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 -1.58261459807967753 \cdot 10^{-289}:\\
\;\;\;\;e^{-\left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im + y.re \cdot \log \left(\frac{-1}{x.re}\right)\right)} \cdot 1\\

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

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

\end{array}
double f(double x_re, double x_im, double y_re, double y_im) {
        double r16495 = x_re;
        double r16496 = r16495 * r16495;
        double r16497 = x_im;
        double r16498 = r16497 * r16497;
        double r16499 = r16496 + r16498;
        double r16500 = sqrt(r16499);
        double r16501 = log(r16500);
        double r16502 = y_re;
        double r16503 = r16501 * r16502;
        double r16504 = atan2(r16497, r16495);
        double r16505 = y_im;
        double r16506 = r16504 * r16505;
        double r16507 = r16503 - r16506;
        double r16508 = exp(r16507);
        double r16509 = r16501 * r16505;
        double r16510 = r16504 * r16502;
        double r16511 = r16509 + r16510;
        double r16512 = cos(r16511);
        double r16513 = r16508 * r16512;
        return r16513;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r16514 = x_re;
        double r16515 = -1.5826145980796775e-289;
        bool r16516 = r16514 <= r16515;
        double r16517 = x_im;
        double r16518 = atan2(r16517, r16514);
        double r16519 = y_im;
        double r16520 = r16518 * r16519;
        double r16521 = y_re;
        double r16522 = -1.0;
        double r16523 = r16522 / r16514;
        double r16524 = log(r16523);
        double r16525 = r16521 * r16524;
        double r16526 = r16520 + r16525;
        double r16527 = -r16526;
        double r16528 = exp(r16527);
        double r16529 = 1.0;
        double r16530 = r16528 * r16529;
        double r16531 = 1.8121822807764002e-45;
        bool r16532 = r16514 <= r16531;
        double r16533 = r16514 * r16514;
        double r16534 = r16517 * r16517;
        double r16535 = r16533 + r16534;
        double r16536 = sqrt(r16535);
        double r16537 = log(r16536);
        double r16538 = r16537 * r16521;
        double r16539 = r16538 - r16520;
        double r16540 = exp(r16539);
        double r16541 = r16540 * r16529;
        double r16542 = log(r16514);
        double r16543 = r16542 * r16521;
        double r16544 = r16543 - r16520;
        double r16545 = exp(r16544);
        double r16546 = r16545 * r16529;
        double r16547 = r16532 ? r16541 : r16546;
        double r16548 = r16516 ? r16530 : r16547;
        return r16548;
}

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.5826145980796775e-289

    1. Initial program 31.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 17.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 6.1

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

    if -1.5826145980796775e-289 < x.re < 1.8121822807764002e-45

    1. Initial program 25.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 \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 14.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}{1}\]

    if 1.8121822807764002e-45 < x.re

    1. Initial program 40.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 26.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.5

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

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

Reproduce

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