Average Error: 32.8 → 10.3
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 -1.0320343030662579 \cdot 10^{-39}:\\ \;\;\;\;e^{-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\\ \mathbf{elif}\;x.re \le -7.0065628327462943 \cdot 10^{-138}:\\ \;\;\;\;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 -1.596491671996702 \cdot 10^{-172}:\\ \;\;\;\;e^{-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\\ \mathbf{elif}\;x.re \le -6.9045443592551714 \cdot 10^{-255}:\\ \;\;\;\;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 -3.10085515308595001 \cdot 10^{-308}:\\ \;\;\;\;e^{-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\\ \mathbf{elif}\;x.re \le 2.99263778611433918 \cdot 10^{-130}:\\ \;\;\;\;\frac{e^{-\log \left(e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\right)}}{{\left(\frac{1}{x.re}\right)}^{y.re}} \cdot 1\\ \mathbf{elif}\;x.re \le 2.45124835309062439:\\ \;\;\;\;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}:\\ \;\;\;\;\frac{e^{-\log \left(e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\right)}}{{\left(\frac{1}{x.re}\right)}^{y.re}} \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.0320343030662579 \cdot 10^{-39}:\\
\;\;\;\;e^{-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\\

\mathbf{elif}\;x.re \le -7.0065628327462943 \cdot 10^{-138}:\\
\;\;\;\;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 -1.596491671996702 \cdot 10^{-172}:\\
\;\;\;\;e^{-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\\

\mathbf{elif}\;x.re \le -6.9045443592551714 \cdot 10^{-255}:\\
\;\;\;\;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 -3.10085515308595001 \cdot 10^{-308}:\\
\;\;\;\;e^{-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\\

\mathbf{elif}\;x.re \le 2.99263778611433918 \cdot 10^{-130}:\\
\;\;\;\;\frac{e^{-\log \left(e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\right)}}{{\left(\frac{1}{x.re}\right)}^{y.re}} \cdot 1\\

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

\end{array}
double f(double x_re, double x_im, double y_re, double y_im) {
        double r11286 = x_re;
        double r11287 = r11286 * r11286;
        double r11288 = x_im;
        double r11289 = r11288 * r11288;
        double r11290 = r11287 + r11289;
        double r11291 = sqrt(r11290);
        double r11292 = log(r11291);
        double r11293 = y_re;
        double r11294 = r11292 * r11293;
        double r11295 = atan2(r11288, r11286);
        double r11296 = y_im;
        double r11297 = r11295 * r11296;
        double r11298 = r11294 - r11297;
        double r11299 = exp(r11298);
        double r11300 = r11292 * r11296;
        double r11301 = r11295 * r11293;
        double r11302 = r11300 + r11301;
        double r11303 = cos(r11302);
        double r11304 = r11299 * r11303;
        return r11304;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r11305 = x_re;
        double r11306 = -1.0320343030662579e-39;
        bool r11307 = r11305 <= r11306;
        double r11308 = -1.0;
        double r11309 = y_re;
        double r11310 = r11308 / r11305;
        double r11311 = log(r11310);
        double r11312 = r11309 * r11311;
        double r11313 = r11308 * r11312;
        double r11314 = x_im;
        double r11315 = atan2(r11314, r11305);
        double r11316 = y_im;
        double r11317 = r11315 * r11316;
        double r11318 = r11313 - r11317;
        double r11319 = exp(r11318);
        double r11320 = 1.0;
        double r11321 = r11319 * r11320;
        double r11322 = -7.006562832746294e-138;
        bool r11323 = r11305 <= r11322;
        double r11324 = r11305 * r11305;
        double r11325 = r11314 * r11314;
        double r11326 = r11324 + r11325;
        double r11327 = sqrt(r11326);
        double r11328 = log(r11327);
        double r11329 = r11328 * r11309;
        double r11330 = r11329 - r11317;
        double r11331 = exp(r11330);
        double r11332 = r11331 * r11320;
        double r11333 = -1.5964916719967018e-172;
        bool r11334 = r11305 <= r11333;
        double r11335 = -6.904544359255171e-255;
        bool r11336 = r11305 <= r11335;
        double r11337 = -3.10085515308595e-308;
        bool r11338 = r11305 <= r11337;
        double r11339 = 2.992637786114339e-130;
        bool r11340 = r11305 <= r11339;
        double r11341 = exp(r11317);
        double r11342 = log(r11341);
        double r11343 = -r11342;
        double r11344 = exp(r11343);
        double r11345 = r11320 / r11305;
        double r11346 = pow(r11345, r11309);
        double r11347 = r11344 / r11346;
        double r11348 = r11347 * r11320;
        double r11349 = 2.4512483530906244;
        bool r11350 = r11305 <= r11349;
        double r11351 = r11350 ? r11332 : r11348;
        double r11352 = r11340 ? r11348 : r11351;
        double r11353 = r11338 ? r11321 : r11352;
        double r11354 = r11336 ? r11332 : r11353;
        double r11355 = r11334 ? r11321 : r11354;
        double r11356 = r11323 ? r11332 : r11355;
        double r11357 = r11307 ? r11321 : r11356;
        return r11357;
}

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 < -1.0320343030662579e-39 or -7.006562832746294e-138 < x.re < -1.5964916719967018e-172 or -6.904544359255171e-255 < x.re < -3.10085515308595e-308

    1. Initial program 34.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 19.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 3.8

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

    if -1.0320343030662579e-39 < x.re < -7.006562832746294e-138 or -1.5964916719967018e-172 < x.re < -6.904544359255171e-255 or 2.992637786114339e-130 < x.re < 2.4512483530906244

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

    if -3.10085515308595e-308 < x.re < 2.992637786114339e-130 or 2.4512483530906244 < x.re

    1. Initial program 38.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 24.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 11.5

      \[\leadsto \color{blue}{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\]
    4. Simplified14.9

      \[\leadsto \color{blue}{\frac{e^{-\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}}{{\left(\frac{1}{x.re}\right)}^{y.re}}} \cdot 1\]
    5. Using strategy rm
    6. Applied add-log-exp14.9

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \le -1.0320343030662579 \cdot 10^{-39}:\\ \;\;\;\;e^{-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\\ \mathbf{elif}\;x.re \le -7.0065628327462943 \cdot 10^{-138}:\\ \;\;\;\;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 -1.596491671996702 \cdot 10^{-172}:\\ \;\;\;\;e^{-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\\ \mathbf{elif}\;x.re \le -6.9045443592551714 \cdot 10^{-255}:\\ \;\;\;\;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 -3.10085515308595001 \cdot 10^{-308}:\\ \;\;\;\;e^{-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\\ \mathbf{elif}\;x.re \le 2.99263778611433918 \cdot 10^{-130}:\\ \;\;\;\;\frac{e^{-\log \left(e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\right)}}{{\left(\frac{1}{x.re}\right)}^{y.re}} \cdot 1\\ \mathbf{elif}\;x.re \le 2.45124835309062439:\\ \;\;\;\;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}:\\ \;\;\;\;\frac{e^{-\log \left(e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\right)}}{{\left(\frac{1}{x.re}\right)}^{y.re}} \cdot 1\\ \end{array}\]

Reproduce

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