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)\]
\[\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)}}\]
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 - y.re \cdot \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)}}
double f(double x_re, double x_im, double y_re, double y_im) {
        double r484256 = x_re;
        double r484257 = r484256 * r484256;
        double r484258 = x_im;
        double r484259 = r484258 * r484258;
        double r484260 = r484257 + r484259;
        double r484261 = sqrt(r484260);
        double r484262 = log(r484261);
        double r484263 = y_re;
        double r484264 = r484262 * r484263;
        double r484265 = atan2(r484258, r484256);
        double r484266 = y_im;
        double r484267 = r484265 * r484266;
        double r484268 = r484264 - r484267;
        double r484269 = exp(r484268);
        double r484270 = r484262 * r484266;
        double r484271 = r484265 * r484263;
        double r484272 = r484270 + r484271;
        double r484273 = cos(r484272);
        double r484274 = r484269 * r484273;
        return r484274;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r484275 = y_im;
        double r484276 = x_re;
        double r484277 = x_im;
        double r484278 = hypot(r484276, r484277);
        double r484279 = log(r484278);
        double r484280 = atan2(r484277, r484276);
        double r484281 = y_re;
        double r484282 = r484280 * r484281;
        double r484283 = fma(r484275, r484279, r484282);
        double r484284 = cos(r484283);
        double r484285 = r484280 * r484275;
        double r484286 = r484281 * r484279;
        double r484287 = r484285 - r484286;
        double r484288 = exp(r484287);
        double r484289 = r484284 / r484288;
        return r484289;
}

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}{\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. 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 - y.re \cdot \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)}}\]

Reproduce

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