Average Error: 30.4 → 0.0
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 - \log \left(e^{y.re \cdot \log \left(\mathsf{hypot}\left(x.re, x.im\right)\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 - \log \left(e^{y.re \cdot \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)}\right)}}
double f(double x_re, double x_im, double y_re, double y_im) {
        double r442554 = x_re;
        double r442555 = r442554 * r442554;
        double r442556 = x_im;
        double r442557 = r442556 * r442556;
        double r442558 = r442555 + r442557;
        double r442559 = sqrt(r442558);
        double r442560 = log(r442559);
        double r442561 = y_re;
        double r442562 = r442560 * r442561;
        double r442563 = atan2(r442556, r442554);
        double r442564 = y_im;
        double r442565 = r442563 * r442564;
        double r442566 = r442562 - r442565;
        double r442567 = exp(r442566);
        double r442568 = r442560 * r442564;
        double r442569 = r442563 * r442561;
        double r442570 = r442568 + r442569;
        double r442571 = cos(r442570);
        double r442572 = r442567 * r442571;
        return r442572;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r442573 = y_im;
        double r442574 = x_re;
        double r442575 = x_im;
        double r442576 = hypot(r442574, r442575);
        double r442577 = log(r442576);
        double r442578 = atan2(r442575, r442574);
        double r442579 = y_re;
        double r442580 = r442578 * r442579;
        double r442581 = fma(r442573, r442577, r442580);
        double r442582 = cos(r442581);
        double r442583 = r442578 * r442573;
        double r442584 = r442579 * r442577;
        double r442585 = exp(r442584);
        double r442586 = log(r442585);
        double r442587 = r442583 - r442586;
        double r442588 = exp(r442587);
        double r442589 = r442582 / r442588;
        return r442589;
}

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.4

    \[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}{\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. Using strategy rm
  4. Applied add-log-exp0.0

    \[\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 - \color{blue}{\log \left(e^{y.re \cdot \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)}\right)}}}\]
  5. Final simplification0.0

    \[\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 - \log \left(e^{y.re \cdot \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)}\right)}}\]

Reproduce

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