Average Error: 7.8 → 4.4
Time: 4.1s
Precision: 64
\[x0 = 1.854999999999999982236431605997495353222 \land x1 = 2.090000000000000115064208161541614572343 \cdot 10^{-4} \lor x0 = 2.984999999999999875655021241982467472553 \land x1 = 0.01859999999999999847899445626353553961962\]
\[\frac{x0}{1 - x1} - x0\]
\[\begin{array}{l} \mathbf{if}\;x0 \le 1.874921874999999849009668650978710502386:\\ \;\;\;\;\mathsf{fma}\left(\frac{\sqrt{x0}}{\sqrt{1} + \sqrt{x1}}, \frac{\sqrt{x0}}{\sqrt{1} - \sqrt{x1}}, -x0\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{{\left(\log \left(\frac{1}{\sqrt{e^{x0}}}\right)\right)}^{3} + {\left(\mathsf{fma}\left(\frac{\sqrt[3]{x0}}{1 - x1}, {x0}^{\frac{2}{3}}, \log \left(\frac{1}{\sqrt{e^{x0}}}\right)\right)\right)}^{3}}{\mathsf{fma}\left(\frac{\sqrt[3]{x0}}{1 - x1}, {x0}^{\frac{2}{3}}, \log \left(\frac{1}{\sqrt{e^{x0}}}\right)\right) \cdot \left(\frac{\sqrt[3]{x0}}{1 - x1} \cdot {x0}^{\frac{2}{3}}\right) + \log \left(\sqrt{e^{x0}}\right) \cdot \log \left(\sqrt{e^{x0}}\right)}\\ \end{array}\]
\frac{x0}{1 - x1} - x0
\begin{array}{l}
\mathbf{if}\;x0 \le 1.874921874999999849009668650978710502386:\\
\;\;\;\;\mathsf{fma}\left(\frac{\sqrt{x0}}{\sqrt{1} + \sqrt{x1}}, \frac{\sqrt{x0}}{\sqrt{1} - \sqrt{x1}}, -x0\right)\\

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

\end{array}
double f(double x0, double x1) {
        double r163513 = x0;
        double r163514 = 1.0;
        double r163515 = x1;
        double r163516 = r163514 - r163515;
        double r163517 = r163513 / r163516;
        double r163518 = r163517 - r163513;
        return r163518;
}

double f(double x0, double x1) {
        double r163519 = x0;
        double r163520 = 1.8749218749999998;
        bool r163521 = r163519 <= r163520;
        double r163522 = sqrt(r163519);
        double r163523 = 1.0;
        double r163524 = sqrt(r163523);
        double r163525 = x1;
        double r163526 = sqrt(r163525);
        double r163527 = r163524 + r163526;
        double r163528 = r163522 / r163527;
        double r163529 = r163524 - r163526;
        double r163530 = r163522 / r163529;
        double r163531 = -r163519;
        double r163532 = fma(r163528, r163530, r163531);
        double r163533 = 1.0;
        double r163534 = exp(r163519);
        double r163535 = sqrt(r163534);
        double r163536 = r163533 / r163535;
        double r163537 = log(r163536);
        double r163538 = 3.0;
        double r163539 = pow(r163537, r163538);
        double r163540 = cbrt(r163519);
        double r163541 = r163523 - r163525;
        double r163542 = r163540 / r163541;
        double r163543 = 0.6666666666666666;
        double r163544 = pow(r163519, r163543);
        double r163545 = fma(r163542, r163544, r163537);
        double r163546 = pow(r163545, r163538);
        double r163547 = r163539 + r163546;
        double r163548 = r163542 * r163544;
        double r163549 = r163545 * r163548;
        double r163550 = log(r163535);
        double r163551 = r163550 * r163550;
        double r163552 = r163549 + r163551;
        double r163553 = r163547 / r163552;
        double r163554 = r163521 ? r163532 : r163553;
        return r163554;
}

Error

Bits error versus x0

Bits error versus x1

Target

Original7.8
Target0.3
Herbie4.4
\[\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.4

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

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

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

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

      \[\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-log-exp7.5

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

      \[\leadsto \log \color{blue}{\left(\frac{{\left(e^{{x0}^{\frac{2}{3}}}\right)}^{\left(\frac{\sqrt[3]{x0}}{1 - x1}\right)}}{e^{x0}}\right)}\]
    10. Using strategy rm
    11. Applied add-sqr-sqrt6.4

      \[\leadsto \log \left(\frac{{\left(e^{{x0}^{\frac{2}{3}}}\right)}^{\left(\frac{\sqrt[3]{x0}}{1 - x1}\right)}}{\color{blue}{\sqrt{e^{x0}} \cdot \sqrt{e^{x0}}}}\right)\]
    12. Applied *-un-lft-identity6.4

      \[\leadsto \log \left(\frac{{\color{blue}{\left(1 \cdot e^{{x0}^{\frac{2}{3}}}\right)}}^{\left(\frac{\sqrt[3]{x0}}{1 - x1}\right)}}{\sqrt{e^{x0}} \cdot \sqrt{e^{x0}}}\right)\]
    13. Applied unpow-prod-down6.4

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

      \[\leadsto \log \color{blue}{\left(\frac{{1}^{\left(\frac{\sqrt[3]{x0}}{1 - x1}\right)}}{\sqrt{e^{x0}}} \cdot \frac{{\left(e^{{x0}^{\frac{2}{3}}}\right)}^{\left(\frac{\sqrt[3]{x0}}{1 - x1}\right)}}{\sqrt{e^{x0}}}\right)}\]
    15. Applied log-prod5.7

      \[\leadsto \color{blue}{\log \left(\frac{{1}^{\left(\frac{\sqrt[3]{x0}}{1 - x1}\right)}}{\sqrt{e^{x0}}}\right) + \log \left(\frac{{\left(e^{{x0}^{\frac{2}{3}}}\right)}^{\left(\frac{\sqrt[3]{x0}}{1 - x1}\right)}}{\sqrt{e^{x0}}}\right)}\]
    16. Simplified5.7

      \[\leadsto \color{blue}{\log \left(\frac{1}{\sqrt{e^{x0}}}\right)} + \log \left(\frac{{\left(e^{{x0}^{\frac{2}{3}}}\right)}^{\left(\frac{\sqrt[3]{x0}}{1 - x1}\right)}}{\sqrt{e^{x0}}}\right)\]
    17. Simplified5.7

      \[\leadsto \log \left(\frac{1}{\sqrt{e^{x0}}}\right) + \color{blue}{\mathsf{fma}\left(\frac{\sqrt[3]{x0}}{1 - x1}, {x0}^{\frac{2}{3}}, \log \left(\frac{1}{\sqrt{e^{x0}}}\right)\right)}\]
    18. Using strategy rm
    19. Applied flip3-+3.5

      \[\leadsto \color{blue}{\frac{{\left(\log \left(\frac{1}{\sqrt{e^{x0}}}\right)\right)}^{3} + {\left(\mathsf{fma}\left(\frac{\sqrt[3]{x0}}{1 - x1}, {x0}^{\frac{2}{3}}, \log \left(\frac{1}{\sqrt{e^{x0}}}\right)\right)\right)}^{3}}{\log \left(\frac{1}{\sqrt{e^{x0}}}\right) \cdot \log \left(\frac{1}{\sqrt{e^{x0}}}\right) + \left(\mathsf{fma}\left(\frac{\sqrt[3]{x0}}{1 - x1}, {x0}^{\frac{2}{3}}, \log \left(\frac{1}{\sqrt{e^{x0}}}\right)\right) \cdot \mathsf{fma}\left(\frac{\sqrt[3]{x0}}{1 - x1}, {x0}^{\frac{2}{3}}, \log \left(\frac{1}{\sqrt{e^{x0}}}\right)\right) - \log \left(\frac{1}{\sqrt{e^{x0}}}\right) \cdot \mathsf{fma}\left(\frac{\sqrt[3]{x0}}{1 - x1}, {x0}^{\frac{2}{3}}, \log \left(\frac{1}{\sqrt{e^{x0}}}\right)\right)\right)}}\]
    20. Simplified3.5

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

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

Reproduce

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