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}:\\ \;\;\;\;{e}^{\left(2 \cdot \log \left(\sqrt[3]{\mathsf{fma}\left({x0}^{\frac{2}{3}}, \frac{\sqrt[3]{x0}}{1 - x1}, -x0\right)}\right)\right)} \cdot {e}^{\left(\log \left(\sqrt[3]{\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}:\\
\;\;\;\;{e}^{\left(2 \cdot \log \left(\sqrt[3]{\mathsf{fma}\left({x0}^{\frac{2}{3}}, \frac{\sqrt[3]{x0}}{1 - x1}, -x0\right)}\right)\right)} \cdot {e}^{\left(\log \left(\sqrt[3]{\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 r317531 = x0;
        double r317532 = 1.0;
        double r317533 = x1;
        double r317534 = r317532 - r317533;
        double r317535 = r317531 / r317534;
        double r317536 = r317535 - r317531;
        return r317536;
}

double f(double x0, double x1) {
        double r317537 = x1;
        double r317538 = 0.00021208908081054686;
        bool r317539 = r317537 <= r317538;
        double r317540 = exp(1.0);
        double r317541 = 2.0;
        double r317542 = x0;
        double r317543 = 0.6666666666666666;
        double r317544 = pow(r317542, r317543);
        double r317545 = cbrt(r317542);
        double r317546 = 1.0;
        double r317547 = r317546 - r317537;
        double r317548 = r317545 / r317547;
        double r317549 = -r317542;
        double r317550 = fma(r317544, r317548, r317549);
        double r317551 = cbrt(r317550);
        double r317552 = log(r317551);
        double r317553 = r317541 * r317552;
        double r317554 = pow(r317540, r317553);
        double r317555 = pow(r317540, r317552);
        double r317556 = r317554 * r317555;
        double r317557 = sqrt(r317542);
        double r317558 = sqrt(r317546);
        double r317559 = sqrt(r317537);
        double r317560 = r317558 + r317559;
        double r317561 = r317557 / r317560;
        double r317562 = r317558 - r317559;
        double r317563 = r317557 / r317562;
        double r317564 = fma(r317561, r317563, r317549);
        double r317565 = r317539 ? r317556 : r317564;
        return r317565;
}

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

      \[\leadsto {e}^{\color{blue}{\left(\log \left(\sqrt[3]{\mathsf{fma}\left({x0}^{\frac{2}{3}}, \frac{\sqrt[3]{x0}}{1 - x1}, -x0\right)} \cdot \sqrt[3]{\mathsf{fma}\left({x0}^{\frac{2}{3}}, \frac{\sqrt[3]{x0}}{1 - x1}, -x0\right)}\right) + \log \left(\sqrt[3]{\mathsf{fma}\left({x0}^{\frac{2}{3}}, \frac{\sqrt[3]{x0}}{1 - x1}, -x0\right)}\right)\right)}}\]
    18. Applied unpow-prod-up8.9

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

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

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