Average Error: 33.5 → 9.7
Time: 29.8s
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 -6.606413508708837158603521356239899672578 \cdot 10^{-75}:\\ \;\;\;\;e^{-\left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im + y.re \cdot \log \left(\frac{-1}{x.re}\right)\right)}\\ \mathbf{elif}\;x.re \le 1.948311381039226908900887207572434452033 \cdot 10^{-246}:\\ \;\;\;\;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}\\ \mathbf{else}:\\ \;\;\;\;e^{\log x.re \cdot y.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 -6.606413508708837158603521356239899672578 \cdot 10^{-75}:\\
\;\;\;\;e^{-\left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im + y.re \cdot \log \left(\frac{-1}{x.re}\right)\right)}\\

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

\mathbf{else}:\\
\;\;\;\;e^{\log x.re \cdot y.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 r22320 = x_re;
        double r22321 = r22320 * r22320;
        double r22322 = x_im;
        double r22323 = r22322 * r22322;
        double r22324 = r22321 + r22323;
        double r22325 = sqrt(r22324);
        double r22326 = log(r22325);
        double r22327 = y_re;
        double r22328 = r22326 * r22327;
        double r22329 = atan2(r22322, r22320);
        double r22330 = y_im;
        double r22331 = r22329 * r22330;
        double r22332 = r22328 - r22331;
        double r22333 = exp(r22332);
        double r22334 = r22326 * r22330;
        double r22335 = r22329 * r22327;
        double r22336 = r22334 + r22335;
        double r22337 = cos(r22336);
        double r22338 = r22333 * r22337;
        return r22338;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r22339 = x_re;
        double r22340 = -6.606413508708837e-75;
        bool r22341 = r22339 <= r22340;
        double r22342 = x_im;
        double r22343 = atan2(r22342, r22339);
        double r22344 = y_im;
        double r22345 = r22343 * r22344;
        double r22346 = y_re;
        double r22347 = -1.0;
        double r22348 = r22347 / r22339;
        double r22349 = log(r22348);
        double r22350 = r22346 * r22349;
        double r22351 = r22345 + r22350;
        double r22352 = -r22351;
        double r22353 = exp(r22352);
        double r22354 = 1.948311381039227e-246;
        bool r22355 = r22339 <= r22354;
        double r22356 = r22339 * r22339;
        double r22357 = r22342 * r22342;
        double r22358 = r22356 + r22357;
        double r22359 = sqrt(r22358);
        double r22360 = log(r22359);
        double r22361 = r22360 * r22346;
        double r22362 = r22361 - r22345;
        double r22363 = exp(r22362);
        double r22364 = log(r22339);
        double r22365 = r22364 * r22346;
        double r22366 = r22365 - r22345;
        double r22367 = exp(r22366);
        double r22368 = r22355 ? r22363 : r22367;
        double r22369 = r22341 ? r22353 : r22368;
        return r22369;
}

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 < -6.606413508708837e-75

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

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

      \[\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 -6.606413508708837e-75 < x.re < 1.948311381039227e-246

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

    if 1.948311381039227e-246 < x.re

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

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

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

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

Reproduce

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