Average Error: 7.9 → 6.1
Time: 1.8m
Precision: 64
\[x0 = 1.855 \land x1 = 2.09000000000000012 \cdot 10^{-4} \lor x0 = 2.98499999999999988 \land x1 = 0.018599999999999998\]
\[\frac{x0}{1 - x1} - x0\]
\[\begin{array}{l} \mathbf{if}\;x1 \le 2.12089080810546861 \cdot 10^{-4}:\\ \;\;\;\;{\left({e}^{\left(\sqrt[3]{\log \left(\mathsf{fma}\left({x0}^{\frac{2}{3}}, \frac{\sqrt[3]{x0}}{1 - x1}, -x0\right)\right)} \cdot \sqrt[3]{\log \left(\mathsf{fma}\left({x0}^{\frac{2}{3}}, \frac{\sqrt[3]{x0}}{1 - x1}, -x0\right)\right)}\right)}\right)}^{\left(\sqrt[3]{\log \left(\mathsf{fma}\left({x0}^{\frac{2}{3}}, \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.12089080810546861 \cdot 10^{-4}:\\
\;\;\;\;{\left({e}^{\left(\sqrt[3]{\log \left(\mathsf{fma}\left({x0}^{\frac{2}{3}}, \frac{\sqrt[3]{x0}}{1 - x1}, -x0\right)\right)} \cdot \sqrt[3]{\log \left(\mathsf{fma}\left({x0}^{\frac{2}{3}}, \frac{\sqrt[3]{x0}}{1 - x1}, -x0\right)\right)}\right)}\right)}^{\left(\sqrt[3]{\log \left(\mathsf{fma}\left({x0}^{\frac{2}{3}}, \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 r258844 = x0;
        double r258845 = 1.0;
        double r258846 = x1;
        double r258847 = r258845 - r258846;
        double r258848 = r258844 / r258847;
        double r258849 = r258848 - r258844;
        return r258849;
}

double f(double x0, double x1) {
        double r258850 = x1;
        double r258851 = 0.00021208908081054686;
        bool r258852 = r258850 <= r258851;
        double r258853 = exp(1.0);
        double r258854 = x0;
        double r258855 = 0.6666666666666666;
        double r258856 = pow(r258854, r258855);
        double r258857 = cbrt(r258854);
        double r258858 = 1.0;
        double r258859 = r258858 - r258850;
        double r258860 = r258857 / r258859;
        double r258861 = -r258854;
        double r258862 = fma(r258856, r258860, r258861);
        double r258863 = log(r258862);
        double r258864 = cbrt(r258863);
        double r258865 = r258864 * r258864;
        double r258866 = pow(r258853, r258865);
        double r258867 = pow(r258866, r258864);
        double r258868 = sqrt(r258854);
        double r258869 = sqrt(r258858);
        double r258870 = sqrt(r258850);
        double r258871 = r258869 + r258870;
        double r258872 = r258868 / r258871;
        double r258873 = r258869 - r258870;
        double r258874 = r258868 / r258873;
        double r258875 = fma(r258872, r258874, r258861);
        double r258876 = r258852 ? r258867 : r258875;
        return r258876;
}

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({x0}^{\frac{2}{3}}, \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({x0}^{\frac{2}{3}}, \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({x0}^{\frac{2}{3}}, \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({x0}^{\frac{2}{3}}, \frac{\sqrt[3]{x0}}{1 - x1}, -x0\right)\right)\right)}}\]
    14. Simplified8.9

      \[\leadsto {\color{blue}{e}}^{\left(\log \left(\mathsf{fma}\left({x0}^{\frac{2}{3}}, \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({x0}^{\frac{2}{3}}, \frac{\sqrt[3]{x0}}{1 - x1}, -x0\right)\right)} \cdot \sqrt[3]{\log \left(\mathsf{fma}\left({x0}^{\frac{2}{3}}, \frac{\sqrt[3]{x0}}{1 - x1}, -x0\right)\right)}\right) \cdot \sqrt[3]{\log \left(\mathsf{fma}\left({x0}^{\frac{2}{3}}, \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({x0}^{\frac{2}{3}}, \frac{\sqrt[3]{x0}}{1 - x1}, -x0\right)\right)} \cdot \sqrt[3]{\log \left(\mathsf{fma}\left({x0}^{\frac{2}{3}}, \frac{\sqrt[3]{x0}}{1 - x1}, -x0\right)\right)}\right)}\right)}^{\left(\sqrt[3]{\log \left(\mathsf{fma}\left({x0}^{\frac{2}{3}}, \frac{\sqrt[3]{x0}}{1 - x1}, -x0\right)\right)}\right)}}\]

    if 0.00021208908081054686 < x1

    1. Initial program 4.5

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

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

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

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

      \[\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.12089080810546861 \cdot 10^{-4}:\\ \;\;\;\;{\left({e}^{\left(\sqrt[3]{\log \left(\mathsf{fma}\left({x0}^{\frac{2}{3}}, \frac{\sqrt[3]{x0}}{1 - x1}, -x0\right)\right)} \cdot \sqrt[3]{\log \left(\mathsf{fma}\left({x0}^{\frac{2}{3}}, \frac{\sqrt[3]{x0}}{1 - x1}, -x0\right)\right)}\right)}\right)}^{\left(\sqrt[3]{\log \left(\mathsf{fma}\left({x0}^{\frac{2}{3}}, \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 2020047 +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))