Average Error: 30.6 → 0.0
Time: 2.3m
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)\]
\[e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}} \cdot \cos \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right)\]
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)
e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}} \cdot \cos \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right)
double f(double x_re, double x_im, double y_re, double y_im) {
        double r440202 = x_re;
        double r440203 = r440202 * r440202;
        double r440204 = x_im;
        double r440205 = r440204 * r440204;
        double r440206 = r440203 + r440205;
        double r440207 = sqrt(r440206);
        double r440208 = log(r440207);
        double r440209 = y_re;
        double r440210 = r440208 * r440209;
        double r440211 = atan2(r440204, r440202);
        double r440212 = y_im;
        double r440213 = r440211 * r440212;
        double r440214 = r440210 - r440213;
        double r440215 = exp(r440214);
        double r440216 = r440208 * r440212;
        double r440217 = r440211 * r440209;
        double r440218 = r440216 + r440217;
        double r440219 = cos(r440218);
        double r440220 = r440215 * r440219;
        return r440220;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r440221 = x_re;
        double r440222 = x_im;
        double r440223 = hypot(r440221, r440222);
        double r440224 = log(r440223);
        double r440225 = y_re;
        double r440226 = r440224 * r440225;
        double r440227 = y_im;
        double r440228 = atan2(r440222, r440221);
        double r440229 = r440227 * r440228;
        double r440230 = r440226 - r440229;
        double r440231 = exp(r440230);
        double r440232 = r440225 * r440228;
        double r440233 = fma(r440227, r440224, r440232);
        double r440234 = cos(r440233);
        double r440235 = r440231 * r440234;
        return r440235;
}

Error

Bits error versus x.re

Bits error versus x.im

Bits error versus y.re

Bits error versus y.im

Derivation

  1. Initial program 30.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. Simplified0.0

    \[\leadsto \color{blue}{e^{y.re \cdot \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right)}\]
  3. Final simplification0.0

    \[\leadsto e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}} \cdot \cos \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right)\]

Reproduce

herbie shell --seed 2019138 +o rules:numerics
(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)))))