Average Error: 30.6 → 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)\]
\[\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 r578911 = x_re;
        double r578912 = r578911 * r578911;
        double r578913 = x_im;
        double r578914 = r578913 * r578913;
        double r578915 = r578912 + r578914;
        double r578916 = sqrt(r578915);
        double r578917 = log(r578916);
        double r578918 = y_re;
        double r578919 = r578917 * r578918;
        double r578920 = atan2(r578913, r578911);
        double r578921 = y_im;
        double r578922 = r578920 * r578921;
        double r578923 = r578919 - r578922;
        double r578924 = exp(r578923);
        double r578925 = r578917 * r578921;
        double r578926 = r578920 * r578918;
        double r578927 = r578925 + r578926;
        double r578928 = cos(r578927);
        double r578929 = r578924 * r578928;
        return r578929;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r578930 = y_im;
        double r578931 = x_re;
        double r578932 = x_im;
        double r578933 = hypot(r578931, r578932);
        double r578934 = log(r578933);
        double r578935 = atan2(r578932, r578931);
        double r578936 = y_re;
        double r578937 = r578935 * r578936;
        double r578938 = fma(r578930, r578934, r578937);
        double r578939 = cos(r578938);
        double r578940 = r578935 * r578930;
        double r578941 = r578936 * r578934;
        double r578942 = exp(r578941);
        double r578943 = log(r578942);
        double r578944 = r578940 - r578943;
        double r578945 = exp(r578944);
        double r578946 = r578939 / r578945;
        return r578946;
}

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

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

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