Average Error: 30.9 → 0.1
Time: 2.4m
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 r492543 = x_re;
        double r492544 = r492543 * r492543;
        double r492545 = x_im;
        double r492546 = r492545 * r492545;
        double r492547 = r492544 + r492546;
        double r492548 = sqrt(r492547);
        double r492549 = log(r492548);
        double r492550 = y_re;
        double r492551 = r492549 * r492550;
        double r492552 = atan2(r492545, r492543);
        double r492553 = y_im;
        double r492554 = r492552 * r492553;
        double r492555 = r492551 - r492554;
        double r492556 = exp(r492555);
        double r492557 = r492549 * r492553;
        double r492558 = r492552 * r492550;
        double r492559 = r492557 + r492558;
        double r492560 = cos(r492559);
        double r492561 = r492556 * r492560;
        return r492561;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r492562 = y_im;
        double r492563 = x_re;
        double r492564 = x_im;
        double r492565 = hypot(r492563, r492564);
        double r492566 = log(r492565);
        double r492567 = atan2(r492564, r492563);
        double r492568 = y_re;
        double r492569 = r492567 * r492568;
        double r492570 = fma(r492562, r492566, r492569);
        double r492571 = cos(r492570);
        double r492572 = r492567 * r492562;
        double r492573 = r492568 * r492566;
        double r492574 = r492572 - r492573;
        double r492575 = exp(r492574);
        double r492576 = r492571 / r492575;
        return r492576;
}

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.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. 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 2019125 +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)))))