Average Error: 7.9 → 6.1
Time: 14.2s
Precision: 64
\[x0 = 1.854999999999999982236431605997495353222 \land x1 = 2.090000000000000115064208161541614572343 \cdot 10^{-4} \lor x0 = 2.984999999999999875655021241982467472553 \land x1 = 0.01859999999999999847899445626353553961962\]
\[\frac{x0}{1 - x1} - x0\]
\[\begin{array}{l} \mathbf{if}\;x1 \le 2.12089080810546861321705391922876060562 \cdot 10^{-4}:\\ \;\;\;\;{\left({e}^{\left(\sqrt[3]{\log \left(\mathsf{fma}\left(\sqrt[3]{x0} \cdot \sqrt[3]{x0}, \frac{\sqrt[3]{x0}}{1 - x1}, -x0\right)\right)} \cdot \sqrt[3]{\log \left(\mathsf{fma}\left(\sqrt[3]{x0} \cdot \sqrt[3]{x0}, \frac{\sqrt[3]{x0}}{1 - x1}, -x0\right)\right)}\right)}\right)}^{\left(\sqrt[3]{\log \left(\mathsf{fma}\left(\sqrt[3]{x0} \cdot \sqrt[3]{x0}, \frac{\sqrt[3]{x0}}{1 - x1}, -x0\right)\right)}\right)}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{\sqrt{x0}}{\sqrt{1} + \sqrt{x1}}, \frac{\sqrt{x0}}{\sqrt{1} - \sqrt{x1}}, -x0\right)\\ \end{array}\]
\frac{x0}{1 - x1} - x0
\begin{array}{l}
\mathbf{if}\;x1 \le 2.12089080810546861321705391922876060562 \cdot 10^{-4}:\\
\;\;\;\;{\left({e}^{\left(\sqrt[3]{\log \left(\mathsf{fma}\left(\sqrt[3]{x0} \cdot \sqrt[3]{x0}, \frac{\sqrt[3]{x0}}{1 - x1}, -x0\right)\right)} \cdot \sqrt[3]{\log \left(\mathsf{fma}\left(\sqrt[3]{x0} \cdot \sqrt[3]{x0}, \frac{\sqrt[3]{x0}}{1 - x1}, -x0\right)\right)}\right)}\right)}^{\left(\sqrt[3]{\log \left(\mathsf{fma}\left(\sqrt[3]{x0} \cdot \sqrt[3]{x0}, \frac{\sqrt[3]{x0}}{1 - x1}, -x0\right)\right)}\right)}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\sqrt{x0}}{\sqrt{1} + \sqrt{x1}}, \frac{\sqrt{x0}}{\sqrt{1} - \sqrt{x1}}, -x0\right)\\

\end{array}
double f(double x0, double x1) {
        double r108800 = x0;
        double r108801 = 1.0;
        double r108802 = x1;
        double r108803 = r108801 - r108802;
        double r108804 = r108800 / r108803;
        double r108805 = r108804 - r108800;
        return r108805;
}

double f(double x0, double x1) {
        double r108806 = x1;
        double r108807 = 0.00021208908081054686;
        bool r108808 = r108806 <= r108807;
        double r108809 = exp(1.0);
        double r108810 = x0;
        double r108811 = cbrt(r108810);
        double r108812 = r108811 * r108811;
        double r108813 = 1.0;
        double r108814 = r108813 - r108806;
        double r108815 = r108811 / r108814;
        double r108816 = -r108810;
        double r108817 = fma(r108812, r108815, r108816);
        double r108818 = log(r108817);
        double r108819 = cbrt(r108818);
        double r108820 = r108819 * r108819;
        double r108821 = pow(r108809, r108820);
        double r108822 = pow(r108821, r108819);
        double r108823 = sqrt(r108810);
        double r108824 = sqrt(r108813);
        double r108825 = sqrt(r108806);
        double r108826 = r108824 + r108825;
        double r108827 = r108823 / r108826;
        double r108828 = r108824 - r108825;
        double r108829 = r108823 / r108828;
        double r108830 = fma(r108827, r108829, r108816);
        double r108831 = r108808 ? r108822 : r108830;
        return r108831;
}

Error

Bits error versus x0

Bits error versus x1

Target

Original7.9
Target0.3
Herbie6.1
\[\frac{x0 \cdot x1}{1 - x1}\]

Derivation

  1. Split input into 2 regimes
  2. if x1 < 0.00021208908081054686

    1. Initial program 11.2

      \[\frac{x0}{1 - x1} - x0\]
    2. Using strategy rm
    3. Applied *-un-lft-identity11.2

      \[\leadsto \frac{x0}{\color{blue}{1 \cdot \left(1 - x1\right)}} - x0\]
    4. Applied add-cube-cbrt11.2

      \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{x0} \cdot \sqrt[3]{x0}\right) \cdot \sqrt[3]{x0}}}{1 \cdot \left(1 - x1\right)} - x0\]
    5. Applied times-frac10.9

      \[\leadsto \color{blue}{\frac{\sqrt[3]{x0} \cdot \sqrt[3]{x0}}{1} \cdot \frac{\sqrt[3]{x0}}{1 - x1}} - x0\]
    6. Applied fma-neg8.9

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{\sqrt[3]{x0} \cdot \sqrt[3]{x0}}{1}, \frac{\sqrt[3]{x0}}{1 - x1}, -x0\right)}\]
    7. Using strategy rm
    8. Applied add-exp-log8.9

      \[\leadsto \color{blue}{e^{\log \left(\mathsf{fma}\left(\frac{\sqrt[3]{x0} \cdot \sqrt[3]{x0}}{1}, \frac{\sqrt[3]{x0}}{1 - x1}, -x0\right)\right)}}\]
    9. Simplified8.9

      \[\leadsto e^{\color{blue}{\log \left(\mathsf{fma}\left(\sqrt[3]{x0} \cdot \sqrt[3]{x0}, \frac{\sqrt[3]{x0}}{1 - x1}, -x0\right)\right)}}\]
    10. Using strategy rm
    11. Applied pow18.9

      \[\leadsto e^{\log \color{blue}{\left({\left(\mathsf{fma}\left(\sqrt[3]{x0} \cdot \sqrt[3]{x0}, \frac{\sqrt[3]{x0}}{1 - x1}, -x0\right)\right)}^{1}\right)}}\]
    12. Applied log-pow8.9

      \[\leadsto e^{\color{blue}{1 \cdot \log \left(\mathsf{fma}\left(\sqrt[3]{x0} \cdot \sqrt[3]{x0}, \frac{\sqrt[3]{x0}}{1 - x1}, -x0\right)\right)}}\]
    13. Applied exp-prod8.9

      \[\leadsto \color{blue}{{\left(e^{1}\right)}^{\left(\log \left(\mathsf{fma}\left(\sqrt[3]{x0} \cdot \sqrt[3]{x0}, \frac{\sqrt[3]{x0}}{1 - x1}, -x0\right)\right)\right)}}\]
    14. Simplified8.9

      \[\leadsto {\color{blue}{e}}^{\left(\log \left(\mathsf{fma}\left(\sqrt[3]{x0} \cdot \sqrt[3]{x0}, \frac{\sqrt[3]{x0}}{1 - x1}, -x0\right)\right)\right)}\]
    15. Using strategy rm
    16. Applied add-cube-cbrt8.9

      \[\leadsto {e}^{\color{blue}{\left(\left(\sqrt[3]{\log \left(\mathsf{fma}\left(\sqrt[3]{x0} \cdot \sqrt[3]{x0}, \frac{\sqrt[3]{x0}}{1 - x1}, -x0\right)\right)} \cdot \sqrt[3]{\log \left(\mathsf{fma}\left(\sqrt[3]{x0} \cdot \sqrt[3]{x0}, \frac{\sqrt[3]{x0}}{1 - x1}, -x0\right)\right)}\right) \cdot \sqrt[3]{\log \left(\mathsf{fma}\left(\sqrt[3]{x0} \cdot \sqrt[3]{x0}, \frac{\sqrt[3]{x0}}{1 - x1}, -x0\right)\right)}\right)}}\]
    17. Applied pow-unpow8.9

      \[\leadsto \color{blue}{{\left({e}^{\left(\sqrt[3]{\log \left(\mathsf{fma}\left(\sqrt[3]{x0} \cdot \sqrt[3]{x0}, \frac{\sqrt[3]{x0}}{1 - x1}, -x0\right)\right)} \cdot \sqrt[3]{\log \left(\mathsf{fma}\left(\sqrt[3]{x0} \cdot \sqrt[3]{x0}, \frac{\sqrt[3]{x0}}{1 - x1}, -x0\right)\right)}\right)}\right)}^{\left(\sqrt[3]{\log \left(\mathsf{fma}\left(\sqrt[3]{x0} \cdot \sqrt[3]{x0}, \frac{\sqrt[3]{x0}}{1 - x1}, -x0\right)\right)}\right)}}\]

    if 0.00021208908081054686 < x1

    1. Initial program 4.6

      \[\frac{x0}{1 - x1} - x0\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt4.6

      \[\leadsto \frac{x0}{1 - \color{blue}{\sqrt{x1} \cdot \sqrt{x1}}} - x0\]
    4. Applied add-sqr-sqrt4.6

      \[\leadsto \frac{x0}{\color{blue}{\sqrt{1} \cdot \sqrt{1}} - \sqrt{x1} \cdot \sqrt{x1}} - x0\]
    5. Applied difference-of-squares4.6

      \[\leadsto \frac{x0}{\color{blue}{\left(\sqrt{1} + \sqrt{x1}\right) \cdot \left(\sqrt{1} - \sqrt{x1}\right)}} - x0\]
    6. Applied add-sqr-sqrt4.6

      \[\leadsto \frac{\color{blue}{\sqrt{x0} \cdot \sqrt{x0}}}{\left(\sqrt{1} + \sqrt{x1}\right) \cdot \left(\sqrt{1} - \sqrt{x1}\right)} - x0\]
    7. Applied times-frac5.2

      \[\leadsto \color{blue}{\frac{\sqrt{x0}}{\sqrt{1} + \sqrt{x1}} \cdot \frac{\sqrt{x0}}{\sqrt{1} - \sqrt{x1}}} - x0\]
    8. Applied fma-neg3.2

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{\sqrt{x0}}{\sqrt{1} + \sqrt{x1}}, \frac{\sqrt{x0}}{\sqrt{1} - \sqrt{x1}}, -x0\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification6.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;x1 \le 2.12089080810546861321705391922876060562 \cdot 10^{-4}:\\ \;\;\;\;{\left({e}^{\left(\sqrt[3]{\log \left(\mathsf{fma}\left(\sqrt[3]{x0} \cdot \sqrt[3]{x0}, \frac{\sqrt[3]{x0}}{1 - x1}, -x0\right)\right)} \cdot \sqrt[3]{\log \left(\mathsf{fma}\left(\sqrt[3]{x0} \cdot \sqrt[3]{x0}, \frac{\sqrt[3]{x0}}{1 - x1}, -x0\right)\right)}\right)}\right)}^{\left(\sqrt[3]{\log \left(\mathsf{fma}\left(\sqrt[3]{x0} \cdot \sqrt[3]{x0}, \frac{\sqrt[3]{x0}}{1 - x1}, -x0\right)\right)}\right)}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{\sqrt{x0}}{\sqrt{1} + \sqrt{x1}}, \frac{\sqrt{x0}}{\sqrt{1} - \sqrt{x1}}, -x0\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019323 +o rules:numerics
(FPCore (x0 x1)
  :name "(- (/ x0 (- 1 x1)) x0)"
  :precision binary64
  :pre (or (and (== x0 1.855) (== x1 0.000209)) (and (== x0 2.985) (== x1 0.0186)))

  :herbie-target
  (/ (* x0 x1) (- 1 x1))

  (- (/ x0 (- 1 x1)) x0))