Average Error: 32.8 → 8.9
Time: 7.0s
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.982268667786879485027973206918957115638 \cdot 10^{-307}:\\ \;\;\;\;e^{\log \left(-1 \cdot x.re\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 -2.982268667786879485027973206918957115638 \cdot 10^{-307}:\\
\;\;\;\;e^{\log \left(-1 \cdot x.re\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 r12314 = x_re;
        double r12315 = r12314 * r12314;
        double r12316 = x_im;
        double r12317 = r12316 * r12316;
        double r12318 = r12315 + r12317;
        double r12319 = sqrt(r12318);
        double r12320 = log(r12319);
        double r12321 = y_re;
        double r12322 = r12320 * r12321;
        double r12323 = atan2(r12316, r12314);
        double r12324 = y_im;
        double r12325 = r12323 * r12324;
        double r12326 = r12322 - r12325;
        double r12327 = exp(r12326);
        double r12328 = r12320 * r12324;
        double r12329 = r12323 * r12321;
        double r12330 = r12328 + r12329;
        double r12331 = cos(r12330);
        double r12332 = r12327 * r12331;
        return r12332;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r12333 = x_re;
        double r12334 = -2.9822686677868795e-307;
        bool r12335 = r12333 <= r12334;
        double r12336 = -1.0;
        double r12337 = r12336 * r12333;
        double r12338 = log(r12337);
        double r12339 = y_re;
        double r12340 = r12338 * r12339;
        double r12341 = x_im;
        double r12342 = atan2(r12341, r12333);
        double r12343 = y_im;
        double r12344 = r12342 * r12343;
        double r12345 = r12340 - r12344;
        double r12346 = exp(r12345);
        double r12347 = 1.0;
        double r12348 = r12346 * r12347;
        double r12349 = log(r12333);
        double r12350 = r12349 * r12339;
        double r12351 = r12350 - r12344;
        double r12352 = exp(r12351);
        double r12353 = r12352 * r12347;
        double r12354 = r12335 ? r12348 : r12353;
        return r12354;
}

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 2 regimes
  2. if x.re < -2.9822686677868795e-307

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

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

    if -2.9822686677868795e-307 < x.re

    1. Initial program 34.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 21.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.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \le -2.982268667786879485027973206918957115638 \cdot 10^{-307}:\\ \;\;\;\;e^{\log \left(-1 \cdot x.re\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 2019352 
(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)))))