Average Error: 32.8 → 9.2
Time: 25.4s
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 -7.244640314977398 \cdot 10^{-31}:\\ \;\;\;\;e^{\log \left(-x.re\right) \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\ \mathbf{elif}\;x.re \le 4.682817159271393 \cdot 10^{-308}:\\ \;\;\;\;e^{y.re \cdot \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\ \mathbf{elif}\;x.re \le 1.3125844742081705 \cdot 10^{-162}:\\ \;\;\;\;e^{y.re \cdot \log x.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\ \mathbf{elif}\;x.re \le 7.413330575436596 \cdot 10^{-62}:\\ \;\;\;\;\cos \left(\log x.re \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) \cdot e^{y.re \cdot \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\ \mathbf{else}:\\ \;\;\;\;e^{y.re \cdot \log x.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\ \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 -7.244640314977398 \cdot 10^{-31}:\\
\;\;\;\;e^{\log \left(-x.re\right) \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\

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

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

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

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

\end{array}
double f(double x_re, double x_im, double y_re, double y_im) {
        double r592178 = x_re;
        double r592179 = r592178 * r592178;
        double r592180 = x_im;
        double r592181 = r592180 * r592180;
        double r592182 = r592179 + r592181;
        double r592183 = sqrt(r592182);
        double r592184 = log(r592183);
        double r592185 = y_re;
        double r592186 = r592184 * r592185;
        double r592187 = atan2(r592180, r592178);
        double r592188 = y_im;
        double r592189 = r592187 * r592188;
        double r592190 = r592186 - r592189;
        double r592191 = exp(r592190);
        double r592192 = r592184 * r592188;
        double r592193 = r592187 * r592185;
        double r592194 = r592192 + r592193;
        double r592195 = cos(r592194);
        double r592196 = r592191 * r592195;
        return r592196;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r592197 = x_re;
        double r592198 = -7.244640314977398e-31;
        bool r592199 = r592197 <= r592198;
        double r592200 = -r592197;
        double r592201 = log(r592200);
        double r592202 = y_re;
        double r592203 = r592201 * r592202;
        double r592204 = y_im;
        double r592205 = x_im;
        double r592206 = atan2(r592205, r592197);
        double r592207 = r592204 * r592206;
        double r592208 = r592203 - r592207;
        double r592209 = exp(r592208);
        double r592210 = 4.682817159271393e-308;
        bool r592211 = r592197 <= r592210;
        double r592212 = r592197 * r592197;
        double r592213 = r592205 * r592205;
        double r592214 = r592212 + r592213;
        double r592215 = sqrt(r592214);
        double r592216 = log(r592215);
        double r592217 = r592202 * r592216;
        double r592218 = r592217 - r592207;
        double r592219 = exp(r592218);
        double r592220 = 1.3125844742081705e-162;
        bool r592221 = r592197 <= r592220;
        double r592222 = log(r592197);
        double r592223 = r592202 * r592222;
        double r592224 = r592223 - r592207;
        double r592225 = exp(r592224);
        double r592226 = 7.413330575436596e-62;
        bool r592227 = r592197 <= r592226;
        double r592228 = r592222 * r592204;
        double r592229 = r592206 * r592202;
        double r592230 = r592228 + r592229;
        double r592231 = cos(r592230);
        double r592232 = r592231 * r592219;
        double r592233 = r592227 ? r592232 : r592225;
        double r592234 = r592221 ? r592225 : r592233;
        double r592235 = r592211 ? r592219 : r592234;
        double r592236 = r592199 ? r592209 : r592235;
        return r592236;
}

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 4 regimes
  2. if x.re < -7.244640314977398e-31

    1. Initial program 37.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 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 1.8

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

      \[\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 -7.244640314977398e-31 < x.re < 4.682817159271393e-308

    1. Initial program 23.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 13.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}\]

    if 4.682817159271393e-308 < x.re < 1.3125844742081705e-162 or 7.413330575436596e-62 < x.re

    1. Initial program 37.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 24.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}\]
    3. Taylor expanded around inf 10.8

      \[\leadsto \color{blue}{e^{-\left(y.im \cdot \tan^{-1}_* \frac{x.im}{x.re} + y.re \cdot \log \left(\frac{1}{x.re}\right)\right)}} \cdot 1\]
    4. Simplified10.8

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

    if 1.3125844742081705e-162 < x.re < 7.413330575436596e-62

    1. Initial program 18.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 inf 11.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 \cos \left(\log \color{blue}{x.re} \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\]
  3. Recombined 4 regimes into one program.
  4. Final simplification9.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \le -7.244640314977398 \cdot 10^{-31}:\\ \;\;\;\;e^{\log \left(-x.re\right) \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\ \mathbf{elif}\;x.re \le 4.682817159271393 \cdot 10^{-308}:\\ \;\;\;\;e^{y.re \cdot \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\ \mathbf{elif}\;x.re \le 1.3125844742081705 \cdot 10^{-162}:\\ \;\;\;\;e^{y.re \cdot \log x.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\ \mathbf{elif}\;x.re \le 7.413330575436596 \cdot 10^{-62}:\\ \;\;\;\;\cos \left(\log x.re \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) \cdot e^{y.re \cdot \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\ \mathbf{else}:\\ \;\;\;\;e^{y.re \cdot \log x.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\ \end{array}\]

Reproduce

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