Average Error: 31.5 → 0.1
Time: 4.0m
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)\]
\[\frac{\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)}{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 \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)
\frac{\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)}{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 r1055475 = x_re;
        double r1055476 = r1055475 * r1055475;
        double r1055477 = x_im;
        double r1055478 = r1055477 * r1055477;
        double r1055479 = r1055476 + r1055478;
        double r1055480 = sqrt(r1055479);
        double r1055481 = log(r1055480);
        double r1055482 = y_re;
        double r1055483 = r1055481 * r1055482;
        double r1055484 = atan2(r1055477, r1055475);
        double r1055485 = y_im;
        double r1055486 = r1055484 * r1055485;
        double r1055487 = r1055483 - r1055486;
        double r1055488 = exp(r1055487);
        double r1055489 = r1055481 * r1055485;
        double r1055490 = r1055484 * r1055482;
        double r1055491 = r1055489 + r1055490;
        double r1055492 = sin(r1055491);
        double r1055493 = r1055488 * r1055492;
        return r1055493;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r1055494 = y_im;
        double r1055495 = x_re;
        double r1055496 = x_im;
        double r1055497 = hypot(r1055495, r1055496);
        double r1055498 = log(r1055497);
        double r1055499 = atan2(r1055496, r1055495);
        double r1055500 = y_re;
        double r1055501 = r1055499 * r1055500;
        double r1055502 = fma(r1055494, r1055498, r1055501);
        double r1055503 = sin(r1055502);
        double r1055504 = r1055499 * r1055494;
        double r1055505 = r1055500 * r1055498;
        double r1055506 = r1055504 - r1055505;
        double r1055507 = exp(r1055506);
        double r1055508 = r1055503 / r1055507;
        return r1055508;
}

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 31.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.1

    \[\leadsto \color{blue}{\frac{\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)}{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{\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)}{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 2019135 +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)))))