Average Error: 33.2 → 9.4
Time: 7.9s
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.317264652803917357459795312024652957916:\\ \;\;\;\;\log \left(e^{e^{-\left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im + y.re \cdot \log \left(\frac{-1}{x.re}\right)\right)}}\right) \cdot 1\\ \mathbf{elif}\;x.re \le -5.407292395185870576518829329849128120183 \cdot 10^{-32}:\\ \;\;\;\;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{elif}\;x.re \le 2.121389030377318108749243206443548417302 \cdot 10^{-310}:\\ \;\;\;\;\log \left(e^{e^{-\left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im + y.re \cdot \log \left(\frac{-1}{x.re}\right)\right)}}\right) \cdot 1\\ \mathbf{elif}\;x.re \le 5.510625452562474342443935677819191805731 \cdot 10^{-126}:\\ \;\;\;\;e^{\log x.re \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot 1\\ \mathbf{elif}\;x.re \le 4.421989942484376912656930468871073106272 \cdot 10^{-92}:\\ \;\;\;\;e^{\log x.im \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.317264652803917357459795312024652957916:\\
\;\;\;\;\log \left(e^{e^{-\left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im + y.re \cdot \log \left(\frac{-1}{x.re}\right)\right)}}\right) \cdot 1\\

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

\mathbf{elif}\;x.re \le 5.510625452562474342443935677819191805731 \cdot 10^{-126}:\\
\;\;\;\;e^{\log x.re \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot 1\\

\mathbf{elif}\;x.re \le 4.421989942484376912656930468871073106272 \cdot 10^{-92}:\\
\;\;\;\;e^{\log x.im \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 r15479 = x_re;
        double r15480 = r15479 * r15479;
        double r15481 = x_im;
        double r15482 = r15481 * r15481;
        double r15483 = r15480 + r15482;
        double r15484 = sqrt(r15483);
        double r15485 = log(r15484);
        double r15486 = y_re;
        double r15487 = r15485 * r15486;
        double r15488 = atan2(r15481, r15479);
        double r15489 = y_im;
        double r15490 = r15488 * r15489;
        double r15491 = r15487 - r15490;
        double r15492 = exp(r15491);
        double r15493 = r15485 * r15489;
        double r15494 = r15488 * r15486;
        double r15495 = r15493 + r15494;
        double r15496 = cos(r15495);
        double r15497 = r15492 * r15496;
        return r15497;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r15498 = x_re;
        double r15499 = -1.3172646528039174;
        bool r15500 = r15498 <= r15499;
        double r15501 = x_im;
        double r15502 = atan2(r15501, r15498);
        double r15503 = y_im;
        double r15504 = r15502 * r15503;
        double r15505 = y_re;
        double r15506 = -1.0;
        double r15507 = r15506 / r15498;
        double r15508 = log(r15507);
        double r15509 = r15505 * r15508;
        double r15510 = r15504 + r15509;
        double r15511 = -r15510;
        double r15512 = exp(r15511);
        double r15513 = exp(r15512);
        double r15514 = log(r15513);
        double r15515 = 1.0;
        double r15516 = r15514 * r15515;
        double r15517 = -5.407292395185871e-32;
        bool r15518 = r15498 <= r15517;
        double r15519 = r15498 * r15498;
        double r15520 = r15501 * r15501;
        double r15521 = r15519 + r15520;
        double r15522 = sqrt(r15521);
        double r15523 = log(r15522);
        double r15524 = r15523 * r15505;
        double r15525 = r15524 - r15504;
        double r15526 = exp(r15525);
        double r15527 = r15526 * r15515;
        double r15528 = 2.1213890303773e-310;
        bool r15529 = r15498 <= r15528;
        double r15530 = 5.5106254525624743e-126;
        bool r15531 = r15498 <= r15530;
        double r15532 = log(r15498);
        double r15533 = r15532 * r15505;
        double r15534 = r15533 - r15504;
        double r15535 = exp(r15534);
        double r15536 = r15535 * r15515;
        double r15537 = 4.421989942484377e-92;
        bool r15538 = r15498 <= r15537;
        double r15539 = log(r15501);
        double r15540 = r15539 * r15505;
        double r15541 = r15540 - r15504;
        double r15542 = exp(r15541);
        double r15543 = r15542 * r15515;
        double r15544 = r15538 ? r15543 : r15536;
        double r15545 = r15531 ? r15536 : r15544;
        double r15546 = r15529 ? r15516 : r15545;
        double r15547 = r15518 ? r15527 : r15546;
        double r15548 = r15500 ? r15516 : r15547;
        return r15548;
}

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 4 regimes
  2. if x.re < -1.3172646528039174 or -5.407292395185871e-32 < x.re < 2.1213890303773e-310

    1. Initial program 32.5

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

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

      \[\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\]
    4. Using strategy rm
    5. Applied add-log-exp5.7

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

    if -1.3172646528039174 < x.re < -5.407292395185871e-32

    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 9.6

      \[\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 2.1213890303773e-310 < x.re < 5.5106254525624743e-126 or 4.421989942484377e-92 < x.re

    1. Initial program 35.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 22.7

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

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

    if 5.5106254525624743e-126 < x.re < 4.421989942484377e-92

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

      \[\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 0 31.6

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \le -1.317264652803917357459795312024652957916:\\ \;\;\;\;\log \left(e^{e^{-\left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im + y.re \cdot \log \left(\frac{-1}{x.re}\right)\right)}}\right) \cdot 1\\ \mathbf{elif}\;x.re \le -5.407292395185870576518829329849128120183 \cdot 10^{-32}:\\ \;\;\;\;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{elif}\;x.re \le 2.121389030377318108749243206443548417302 \cdot 10^{-310}:\\ \;\;\;\;\log \left(e^{e^{-\left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im + y.re \cdot \log \left(\frac{-1}{x.re}\right)\right)}}\right) \cdot 1\\ \mathbf{elif}\;x.re \le 5.510625452562474342443935677819191805731 \cdot 10^{-126}:\\ \;\;\;\;e^{\log x.re \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot 1\\ \mathbf{elif}\;x.re \le 4.421989942484376912656930468871073106272 \cdot 10^{-92}:\\ \;\;\;\;e^{\log x.im \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 2019362 
(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)))))