Average Error: 33.3 → 9.2
Time: 8.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 -1.970924851239729743314078565588620683968 \cdot 10^{-7}:\\ \;\;\;\;e^{\log \left(-1 \cdot x.re\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot 1\\ \mathbf{elif}\;x.re \le -9.872887954978357651344350960942713713943 \cdot 10^{-158}:\\ \;\;\;\;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 -2.245115134551110158485007312801069474368 \cdot 10^{-307}:\\ \;\;\;\;e^{\log \left(-1 \cdot x.re\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot 1\\ \mathbf{elif}\;x.re \le 2.358739548938710791532501110200331286145 \cdot 10^{-116}:\\ \;\;\;\;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 -1.970924851239729743314078565588620683968 \cdot 10^{-7}:\\
\;\;\;\;e^{\log \left(-1 \cdot x.re\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot 1\\

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

\mathbf{elif}\;x.re \le 2.358739548938710791532501110200331286145 \cdot 10^{-116}:\\
\;\;\;\;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 r16174 = x_re;
        double r16175 = r16174 * r16174;
        double r16176 = x_im;
        double r16177 = r16176 * r16176;
        double r16178 = r16175 + r16177;
        double r16179 = sqrt(r16178);
        double r16180 = log(r16179);
        double r16181 = y_re;
        double r16182 = r16180 * r16181;
        double r16183 = atan2(r16176, r16174);
        double r16184 = y_im;
        double r16185 = r16183 * r16184;
        double r16186 = r16182 - r16185;
        double r16187 = exp(r16186);
        double r16188 = r16180 * r16184;
        double r16189 = r16183 * r16181;
        double r16190 = r16188 + r16189;
        double r16191 = cos(r16190);
        double r16192 = r16187 * r16191;
        return r16192;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r16193 = x_re;
        double r16194 = -1.9709248512397297e-07;
        bool r16195 = r16193 <= r16194;
        double r16196 = -1.0;
        double r16197 = r16196 * r16193;
        double r16198 = log(r16197);
        double r16199 = y_re;
        double r16200 = r16198 * r16199;
        double r16201 = x_im;
        double r16202 = atan2(r16201, r16193);
        double r16203 = y_im;
        double r16204 = r16202 * r16203;
        double r16205 = r16200 - r16204;
        double r16206 = exp(r16205);
        double r16207 = 1.0;
        double r16208 = r16206 * r16207;
        double r16209 = -9.872887954978358e-158;
        bool r16210 = r16193 <= r16209;
        double r16211 = r16193 * r16193;
        double r16212 = r16201 * r16201;
        double r16213 = r16211 + r16212;
        double r16214 = sqrt(r16213);
        double r16215 = log(r16214);
        double r16216 = r16215 * r16199;
        double r16217 = r16216 - r16204;
        double r16218 = exp(r16217);
        double r16219 = r16218 * r16207;
        double r16220 = -2.24511513455111e-307;
        bool r16221 = r16193 <= r16220;
        double r16222 = 2.3587395489387108e-116;
        bool r16223 = r16193 <= r16222;
        double r16224 = log(r16193);
        double r16225 = r16224 * r16199;
        double r16226 = r16225 - r16204;
        double r16227 = exp(r16226);
        double r16228 = r16227 * r16207;
        double r16229 = r16223 ? r16219 : r16228;
        double r16230 = r16221 ? r16208 : r16229;
        double r16231 = r16210 ? r16219 : r16230;
        double r16232 = r16195 ? r16208 : r16231;
        return r16232;
}

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.9709248512397297e-07 or -9.872887954978358e-158 < x.re < -2.24511513455111e-307

    1. Initial program 36.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.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 4.5

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

    if -1.9709248512397297e-07 < x.re < -9.872887954978358e-158 or -2.24511513455111e-307 < x.re < 2.3587395489387108e-116

    1. Initial program 22.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 12.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}\]

    if 2.3587395489387108e-116 < x.re

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \le -1.970924851239729743314078565588620683968 \cdot 10^{-7}:\\ \;\;\;\;e^{\log \left(-1 \cdot x.re\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot 1\\ \mathbf{elif}\;x.re \le -9.872887954978357651344350960942713713943 \cdot 10^{-158}:\\ \;\;\;\;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 -2.245115134551110158485007312801069474368 \cdot 10^{-307}:\\ \;\;\;\;e^{\log \left(-1 \cdot x.re\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot 1\\ \mathbf{elif}\;x.re \le 2.358739548938710791532501110200331286145 \cdot 10^{-116}:\\ \;\;\;\;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 2019344 
(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)))))