Average Error: 33.3 → 4.1
Time: 7.0s
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(\mathsf{hypot}\left(x.re, x.im\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(\mathsf{hypot}\left(x.re, x.im\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 r12639 = x_re;
        double r12640 = r12639 * r12639;
        double r12641 = x_im;
        double r12642 = r12641 * r12641;
        double r12643 = r12640 + r12642;
        double r12644 = sqrt(r12643);
        double r12645 = log(r12644);
        double r12646 = y_re;
        double r12647 = r12645 * r12646;
        double r12648 = atan2(r12641, r12639);
        double r12649 = y_im;
        double r12650 = r12648 * r12649;
        double r12651 = r12647 - r12650;
        double r12652 = exp(r12651);
        double r12653 = r12645 * r12649;
        double r12654 = r12648 * r12646;
        double r12655 = r12653 + r12654;
        double r12656 = cos(r12655);
        double r12657 = r12652 * r12656;
        return r12657;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r12658 = x_re;
        double r12659 = x_im;
        double r12660 = hypot(r12658, r12659);
        double r12661 = log(r12660);
        double r12662 = y_re;
        double r12663 = r12661 * r12662;
        double r12664 = atan2(r12659, r12658);
        double r12665 = y_im;
        double r12666 = r12664 * r12665;
        double r12667 = r12663 - r12666;
        double r12668 = exp(r12667);
        return r12668;
}

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 hypot-def4.1

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

    \[\leadsto e^{\log \left(\mathsf{hypot}\left(x.re, x.im\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)))))