Average Error: 30.5 → 0.2
Time: 4.1m
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 \sin \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)\]
\[\sin \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right) \cdot e^{y.re \cdot \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\]
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 \sin \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)
\sin \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right) \cdot e^{y.re \cdot \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}
double f(double x_re, double x_im, double y_re, double y_im) {
        double r1463402 = x_re;
        double r1463403 = r1463402 * r1463402;
        double r1463404 = x_im;
        double r1463405 = r1463404 * r1463404;
        double r1463406 = r1463403 + r1463405;
        double r1463407 = sqrt(r1463406);
        double r1463408 = log(r1463407);
        double r1463409 = y_re;
        double r1463410 = r1463408 * r1463409;
        double r1463411 = atan2(r1463404, r1463402);
        double r1463412 = y_im;
        double r1463413 = r1463411 * r1463412;
        double r1463414 = r1463410 - r1463413;
        double r1463415 = exp(r1463414);
        double r1463416 = r1463408 * r1463412;
        double r1463417 = r1463411 * r1463409;
        double r1463418 = r1463416 + r1463417;
        double r1463419 = sin(r1463418);
        double r1463420 = r1463415 * r1463419;
        return r1463420;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r1463421 = y_im;
        double r1463422 = x_re;
        double r1463423 = x_im;
        double r1463424 = hypot(r1463422, r1463423);
        double r1463425 = log(r1463424);
        double r1463426 = atan2(r1463423, r1463422);
        double r1463427 = y_re;
        double r1463428 = r1463426 * r1463427;
        double r1463429 = fma(r1463421, r1463425, r1463428);
        double r1463430 = sin(r1463429);
        double r1463431 = r1463427 * r1463425;
        double r1463432 = r1463426 * r1463421;
        double r1463433 = r1463431 - r1463432;
        double r1463434 = exp(r1463433);
        double r1463435 = r1463430 * r1463434;
        return r1463435;
}

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

    \[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 \sin \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.2

    \[\leadsto \color{blue}{\sin \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right) \cdot e^{y.re \cdot \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}}\]
  3. Final simplification0.2

    \[\leadsto \sin \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right) \cdot e^{y.re \cdot \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\]

Reproduce

herbie shell --seed 2019134 +o rules:numerics
(FPCore (x.re x.im y.re y.im)
  :name "powComplex, imaginary part"
  (* (exp (- (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re) (* (atan2 x.im x.re) y.im))) (sin (+ (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.im) (* (atan2 x.im x.re) y.re)))))