Average Error: 33.0 → 9.1
Time: 27.6s
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 -2.203136696212098368153966931412365744688 \cdot 10^{-306}:\\ \;\;\;\;e^{\log \left(-x.re\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\ \mathbf{elif}\;x.re \le 2.354070740496083302526100857388941057602 \cdot 10^{-92}:\\ \;\;\;\;e^{y.re \cdot \log x.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\ \mathbf{elif}\;x.re \le 0.03393766374877916353058893150773656088859:\\ \;\;\;\;e^{\log \left(\sqrt[3]{\sqrt{x.re \cdot x.re + x.im \cdot x.im} \cdot \left(x.re \cdot x.re + x.im \cdot x.im\right)}\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\ \mathbf{else}:\\ \;\;\;\;e^{y.re \cdot \log x.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\ \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 -2.203136696212098368153966931412365744688 \cdot 10^{-306}:\\
\;\;\;\;e^{\log \left(-x.re\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\

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

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

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

\end{array}
double f(double x_re, double x_im, double y_re, double y_im) {
        double r1837472 = x_re;
        double r1837473 = r1837472 * r1837472;
        double r1837474 = x_im;
        double r1837475 = r1837474 * r1837474;
        double r1837476 = r1837473 + r1837475;
        double r1837477 = sqrt(r1837476);
        double r1837478 = log(r1837477);
        double r1837479 = y_re;
        double r1837480 = r1837478 * r1837479;
        double r1837481 = atan2(r1837474, r1837472);
        double r1837482 = y_im;
        double r1837483 = r1837481 * r1837482;
        double r1837484 = r1837480 - r1837483;
        double r1837485 = exp(r1837484);
        double r1837486 = r1837478 * r1837482;
        double r1837487 = r1837481 * r1837479;
        double r1837488 = r1837486 + r1837487;
        double r1837489 = cos(r1837488);
        double r1837490 = r1837485 * r1837489;
        return r1837490;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r1837491 = x_re;
        double r1837492 = -2.2031366962120984e-306;
        bool r1837493 = r1837491 <= r1837492;
        double r1837494 = -r1837491;
        double r1837495 = log(r1837494);
        double r1837496 = y_re;
        double r1837497 = r1837495 * r1837496;
        double r1837498 = x_im;
        double r1837499 = atan2(r1837498, r1837491);
        double r1837500 = y_im;
        double r1837501 = r1837499 * r1837500;
        double r1837502 = r1837497 - r1837501;
        double r1837503 = exp(r1837502);
        double r1837504 = 2.3540707404960833e-92;
        bool r1837505 = r1837491 <= r1837504;
        double r1837506 = log(r1837491);
        double r1837507 = r1837496 * r1837506;
        double r1837508 = r1837507 - r1837501;
        double r1837509 = exp(r1837508);
        double r1837510 = 0.033937663748779164;
        bool r1837511 = r1837491 <= r1837510;
        double r1837512 = r1837491 * r1837491;
        double r1837513 = r1837498 * r1837498;
        double r1837514 = r1837512 + r1837513;
        double r1837515 = sqrt(r1837514);
        double r1837516 = r1837515 * r1837514;
        double r1837517 = cbrt(r1837516);
        double r1837518 = log(r1837517);
        double r1837519 = r1837518 * r1837496;
        double r1837520 = r1837519 - r1837501;
        double r1837521 = exp(r1837520);
        double r1837522 = r1837511 ? r1837521 : r1837509;
        double r1837523 = r1837505 ? r1837509 : r1837522;
        double r1837524 = r1837493 ? r1837503 : r1837523;
        return r1837524;
}

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 < -2.2031366962120984e-306

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

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

      \[\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 -2.2031366962120984e-306 < x.re < 2.3540707404960833e-92 or 0.033937663748779164 < x.re

    1. Initial program 36.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.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. Taylor expanded around inf 11.5

      \[\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\]
    4. Simplified11.5

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

    if 2.3540707404960833e-92 < x.re < 0.033937663748779164

    1. Initial program 19.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 12.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. Using strategy rm
    4. Applied add-cbrt-cube15.8

      \[\leadsto e^{\log \color{blue}{\left(\sqrt[3]{\left(\sqrt{x.re \cdot x.re + x.im \cdot x.im} \cdot \sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot \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\]
    5. Simplified15.8

      \[\leadsto e^{\log \left(\sqrt[3]{\color{blue}{\sqrt{x.re \cdot x.re + x.im \cdot x.im} \cdot \left(x.re \cdot x.re + x.im \cdot x.im\right)}}\right) \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.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \le -2.203136696212098368153966931412365744688 \cdot 10^{-306}:\\ \;\;\;\;e^{\log \left(-x.re\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\ \mathbf{elif}\;x.re \le 2.354070740496083302526100857388941057602 \cdot 10^{-92}:\\ \;\;\;\;e^{y.re \cdot \log x.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\ \mathbf{elif}\;x.re \le 0.03393766374877916353058893150773656088859:\\ \;\;\;\;e^{\log \left(\sqrt[3]{\sqrt{x.re \cdot x.re + x.im \cdot x.im} \cdot \left(x.re \cdot x.re + x.im \cdot x.im\right)}\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\ \mathbf{else}:\\ \;\;\;\;e^{y.re \cdot \log x.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\ \end{array}\]

Reproduce

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