Average Error: 7.9 → 6.2
Time: 17.3s
Precision: 64
\[x0 = 1.855 \land x1 = 0.000209 \lor x0 = 2.985 \land x1 = 0.0186\]
\[\frac{x0}{1 - x1} - x0\]
\[\begin{array}{l} \mathbf{if}\;x0 \le 2.3076562499999995:\\ \;\;\;\;\mathsf{fma}\left(\frac{\sqrt{x0}}{\sqrt{x1} + 1}, \frac{\sqrt{x0}}{1 - \sqrt{x1}}, -x0\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt[3]{\mathsf{fma}\left(\frac{\sqrt[3]{x0} \cdot \sqrt[3]{x0}}{\sqrt{x1} + 1}, \frac{\sqrt[3]{x0}}{1 - \sqrt{x1}}, -x0\right)} \cdot \left(\sqrt[3]{\mathsf{fma}\left(\frac{\sqrt[3]{x0} \cdot \sqrt[3]{x0}}{\sqrt{x1} + 1}, \frac{\sqrt[3]{x0}}{1 - \sqrt{x1}}, -x0\right)} \cdot \sqrt[3]{\mathsf{fma}\left(\frac{\sqrt[3]{x0} \cdot \sqrt[3]{x0}}{\sqrt{x1} + 1}, \frac{\sqrt[3]{x0}}{1 - \sqrt{x1}}, -x0\right)}\right)\\ \end{array}\]
\frac{x0}{1 - x1} - x0
\begin{array}{l}
\mathbf{if}\;x0 \le 2.3076562499999995:\\
\;\;\;\;\mathsf{fma}\left(\frac{\sqrt{x0}}{\sqrt{x1} + 1}, \frac{\sqrt{x0}}{1 - \sqrt{x1}}, -x0\right)\\

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

\end{array}
double f(double x0, double x1) {
        double r5600000 = x0;
        double r5600001 = 1.0;
        double r5600002 = x1;
        double r5600003 = r5600001 - r5600002;
        double r5600004 = r5600000 / r5600003;
        double r5600005 = r5600004 - r5600000;
        return r5600005;
}

double f(double x0, double x1) {
        double r5600006 = x0;
        double r5600007 = 2.3076562499999995;
        bool r5600008 = r5600006 <= r5600007;
        double r5600009 = sqrt(r5600006);
        double r5600010 = x1;
        double r5600011 = sqrt(r5600010);
        double r5600012 = 1.0;
        double r5600013 = r5600011 + r5600012;
        double r5600014 = r5600009 / r5600013;
        double r5600015 = r5600012 - r5600011;
        double r5600016 = r5600009 / r5600015;
        double r5600017 = -r5600006;
        double r5600018 = fma(r5600014, r5600016, r5600017);
        double r5600019 = cbrt(r5600006);
        double r5600020 = r5600019 * r5600019;
        double r5600021 = r5600020 / r5600013;
        double r5600022 = r5600019 / r5600015;
        double r5600023 = fma(r5600021, r5600022, r5600017);
        double r5600024 = cbrt(r5600023);
        double r5600025 = r5600024 * r5600024;
        double r5600026 = r5600024 * r5600025;
        double r5600027 = r5600008 ? r5600018 : r5600026;
        return r5600027;
}

Error

Bits error versus x0

Bits error versus x1

Target

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

Derivation

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

    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 *-un-lft-identity7.4

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

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

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

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

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

    if 2.3076562499999995 < 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 *-un-lft-identity8.3

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

      \[\leadsto \frac{x0}{\color{blue}{\left(1 + \sqrt{x1}\right) \cdot \left(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(1 + \sqrt{x1}\right) \cdot \left(1 - \sqrt{x1}\right)} - x0\]
    7. Applied times-frac8.2

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{\sqrt[3]{x0} \cdot \sqrt[3]{x0}}{1 + \sqrt{x1}}, \frac{\sqrt[3]{x0}}{1 - \sqrt{x1}}, -x0\right)}\]
    9. Using strategy rm
    10. Applied add-cube-cbrt7.0

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

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

Reproduce

herbie shell --seed 2019141 +o rules:numerics
(FPCore (x0 x1)
  :name "(- (/ x0 (- 1 x1)) x0)"
  :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))