Average Error: 30.7 → 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)\]
\[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 r457040 = x_re;
        double r457041 = r457040 * r457040;
        double r457042 = x_im;
        double r457043 = r457042 * r457042;
        double r457044 = r457041 + r457043;
        double r457045 = sqrt(r457044);
        double r457046 = log(r457045);
        double r457047 = y_re;
        double r457048 = r457046 * r457047;
        double r457049 = atan2(r457042, r457040);
        double r457050 = y_im;
        double r457051 = r457049 * r457050;
        double r457052 = r457048 - r457051;
        double r457053 = exp(r457052);
        double r457054 = r457046 * r457050;
        double r457055 = r457049 * r457047;
        double r457056 = r457054 + r457055;
        double r457057 = cos(r457056);
        double r457058 = r457053 * r457057;
        return r457058;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r457059 = x_re;
        double r457060 = x_im;
        double r457061 = hypot(r457059, r457060);
        double r457062 = log(r457061);
        double r457063 = y_re;
        double r457064 = r457062 * r457063;
        double r457065 = y_im;
        double r457066 = atan2(r457060, r457059);
        double r457067 = r457065 * r457066;
        double r457068 = r457064 - r457067;
        double r457069 = exp(r457068);
        double r457070 = r457063 * r457066;
        double r457071 = fma(r457065, r457062, r457070);
        double r457072 = cos(r457071);
        double r457073 = r457069 * r457072;
        return r457073;
}

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

    \[\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.1

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