Average Error: 33.4 → 3.7
Time: 31.7s
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{\sqrt[3]{\cos \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot \left(\cos \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot \cos \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right)\right)}}{e^{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re} - \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re}}\]
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{\sqrt[3]{\cos \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot \left(\cos \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot \cos \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right)\right)}}{e^{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re} - \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re}}
double f(double x_re, double x_im, double y_re, double y_im) {
        double r1253329 = x_re;
        double r1253330 = r1253329 * r1253329;
        double r1253331 = x_im;
        double r1253332 = r1253331 * r1253331;
        double r1253333 = r1253330 + r1253332;
        double r1253334 = sqrt(r1253333);
        double r1253335 = log(r1253334);
        double r1253336 = y_re;
        double r1253337 = r1253335 * r1253336;
        double r1253338 = atan2(r1253331, r1253329);
        double r1253339 = y_im;
        double r1253340 = r1253338 * r1253339;
        double r1253341 = r1253337 - r1253340;
        double r1253342 = exp(r1253341);
        double r1253343 = r1253335 * r1253339;
        double r1253344 = r1253338 * r1253336;
        double r1253345 = r1253343 + r1253344;
        double r1253346 = cos(r1253345);
        double r1253347 = r1253342 * r1253346;
        return r1253347;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r1253348 = y_im;
        double r1253349 = x_re;
        double r1253350 = x_im;
        double r1253351 = hypot(r1253349, r1253350);
        double r1253352 = log(r1253351);
        double r1253353 = y_re;
        double r1253354 = atan2(r1253350, r1253349);
        double r1253355 = r1253353 * r1253354;
        double r1253356 = fma(r1253348, r1253352, r1253355);
        double r1253357 = cos(r1253356);
        double r1253358 = r1253357 * r1253357;
        double r1253359 = r1253357 * r1253358;
        double r1253360 = cbrt(r1253359);
        double r1253361 = r1253348 * r1253354;
        double r1253362 = r1253352 * r1253353;
        double r1253363 = r1253361 - r1253362;
        double r1253364 = exp(r1253363);
        double r1253365 = r1253360 / r1253364;
        return r1253365;
}

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 33.4

    \[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. Simplified3.6

    \[\leadsto \color{blue}{\frac{\cos \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. Using strategy rm
  4. Applied add-log-exp3.6

    \[\leadsto \frac{\color{blue}{\log \left(e^{\cos \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)}\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)}}\]
  5. Using strategy rm
  6. Applied add-cbrt-cube3.7

    \[\leadsto \frac{\color{blue}{\sqrt[3]{\left(\log \left(e^{\cos \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)}\right) \cdot \log \left(e^{\cos \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)}\right)\right) \cdot \log \left(e^{\cos \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)}\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)}}\]
  7. Simplified3.7

    \[\leadsto \frac{\sqrt[3]{\color{blue}{\left(\cos \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot \cos \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right)\right) \cdot \cos \left(\mathsf{fma}\left(y.im, \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re \cdot \tan^{-1}_* \frac{x.im}{x.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)}}\]
  8. Final simplification3.7

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

Reproduce

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