Average Error: 30.8 → 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((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 r432724 = x_re;
        double r432725 = r432724 * r432724;
        double r432726 = x_im;
        double r432727 = r432726 * r432726;
        double r432728 = r432725 + r432727;
        double r432729 = sqrt(r432728);
        double r432730 = log(r432729);
        double r432731 = y_re;
        double r432732 = r432730 * r432731;
        double r432733 = atan2(r432726, r432724);
        double r432734 = y_im;
        double r432735 = r432733 * r432734;
        double r432736 = r432732 - r432735;
        double r432737 = exp(r432736);
        double r432738 = r432730 * r432734;
        double r432739 = r432733 * r432731;
        double r432740 = r432738 + r432739;
        double r432741 = cos(r432740);
        double r432742 = r432737 * r432741;
        return r432742;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r432743 = y_im;
        double r432744 = x_re;
        double r432745 = x_im;
        double r432746 = hypot(r432744, r432745);
        double r432747 = log(r432746);
        double r432748 = atan2(r432745, r432744);
        double r432749 = y_re;
        double r432750 = r432748 * r432749;
        double r432751 = fma(r432743, r432747, r432750);
        double r432752 = cos(r432751);
        double r432753 = r432748 * r432743;
        double r432754 = r432749 * r432747;
        double r432755 = exp(r432754);
        double r432756 = log(r432755);
        double r432757 = r432753 - r432756;
        double r432758 = exp(r432757);
        double r432759 = r432752 / r432758;
        return r432759;
}

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

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