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

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

\end{array}
double f(double x0, double x1) {
        double r3981464 = x0;
        double r3981465 = 1.0;
        double r3981466 = x1;
        double r3981467 = r3981465 - r3981466;
        double r3981468 = r3981464 / r3981467;
        double r3981469 = r3981468 - r3981464;
        return r3981469;
}

double f(double x0, double x1) {
        double r3981470 = x1;
        double r3981471 = 0.018204597656249998;
        bool r3981472 = r3981470 <= r3981471;
        double r3981473 = x0;
        double r3981474 = cbrt(r3981473);
        double r3981475 = r3981474 * r3981474;
        double r3981476 = 1.0;
        double r3981477 = r3981476 - r3981470;
        double r3981478 = r3981474 / r3981477;
        double r3981479 = -r3981473;
        double r3981480 = fma(r3981475, r3981478, r3981479);
        double r3981481 = sqrt(r3981473);
        double r3981482 = sqrt(r3981470);
        double r3981483 = r3981476 + r3981482;
        double r3981484 = r3981481 / r3981483;
        double r3981485 = r3981476 - r3981482;
        double r3981486 = r3981481 / r3981485;
        double r3981487 = fma(r3981484, r3981486, r3981479);
        double r3981488 = r3981472 ? r3981480 : r3981487;
        return r3981488;
}

Error

Bits error versus x0

Bits error versus x1

Target

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

Derivation

  1. Split input into 2 regimes
  2. if x1 < 0.018204597656249998

    1. Initial program 11.2

      \[\frac{x0}{1 - x1} - x0\]
    2. Using strategy rm
    3. Applied *-un-lft-identity11.2

      \[\leadsto \frac{x0}{1 - \color{blue}{1 \cdot x1}} - x0\]
    4. Applied *-un-lft-identity11.2

      \[\leadsto \frac{x0}{\color{blue}{1 \cdot 1} - 1 \cdot x1} - x0\]
    5. Applied distribute-lft-out--11.2

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

      \[\leadsto \color{blue}{\frac{\sqrt[3]{x0} \cdot \sqrt[3]{x0}}{1} \cdot \frac{\sqrt[3]{x0}}{1 - x1}} - x0\]
    8. 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)}\]

    if 0.018204597656249998 < 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 *-un-lft-identity4.5

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

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

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

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

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

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

Reproduce

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