Average Error: 33.0 → 9.0
Time: 38.4s
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)\]
\[\begin{array}{l} \mathbf{if}\;x.re \le -1.7493329460610796 \cdot 10^{-37}:\\ \;\;\;\;e^{\log \left(-x.re\right) \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\ \mathbf{elif}\;x.re \le -2.301028981933872 \cdot 10^{-69}:\\ \;\;\;\;e^{\log \left(\left(\left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)\right)\right) \cdot y.re - \left(\left(y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right)}\\ \mathbf{elif}\;x.re \le -4.9836048998994 \cdot 10^{-312}:\\ \;\;\;\;e^{\log \left(-x.re\right) \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\ \mathbf{else}:\\ \;\;\;\;e^{y.re \cdot \log x.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\ \end{array}\]
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)
\begin{array}{l}
\mathbf{if}\;x.re \le -1.7493329460610796 \cdot 10^{-37}:\\
\;\;\;\;e^{\log \left(-x.re\right) \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\

\mathbf{elif}\;x.re \le -2.301028981933872 \cdot 10^{-69}:\\
\;\;\;\;e^{\log \left(\left(\left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)\right)\right) \cdot y.re - \left(\left(y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right)}\\

\mathbf{elif}\;x.re \le -4.9836048998994 \cdot 10^{-312}:\\
\;\;\;\;e^{\log \left(-x.re\right) \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\

\mathbf{else}:\\
\;\;\;\;e^{y.re \cdot \log x.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\

\end{array}
double f(double x_re, double x_im, double y_re, double y_im) {
        double r1011733 = x_re;
        double r1011734 = r1011733 * r1011733;
        double r1011735 = x_im;
        double r1011736 = r1011735 * r1011735;
        double r1011737 = r1011734 + r1011736;
        double r1011738 = sqrt(r1011737);
        double r1011739 = log(r1011738);
        double r1011740 = y_re;
        double r1011741 = r1011739 * r1011740;
        double r1011742 = atan2(r1011735, r1011733);
        double r1011743 = y_im;
        double r1011744 = r1011742 * r1011743;
        double r1011745 = r1011741 - r1011744;
        double r1011746 = exp(r1011745);
        double r1011747 = r1011739 * r1011743;
        double r1011748 = r1011742 * r1011740;
        double r1011749 = r1011747 + r1011748;
        double r1011750 = cos(r1011749);
        double r1011751 = r1011746 * r1011750;
        return r1011751;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r1011752 = x_re;
        double r1011753 = -1.7493329460610796e-37;
        bool r1011754 = r1011752 <= r1011753;
        double r1011755 = -r1011752;
        double r1011756 = log(r1011755);
        double r1011757 = y_re;
        double r1011758 = r1011756 * r1011757;
        double r1011759 = y_im;
        double r1011760 = x_im;
        double r1011761 = atan2(r1011760, r1011752);
        double r1011762 = r1011759 * r1011761;
        double r1011763 = r1011758 - r1011762;
        double r1011764 = exp(r1011763);
        double r1011765 = -2.301028981933872e-69;
        bool r1011766 = r1011752 <= r1011765;
        double r1011767 = r1011752 * r1011752;
        double r1011768 = r1011760 * r1011760;
        double r1011769 = r1011767 + r1011768;
        double r1011770 = sqrt(r1011769);
        double r1011771 = /* ERROR: no posit support in C */;
        double r1011772 = /* ERROR: no posit support in C */;
        double r1011773 = log(r1011772);
        double r1011774 = r1011773 * r1011757;
        double r1011775 = /* ERROR: no posit support in C */;
        double r1011776 = /* ERROR: no posit support in C */;
        double r1011777 = r1011774 - r1011776;
        double r1011778 = exp(r1011777);
        double r1011779 = -4.9836048998994e-312;
        bool r1011780 = r1011752 <= r1011779;
        double r1011781 = log(r1011752);
        double r1011782 = r1011757 * r1011781;
        double r1011783 = r1011782 - r1011762;
        double r1011784 = exp(r1011783);
        double r1011785 = r1011780 ? r1011764 : r1011784;
        double r1011786 = r1011766 ? r1011778 : r1011785;
        double r1011787 = r1011754 ? r1011764 : r1011786;
        return r1011787;
}

Error

Bits error versus x.re

Bits error versus x.im

Bits error versus y.re

Bits error versus y.im

Derivation

  1. Split input into 3 regimes
  2. if x.re < -1.7493329460610796e-37 or -2.301028981933872e-69 < x.re < -4.9836048998994e-312

    1. Initial program 32.8

      \[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 18.3

      \[\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 insert-posit1618.5

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

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

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

    if -1.7493329460610796e-37 < x.re < -2.301028981933872e-69

    1. Initial program 17.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 \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 10.5

      \[\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 insert-posit1610.5

      \[\leadsto e^{\log \color{blue}{\left(\left(\left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)\right)\right)} \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot 1\]
    5. Using strategy rm
    6. Applied insert-posit1619.0

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

    if -4.9836048998994e-312 < x.re

    1. Initial program 33.8

      \[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 21.1

      \[\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 insert-posit1621.3

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

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

      \[\leadsto e^{\color{blue}{\log x.re \cdot y.re} - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot 1\]
  3. Recombined 3 regimes into one program.
  4. Final simplification9.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \le -1.7493329460610796 \cdot 10^{-37}:\\ \;\;\;\;e^{\log \left(-x.re\right) \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\ \mathbf{elif}\;x.re \le -2.301028981933872 \cdot 10^{-69}:\\ \;\;\;\;e^{\log \left(\left(\left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)\right)\right) \cdot y.re - \left(\left(y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right)}\\ \mathbf{elif}\;x.re \le -4.9836048998994 \cdot 10^{-312}:\\ \;\;\;\;e^{\log \left(-x.re\right) \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\ \mathbf{else}:\\ \;\;\;\;e^{y.re \cdot \log x.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\ \end{array}\]

Reproduce

herbie shell --seed 2019149 
(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)))))