Average Error: 30.6 → 0.1
Time: 2.5m
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((y.im \cdot \left(\log \left(\sqrt{x.re^2 + x.im^2}^*\right)\right) + \left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right))_*\right)}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im - \log \left(e^{y.re \cdot \log \left(\sqrt{x.re^2 + x.im^2}^*\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((y.im \cdot \left(\log \left(\sqrt{x.re^2 + x.im^2}^*\right)\right) + \left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right))_*\right)}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im - \log \left(e^{y.re \cdot \log \left(\sqrt{x.re^2 + x.im^2}^*\right)}\right)}}
double f(double x_re, double x_im, double y_re, double y_im) {
        double r578916 = x_re;
        double r578917 = r578916 * r578916;
        double r578918 = x_im;
        double r578919 = r578918 * r578918;
        double r578920 = r578917 + r578919;
        double r578921 = sqrt(r578920);
        double r578922 = log(r578921);
        double r578923 = y_re;
        double r578924 = r578922 * r578923;
        double r578925 = atan2(r578918, r578916);
        double r578926 = y_im;
        double r578927 = r578925 * r578926;
        double r578928 = r578924 - r578927;
        double r578929 = exp(r578928);
        double r578930 = r578922 * r578926;
        double r578931 = r578925 * r578923;
        double r578932 = r578930 + r578931;
        double r578933 = cos(r578932);
        double r578934 = r578929 * r578933;
        return r578934;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r578935 = y_im;
        double r578936 = x_re;
        double r578937 = x_im;
        double r578938 = hypot(r578936, r578937);
        double r578939 = log(r578938);
        double r578940 = atan2(r578937, r578936);
        double r578941 = y_re;
        double r578942 = r578940 * r578941;
        double r578943 = fma(r578935, r578939, r578942);
        double r578944 = cos(r578943);
        double r578945 = r578940 * r578935;
        double r578946 = r578941 * r578939;
        double r578947 = exp(r578946);
        double r578948 = log(r578947);
        double r578949 = r578945 - r578948;
        double r578950 = exp(r578949);
        double r578951 = r578944 / r578950;
        return r578951;
}

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

    \[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((y.im \cdot \left(\log \left(\sqrt{x.re^2 + x.im^2}^*\right)\right) + \left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right))_*\right)}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im - y.re \cdot \log \left(\sqrt{x.re^2 + x.im^2}^*\right)}}}\]
  3. Using strategy rm
  4. Applied add-log-exp0.1

    \[\leadsto \frac{\cos \left((y.im \cdot \left(\log \left(\sqrt{x.re^2 + x.im^2}^*\right)\right) + \left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right))_*\right)}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im - \color{blue}{\log \left(e^{y.re \cdot \log \left(\sqrt{x.re^2 + x.im^2}^*\right)}\right)}}}\]
  5. Final simplification0.1

    \[\leadsto \frac{\cos \left((y.im \cdot \left(\log \left(\sqrt{x.re^2 + x.im^2}^*\right)\right) + \left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right))_*\right)}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im - \log \left(e^{y.re \cdot \log \left(\sqrt{x.re^2 + x.im^2}^*\right)}\right)}}\]

Reproduce

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