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)}}\]
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 r192474 = x_re;
        double r192475 = r192474 * r192474;
        double r192476 = x_im;
        double r192477 = r192476 * r192476;
        double r192478 = r192475 + r192477;
        double r192479 = sqrt(r192478);
        double r192480 = log(r192479);
        double r192481 = y_re;
        double r192482 = r192480 * r192481;
        double r192483 = atan2(r192476, r192474);
        double r192484 = y_im;
        double r192485 = r192483 * r192484;
        double r192486 = r192482 - r192485;
        double r192487 = exp(r192486);
        double r192488 = r192480 * r192484;
        double r192489 = r192483 * r192481;
        double r192490 = r192488 + r192489;
        double r192491 = cos(r192490);
        double r192492 = r192487 * r192491;
        return r192492;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r192493 = y_im;
        double r192494 = x_re;
        double r192495 = x_im;
        double r192496 = hypot(r192494, r192495);
        double r192497 = log(r192496);
        double r192498 = atan2(r192495, r192494);
        double r192499 = y_re;
        double r192500 = r192498 * r192499;
        double r192501 = fma(r192493, r192497, r192500);
        double r192502 = cos(r192501);
        double r192503 = r192498 * r192493;
        double r192504 = r192499 * r192497;
        double r192505 = r192503 - r192504;
        double r192506 = exp(r192505);
        double r192507 = r192502 / r192506;
        return r192507;
}

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 2019104 +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)))))