Average Error: 31.2 → 0.1
Time: 2.2m
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)\]
\[\frac{\cos \left(\mathsf{fma}\left(y.im, \left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\right), \left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right)\right)}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im - y.re \cdot \log \left(\mathsf{hypot}\left(x.re, x.im\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)
\frac{\cos \left(\mathsf{fma}\left(y.im, \left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\right), \left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right)\right)}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im - y.re \cdot \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)}}
double f(double x_re, double x_im, double y_re, double y_im) {
        double r192461 = x_re;
        double r192462 = r192461 * r192461;
        double r192463 = x_im;
        double r192464 = r192463 * r192463;
        double r192465 = r192462 + r192464;
        double r192466 = sqrt(r192465);
        double r192467 = log(r192466);
        double r192468 = y_re;
        double r192469 = r192467 * r192468;
        double r192470 = atan2(r192463, r192461);
        double r192471 = y_im;
        double r192472 = r192470 * r192471;
        double r192473 = r192469 - r192472;
        double r192474 = exp(r192473);
        double r192475 = r192467 * r192471;
        double r192476 = r192470 * r192468;
        double r192477 = r192475 + r192476;
        double r192478 = cos(r192477);
        double r192479 = r192474 * r192478;
        return r192479;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r192480 = y_im;
        double r192481 = x_re;
        double r192482 = x_im;
        double r192483 = hypot(r192481, r192482);
        double r192484 = log(r192483);
        double r192485 = atan2(r192482, r192481);
        double r192486 = y_re;
        double r192487 = r192485 * r192486;
        double r192488 = fma(r192480, r192484, r192487);
        double r192489 = cos(r192488);
        double r192490 = r192485 * r192480;
        double r192491 = r192486 * r192484;
        double r192492 = r192490 - r192491;
        double r192493 = exp(r192492);
        double r192494 = r192489 / r192493;
        return r192494;
}

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 31.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. Simplified0.1

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

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

Reproduce

herbie shell --seed 2019121 +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)))))