Average Error: 7.9 → 5.5
Time: 3.5s
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 2.9451562499999997:\\ \;\;\;\;\mathsf{fma}\left(\frac{\sqrt{x0}}{\sqrt{1} + \sqrt{x1}}, \frac{\sqrt{x0}}{\sqrt{1} - \sqrt{x1}}, -x0\right)\\ \mathbf{else}:\\ \;\;\;\;e^{\log \left(\log \left(\frac{{\left(e^{{x0}^{\frac{2}{3}}}\right)}^{\left(\frac{\sqrt[3]{x0}}{1 - x1}\right)}}{e^{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{1} + \sqrt{x1}}, \frac{\sqrt{x0}}{\sqrt{1} - \sqrt{x1}}, -x0\right)\\

\mathbf{else}:\\
\;\;\;\;e^{\log \left(\log \left(\frac{{\left(e^{{x0}^{\frac{2}{3}}}\right)}^{\left(\frac{\sqrt[3]{x0}}{1 - x1}\right)}}{e^{x0}}\right)\right)}\\

\end{array}
double f(double x0, double x1) {
        double r134448 = x0;
        double r134449 = 1.0;
        double r134450 = x1;
        double r134451 = r134449 - r134450;
        double r134452 = r134448 / r134451;
        double r134453 = r134452 - r134448;
        return r134453;
}

double f(double x0, double x1) {
        double r134454 = x0;
        double r134455 = 2.9451562499999997;
        bool r134456 = r134454 <= r134455;
        double r134457 = sqrt(r134454);
        double r134458 = 1.0;
        double r134459 = sqrt(r134458);
        double r134460 = x1;
        double r134461 = sqrt(r134460);
        double r134462 = r134459 + r134461;
        double r134463 = r134457 / r134462;
        double r134464 = r134459 - r134461;
        double r134465 = r134457 / r134464;
        double r134466 = -r134454;
        double r134467 = fma(r134463, r134465, r134466);
        double r134468 = 0.6666666666666666;
        double r134469 = pow(r134454, r134468);
        double r134470 = exp(r134469);
        double r134471 = cbrt(r134454);
        double r134472 = r134458 - r134460;
        double r134473 = r134471 / r134472;
        double r134474 = pow(r134470, r134473);
        double r134475 = exp(r134454);
        double r134476 = r134474 / r134475;
        double r134477 = log(r134476);
        double r134478 = log(r134477);
        double r134479 = exp(r134478);
        double r134480 = r134456 ? r134467 : r134479;
        return r134480;
}

Error

Bits error versus x0

Bits error versus x1

Target

Original7.9
Target0.2
Herbie5.5
\[\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 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 2.9451562499999997 < x0

    1. Initial program 8.4

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

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

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

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

      \[\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-log7.2

      \[\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. Using strategy rm
    10. Applied add-log-exp7.6

      \[\leadsto e^{\log \color{blue}{\left(\log \left(e^{\mathsf{fma}\left(\frac{\sqrt[3]{x0} \cdot \sqrt[3]{x0}}{1}, \frac{\sqrt[3]{x0}}{1 - x1}, -x0\right)}\right)\right)}}\]
    11. Simplified5.6

      \[\leadsto e^{\log \left(\log \color{blue}{\left(\frac{{\left(e^{{x0}^{\frac{2}{3}}}\right)}^{\left(\frac{\sqrt[3]{x0}}{1 - x1}\right)}}{e^{x0}}\right)}\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification5.5

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

Reproduce

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