Average Error: 7.8 → 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}\;x0 \le 1.87492187499999985:\\ \;\;\;\;\mathsf{fma}\left(\frac{\sqrt{x0}}{\sqrt{1} + \sqrt{x1}}, \frac{\sqrt{x0}}{\sqrt{1} - \sqrt{x1}}, -x0\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{\sqrt[3]{x0} \cdot \sqrt[3]{x0}}{\sqrt{1} + \sqrt{x1}}, \frac{\sqrt[3]{x0}}{\sqrt{1} - \sqrt{x1}}, -x0\right)\\ \end{array}\]
\frac{x0}{1 - x1} - x0
\begin{array}{l}
\mathbf{if}\;x0 \le 1.87492187499999985:\\
\;\;\;\;\mathsf{fma}\left(\frac{\sqrt{x0}}{\sqrt{1} + \sqrt{x1}}, \frac{\sqrt{x0}}{\sqrt{1} - \sqrt{x1}}, -x0\right)\\

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

\end{array}
double f(double x0, double x1) {
        double r344603 = x0;
        double r344604 = 1.0;
        double r344605 = x1;
        double r344606 = r344604 - r344605;
        double r344607 = r344603 / r344606;
        double r344608 = r344607 - r344603;
        return r344608;
}

double f(double x0, double x1) {
        double r344609 = x0;
        double r344610 = 1.8749218749999998;
        bool r344611 = r344609 <= r344610;
        double r344612 = sqrt(r344609);
        double r344613 = 1.0;
        double r344614 = sqrt(r344613);
        double r344615 = x1;
        double r344616 = sqrt(r344615);
        double r344617 = r344614 + r344616;
        double r344618 = r344612 / r344617;
        double r344619 = r344614 - r344616;
        double r344620 = r344612 / r344619;
        double r344621 = -r344609;
        double r344622 = fma(r344618, r344620, r344621);
        double r344623 = cbrt(r344609);
        double r344624 = r344623 * r344623;
        double r344625 = r344624 / r344617;
        double r344626 = r344623 / r344619;
        double r344627 = fma(r344625, r344626, r344621);
        double r344628 = r344611 ? r344622 : r344627;
        return r344628;
}

Error

Bits error versus x0

Bits error versus x1

Target

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

Derivation

  1. Split input into 2 regimes
  2. if x0 < 1.8749218749999998

    1. Initial program 7.4

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

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

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

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

      \[\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-frac7.4

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{\sqrt{x0}}{\sqrt{1} + \sqrt{x1}}, \frac{\sqrt{x0}}{\sqrt{1} - \sqrt{x1}}, -x0\right)}\]

    if 1.8749218749999998 < x0

    1. Initial program 8.3

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

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

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

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

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

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

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

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

Reproduce

herbie shell --seed 2020045 +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))