Average Error: 33.3 → 4.1
Time: 7.2s
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)\]
\[e^{\log \left(e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)}\right) \cdot y.re - \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 \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)
e^{\log \left(e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)}\right) \cdot y.re - \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 r12729 = x_re;
        double r12730 = r12729 * r12729;
        double r12731 = x_im;
        double r12732 = r12731 * r12731;
        double r12733 = r12730 + r12732;
        double r12734 = sqrt(r12733);
        double r12735 = log(r12734);
        double r12736 = y_re;
        double r12737 = r12735 * r12736;
        double r12738 = atan2(r12731, r12729);
        double r12739 = y_im;
        double r12740 = r12738 * r12739;
        double r12741 = r12737 - r12740;
        double r12742 = exp(r12741);
        double r12743 = r12735 * r12739;
        double r12744 = r12738 * r12736;
        double r12745 = r12743 + r12744;
        double r12746 = cos(r12745);
        double r12747 = r12742 * r12746;
        return r12747;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r12748 = x_re;
        double r12749 = x_im;
        double r12750 = hypot(r12748, r12749);
        double r12751 = log(r12750);
        double r12752 = exp(r12751);
        double r12753 = log(r12752);
        double r12754 = y_re;
        double r12755 = r12753 * r12754;
        double r12756 = atan2(r12749, r12748);
        double r12757 = y_im;
        double r12758 = r12756 * r12757;
        double r12759 = r12755 - r12758;
        double r12760 = exp(r12759);
        return r12760;
}

Error

Bits error versus x.re

Bits error versus x.im

Bits error versus y.re

Bits error versus y.im

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 33.3

    \[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. Taylor expanded around 0 19.7

    \[\leadsto 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 \color{blue}{1}\]
  3. Using strategy rm
  4. Applied add-exp-log19.7

    \[\leadsto e^{\log \color{blue}{\left(e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)}\right)} \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot 1\]
  5. Simplified4.1

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

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

Reproduce

herbie shell --seed 2019353 +o rules:numerics
(FPCore (x.re x.im y.re y.im)
  :name "powComplex, real part"
  :precision binary64
  (* (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)))))