Average Error: 30.7 → 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 r438497 = x_re;
        double r438498 = r438497 * r438497;
        double r438499 = x_im;
        double r438500 = r438499 * r438499;
        double r438501 = r438498 + r438500;
        double r438502 = sqrt(r438501);
        double r438503 = log(r438502);
        double r438504 = y_re;
        double r438505 = r438503 * r438504;
        double r438506 = atan2(r438499, r438497);
        double r438507 = y_im;
        double r438508 = r438506 * r438507;
        double r438509 = r438505 - r438508;
        double r438510 = exp(r438509);
        double r438511 = r438503 * r438507;
        double r438512 = r438506 * r438504;
        double r438513 = r438511 + r438512;
        double r438514 = cos(r438513);
        double r438515 = r438510 * r438514;
        return r438515;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r438516 = x_re;
        double r438517 = x_im;
        double r438518 = hypot(r438516, r438517);
        double r438519 = log(r438518);
        double r438520 = y_re;
        double r438521 = r438519 * r438520;
        double r438522 = y_im;
        double r438523 = atan2(r438517, r438516);
        double r438524 = r438522 * r438523;
        double r438525 = r438521 - r438524;
        double r438526 = exp(r438525);
        double r438527 = r438520 * r438523;
        double r438528 = fma(r438522, r438519, r438527);
        double r438529 = cos(r438528);
        double r438530 = r438526 * r438529;
        return r438530;
}

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

    \[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 2019139 +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)))))