Average Error: 33.9 → 10.1
Time: 8.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 -0.2720582922398190328650002811627928167582:\\ \;\;\;\;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 6.623197845640913221065617899561103978607 \cdot 10^{-62}:\\ \;\;\;\;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 -0.2720582922398190328650002811627928167582:\\
\;\;\;\;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 6.623197845640913221065617899561103978607 \cdot 10^{-62}:\\
\;\;\;\;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 r17462 = x_re;
        double r17463 = r17462 * r17462;
        double r17464 = x_im;
        double r17465 = r17464 * r17464;
        double r17466 = r17463 + r17465;
        double r17467 = sqrt(r17466);
        double r17468 = log(r17467);
        double r17469 = y_re;
        double r17470 = r17468 * r17469;
        double r17471 = atan2(r17464, r17462);
        double r17472 = y_im;
        double r17473 = r17471 * r17472;
        double r17474 = r17470 - r17473;
        double r17475 = exp(r17474);
        double r17476 = r17468 * r17472;
        double r17477 = r17471 * r17469;
        double r17478 = r17476 + r17477;
        double r17479 = cos(r17478);
        double r17480 = r17475 * r17479;
        return r17480;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r17481 = x_re;
        double r17482 = -0.27205829223981903;
        bool r17483 = r17481 <= r17482;
        double r17484 = x_im;
        double r17485 = atan2(r17484, r17481);
        double r17486 = y_im;
        double r17487 = r17485 * r17486;
        double r17488 = y_re;
        double r17489 = -1.0;
        double r17490 = r17489 / r17481;
        double r17491 = log(r17490);
        double r17492 = r17488 * r17491;
        double r17493 = r17487 + r17492;
        double r17494 = -r17493;
        double r17495 = exp(r17494);
        double r17496 = 1.0;
        double r17497 = r17495 * r17496;
        double r17498 = 6.623197845640913e-62;
        bool r17499 = r17481 <= r17498;
        double r17500 = r17481 * r17481;
        double r17501 = r17484 * r17484;
        double r17502 = r17500 + r17501;
        double r17503 = sqrt(r17502);
        double r17504 = log(r17503);
        double r17505 = r17504 * r17488;
        double r17506 = r17505 - r17487;
        double r17507 = exp(r17506);
        double r17508 = r17507 * r17496;
        double r17509 = log(r17481);
        double r17510 = r17509 * r17488;
        double r17511 = r17510 - r17487;
        double r17512 = exp(r17511);
        double r17513 = r17512 * r17496;
        double r17514 = r17499 ? r17508 : r17513;
        double r17515 = r17483 ? r17497 : r17514;
        return r17515;
}

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 < -0.27205829223981903

    1. Initial program 41.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 23.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 1.0

      \[\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 -0.27205829223981903 < x.re < 6.623197845640913e-62

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

    if 6.623197845640913e-62 < x.re

    1. Initial program 40.7

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

      \[\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\]
  3. Recombined 3 regimes into one program.
  4. Final simplification10.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \le -0.2720582922398190328650002811627928167582:\\ \;\;\;\;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 6.623197845640913221065617899561103978607 \cdot 10^{-62}:\\ \;\;\;\;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 2020002 
(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)))))