Average Error: 7.9 → 6.2
Time: 21.2s
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.9451562499999997:\\ \;\;\;\;\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.9451562499999997:\\
\;\;\;\;\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 r5859011 = x0;
        double r5859012 = 1.0;
        double r5859013 = x1;
        double r5859014 = r5859012 - r5859013;
        double r5859015 = r5859011 / r5859014;
        double r5859016 = r5859015 - r5859011;
        return r5859016;
}

double f(double x0, double x1) {
        double r5859017 = x0;
        double r5859018 = 2.9451562499999997;
        bool r5859019 = r5859017 <= r5859018;
        double r5859020 = sqrt(r5859017);
        double r5859021 = x1;
        double r5859022 = sqrt(r5859021);
        double r5859023 = 1.0;
        double r5859024 = r5859022 + r5859023;
        double r5859025 = r5859020 / r5859024;
        double r5859026 = r5859023 - r5859022;
        double r5859027 = r5859020 / r5859026;
        double r5859028 = -r5859017;
        double r5859029 = fma(r5859025, r5859027, r5859028);
        double r5859030 = cbrt(r5859017);
        double r5859031 = r5859030 * r5859030;
        double r5859032 = r5859031 / r5859024;
        double r5859033 = r5859030 / r5859026;
        double r5859034 = fma(r5859032, r5859033, r5859028);
        double r5859035 = cbrt(r5859034);
        double r5859036 = r5859035 * r5859035;
        double r5859037 = r5859035 * r5859036;
        double r5859038 = r5859019 ? r5859029 : r5859037;
        return r5859038;
}

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.9451562499999997

    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.4

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

    if 2.9451562499999997 < 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.9451562499999997:\\ \;\;\;\;\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 2019142 +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))