Average Error: 32.7 → 9.3
Time: 31.6s
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 -2759744.9040251518599689006805419921875:\\ \;\;\;\;e^{\log \left(-x.re\right) \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\ \mathbf{elif}\;x.re \le -5.32610268211259449984213034556843154695 \cdot 10^{-30}:\\ \;\;\;\;e^{\log \left(\log \left(e^{\sqrt{x.re \cdot x.re + x.im \cdot x.im}}\right)\right) \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\ \mathbf{elif}\;x.re \le -4.399901143579185647092718121671803160377 \cdot 10^{-310}:\\ \;\;\;\;e^{\log \left(-x.re\right) \cdot y.re - 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 -2759744.9040251518599689006805419921875:\\
\;\;\;\;e^{\log \left(-x.re\right) \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\

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

\mathbf{elif}\;x.re \le -4.399901143579185647092718121671803160377 \cdot 10^{-310}:\\
\;\;\;\;e^{\log \left(-x.re\right) \cdot y.re - 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 r1396158 = x_re;
        double r1396159 = r1396158 * r1396158;
        double r1396160 = x_im;
        double r1396161 = r1396160 * r1396160;
        double r1396162 = r1396159 + r1396161;
        double r1396163 = sqrt(r1396162);
        double r1396164 = log(r1396163);
        double r1396165 = y_re;
        double r1396166 = r1396164 * r1396165;
        double r1396167 = atan2(r1396160, r1396158);
        double r1396168 = y_im;
        double r1396169 = r1396167 * r1396168;
        double r1396170 = r1396166 - r1396169;
        double r1396171 = exp(r1396170);
        double r1396172 = r1396164 * r1396168;
        double r1396173 = r1396167 * r1396165;
        double r1396174 = r1396172 + r1396173;
        double r1396175 = cos(r1396174);
        double r1396176 = r1396171 * r1396175;
        return r1396176;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r1396177 = x_re;
        double r1396178 = -2759744.904025152;
        bool r1396179 = r1396177 <= r1396178;
        double r1396180 = -r1396177;
        double r1396181 = log(r1396180);
        double r1396182 = y_re;
        double r1396183 = r1396181 * r1396182;
        double r1396184 = y_im;
        double r1396185 = x_im;
        double r1396186 = atan2(r1396185, r1396177);
        double r1396187 = r1396184 * r1396186;
        double r1396188 = r1396183 - r1396187;
        double r1396189 = exp(r1396188);
        double r1396190 = -5.3261026821125945e-30;
        bool r1396191 = r1396177 <= r1396190;
        double r1396192 = r1396177 * r1396177;
        double r1396193 = r1396185 * r1396185;
        double r1396194 = r1396192 + r1396193;
        double r1396195 = sqrt(r1396194);
        double r1396196 = exp(r1396195);
        double r1396197 = log(r1396196);
        double r1396198 = log(r1396197);
        double r1396199 = r1396198 * r1396182;
        double r1396200 = r1396199 - r1396187;
        double r1396201 = exp(r1396200);
        double r1396202 = -4.3999011435792e-310;
        bool r1396203 = r1396177 <= r1396202;
        double r1396204 = log(r1396177);
        double r1396205 = r1396182 * r1396204;
        double r1396206 = r1396205 - r1396187;
        double r1396207 = exp(r1396206);
        double r1396208 = r1396203 ? r1396189 : r1396207;
        double r1396209 = r1396191 ? r1396201 : r1396208;
        double r1396210 = r1396179 ? r1396189 : r1396209;
        return r1396210;
}

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 < -2759744.904025152 or -5.3261026821125945e-30 < x.re < -4.3999011435792e-310

    1. Initial program 32.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 18.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 6.4

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

      \[\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 -2759744.904025152 < x.re < -5.3261026821125945e-30

    1. Initial program 12.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 6.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}\]
    3. Using strategy rm
    4. Applied add-log-exp20.8

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

    if -4.3999011435792e-310 < x.re

    1. Initial program 33.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 20.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}\]
    3. Taylor expanded around inf 11.4

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \le -2759744.9040251518599689006805419921875:\\ \;\;\;\;e^{\log \left(-x.re\right) \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\ \mathbf{elif}\;x.re \le -5.32610268211259449984213034556843154695 \cdot 10^{-30}:\\ \;\;\;\;e^{\log \left(\log \left(e^{\sqrt{x.re \cdot x.re + x.im \cdot x.im}}\right)\right) \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\ \mathbf{elif}\;x.re \le -4.399901143579185647092718121671803160377 \cdot 10^{-310}:\\ \;\;\;\;e^{\log \left(-x.re\right) \cdot y.re - 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 2019172 
(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)))))