Average Error: 32.8 → 9.0
Time: 7.5s
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 -9.37440321357841976 \cdot 10^{-308}:\\ \;\;\;\;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 0.506585552862842348:\\ \;\;\;\;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 -9.37440321357841976 \cdot 10^{-308}:\\
\;\;\;\;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 0.506585552862842348:\\
\;\;\;\;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 r14366 = x_re;
        double r14367 = r14366 * r14366;
        double r14368 = x_im;
        double r14369 = r14368 * r14368;
        double r14370 = r14367 + r14369;
        double r14371 = sqrt(r14370);
        double r14372 = log(r14371);
        double r14373 = y_re;
        double r14374 = r14372 * r14373;
        double r14375 = atan2(r14368, r14366);
        double r14376 = y_im;
        double r14377 = r14375 * r14376;
        double r14378 = r14374 - r14377;
        double r14379 = exp(r14378);
        double r14380 = r14372 * r14376;
        double r14381 = r14375 * r14373;
        double r14382 = r14380 + r14381;
        double r14383 = cos(r14382);
        double r14384 = r14379 * r14383;
        return r14384;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r14385 = x_re;
        double r14386 = -9.37440321357842e-308;
        bool r14387 = r14385 <= r14386;
        double r14388 = x_im;
        double r14389 = atan2(r14388, r14385);
        double r14390 = y_im;
        double r14391 = r14389 * r14390;
        double r14392 = y_re;
        double r14393 = -1.0;
        double r14394 = r14393 / r14385;
        double r14395 = log(r14394);
        double r14396 = r14392 * r14395;
        double r14397 = r14391 + r14396;
        double r14398 = -r14397;
        double r14399 = exp(r14398);
        double r14400 = 1.0;
        double r14401 = r14399 * r14400;
        double r14402 = 0.5065855528628423;
        bool r14403 = r14385 <= r14402;
        double r14404 = r14385 * r14385;
        double r14405 = r14388 * r14388;
        double r14406 = r14404 + r14405;
        double r14407 = sqrt(r14406);
        double r14408 = log(r14407);
        double r14409 = r14408 * r14392;
        double r14410 = r14409 - r14391;
        double r14411 = exp(r14410);
        double r14412 = r14411 * r14400;
        double r14413 = log(r14385);
        double r14414 = r14413 * r14392;
        double r14415 = r14414 - r14391;
        double r14416 = exp(r14415);
        double r14417 = r14416 * r14400;
        double r14418 = r14403 ? r14412 : r14417;
        double r14419 = r14387 ? r14401 : r14418;
        return r14419;
}

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 < -9.37440321357842e-308

    1. Initial program 31.4

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

      \[\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 -9.37440321357842e-308 < x.re < 0.5065855528628423

    1. Initial program 24.1

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

      \[\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 0.5065855528628423 < x.re

    1. Initial program 43.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 28.1

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \le -9.37440321357841976 \cdot 10^{-308}:\\ \;\;\;\;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 0.506585552862842348:\\ \;\;\;\;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 2020062 
(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)))))