Average Error: 33.0 → 4.0
Time: 27.8s
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 \log \left(e^{\left(\left(\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)\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)
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 \log \left(e^{\left(\left(\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)\right)\right)}\right)
double f(double x_re, double x_im, double y_re, double y_im) {
        double r555025 = x_re;
        double r555026 = r555025 * r555025;
        double r555027 = x_im;
        double r555028 = r555027 * r555027;
        double r555029 = r555026 + r555028;
        double r555030 = sqrt(r555029);
        double r555031 = log(r555030);
        double r555032 = y_re;
        double r555033 = r555031 * r555032;
        double r555034 = atan2(r555027, r555025);
        double r555035 = y_im;
        double r555036 = r555034 * r555035;
        double r555037 = r555033 - r555036;
        double r555038 = exp(r555037);
        double r555039 = r555031 * r555035;
        double r555040 = r555034 * r555032;
        double r555041 = r555039 + r555040;
        double r555042 = cos(r555041);
        double r555043 = r555038 * r555042;
        return r555043;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r555044 = x_re;
        double r555045 = x_im;
        double r555046 = hypot(r555044, r555045);
        double r555047 = log(r555046);
        double r555048 = y_re;
        double r555049 = r555047 * r555048;
        double r555050 = y_im;
        double r555051 = atan2(r555045, r555044);
        double r555052 = r555050 * r555051;
        double r555053 = r555049 - r555052;
        double r555054 = exp(r555053);
        double r555055 = r555048 * r555051;
        double r555056 = fma(r555050, r555047, r555055);
        double r555057 = cos(r555056);
        double r555058 = /* ERROR: no posit support in C */;
        double r555059 = /* ERROR: no posit support in C */;
        double r555060 = exp(r555059);
        double r555061 = log(r555060);
        double r555062 = r555054 * r555061;
        return r555062;
}

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 33.0

    \[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. Simplified3.4

    \[\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. Using strategy rm
  4. Applied insert-posit164.0

    \[\leadsto 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 \color{blue}{\left(\left(\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)\right)\right)}\]
  5. Using strategy rm
  6. Applied add-log-exp4.0

    \[\leadsto 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 \color{blue}{\log \left(e^{\left(\left(\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)\right)\right)}\right)}\]
  7. Final simplification4.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 \log \left(e^{\left(\left(\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)\right)\right)}\right)\]

Reproduce

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