Average Error: 30.8 → 0.1
Time: 2.3m
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 - y.re \cdot \log \left(\sqrt{x.re^2 + x.im^2}^*\right)}}\]
double f(double x_re, double x_im, double y_re, double y_im) {
        double r192409 = x_re;
        double r192410 = r192409 * r192409;
        double r192411 = x_im;
        double r192412 = r192411 * r192411;
        double r192413 = r192410 + r192412;
        double r192414 = sqrt(r192413);
        double r192415 = log(r192414);
        double r192416 = y_re;
        double r192417 = r192415 * r192416;
        double r192418 = atan2(r192411, r192409);
        double r192419 = y_im;
        double r192420 = r192418 * r192419;
        double r192421 = r192417 - r192420;
        double r192422 = exp(r192421);
        double r192423 = r192415 * r192419;
        double r192424 = r192418 * r192416;
        double r192425 = r192423 + r192424;
        double r192426 = cos(r192425);
        double r192427 = r192422 * r192426;
        return r192427;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r192428 = y_im;
        double r192429 = x_re;
        double r192430 = x_im;
        double r192431 = hypot(r192429, r192430);
        double r192432 = log(r192431);
        double r192433 = atan2(r192430, r192429);
        double r192434 = y_re;
        double r192435 = r192433 * r192434;
        double r192436 = fma(r192428, r192432, r192435);
        double r192437 = cos(r192436);
        double r192438 = r192433 * r192428;
        double r192439 = r192434 * r192432;
        double r192440 = r192438 - r192439;
        double r192441 = exp(r192440);
        double r192442 = r192437 / r192441;
        return r192442;
}

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 - y.re \cdot \log \left(\sqrt{x.re^2 + x.im^2}^*\right)}}

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. 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 - y.re \cdot \log \left(\sqrt{x.re^2 + x.im^2}^*\right)}}\]

Reproduce

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