Average Error: 4.6 → 1.6
Time: 6.0s
Precision: 64
\[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)\]
\[\begin{array}{l} \mathbf{if}\;\frac{y}{z} - \frac{t}{1 - z} \le -1.7719375982154692 \cdot 10^{186} \lor \neg \left(\frac{y}{z} - \frac{t}{1 - z} \le -2.16390322287129159 \cdot 10^{-24} \lor \neg \left(\frac{y}{z} - \frac{t}{1 - z} \le 2.379884009843327 \cdot 10^{-235} \lor \neg \left(\frac{y}{z} - \frac{t}{1 - z} \le 4.61028574925404029 \cdot 10^{228}\right)\right)\right):\\ \;\;\;\;\left(-x\right) \cdot \frac{t}{1 - z} + \frac{x \cdot y}{z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \mathsf{fma}\left(y, \frac{1}{z}, -\frac{t}{1 - z}\right)\\ \end{array}\]
x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)
\begin{array}{l}
\mathbf{if}\;\frac{y}{z} - \frac{t}{1 - z} \le -1.7719375982154692 \cdot 10^{186} \lor \neg \left(\frac{y}{z} - \frac{t}{1 - z} \le -2.16390322287129159 \cdot 10^{-24} \lor \neg \left(\frac{y}{z} - \frac{t}{1 - z} \le 2.379884009843327 \cdot 10^{-235} \lor \neg \left(\frac{y}{z} - \frac{t}{1 - z} \le 4.61028574925404029 \cdot 10^{228}\right)\right)\right):\\
\;\;\;\;\left(-x\right) \cdot \frac{t}{1 - z} + \frac{x \cdot y}{z}\\

\mathbf{else}:\\
\;\;\;\;x \cdot \mathsf{fma}\left(y, \frac{1}{z}, -\frac{t}{1 - z}\right)\\

\end{array}
double f(double x, double y, double z, double t) {
        double r370149 = x;
        double r370150 = y;
        double r370151 = z;
        double r370152 = r370150 / r370151;
        double r370153 = t;
        double r370154 = 1.0;
        double r370155 = r370154 - r370151;
        double r370156 = r370153 / r370155;
        double r370157 = r370152 - r370156;
        double r370158 = r370149 * r370157;
        return r370158;
}

double f(double x, double y, double z, double t) {
        double r370159 = y;
        double r370160 = z;
        double r370161 = r370159 / r370160;
        double r370162 = t;
        double r370163 = 1.0;
        double r370164 = r370163 - r370160;
        double r370165 = r370162 / r370164;
        double r370166 = r370161 - r370165;
        double r370167 = -1.7719375982154692e+186;
        bool r370168 = r370166 <= r370167;
        double r370169 = -2.1639032228712916e-24;
        bool r370170 = r370166 <= r370169;
        double r370171 = 2.379884009843327e-235;
        bool r370172 = r370166 <= r370171;
        double r370173 = 4.61028574925404e+228;
        bool r370174 = r370166 <= r370173;
        double r370175 = !r370174;
        bool r370176 = r370172 || r370175;
        double r370177 = !r370176;
        bool r370178 = r370170 || r370177;
        double r370179 = !r370178;
        bool r370180 = r370168 || r370179;
        double r370181 = x;
        double r370182 = -r370181;
        double r370183 = r370182 * r370165;
        double r370184 = r370181 * r370159;
        double r370185 = r370184 / r370160;
        double r370186 = r370183 + r370185;
        double r370187 = 1.0;
        double r370188 = r370187 / r370160;
        double r370189 = -r370165;
        double r370190 = fma(r370159, r370188, r370189);
        double r370191 = r370181 * r370190;
        double r370192 = r370180 ? r370186 : r370191;
        return r370192;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original4.6
Target4.2
Herbie1.6
\[\begin{array}{l} \mathbf{if}\;x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \lt -7.62322630331204244 \cdot 10^{-196}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - t \cdot \frac{1}{1 - z}\right)\\ \mathbf{elif}\;x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \lt 1.41339449277023022 \cdot 10^{-211}:\\ \;\;\;\;\frac{y \cdot x}{z} + \left(-\frac{t \cdot x}{1 - z}\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - t \cdot \frac{1}{1 - z}\right)\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if (- (/ y z) (/ t (- 1.0 z))) < -1.7719375982154692e+186 or -2.1639032228712916e-24 < (- (/ y z) (/ t (- 1.0 z))) < 2.379884009843327e-235 or 4.61028574925404e+228 < (- (/ y z) (/ t (- 1.0 z)))

    1. Initial program 11.0

      \[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)\]
    2. Using strategy rm
    3. Applied div-inv11.0

      \[\leadsto x \cdot \left(\frac{y}{z} - \color{blue}{t \cdot \frac{1}{1 - z}}\right)\]
    4. Using strategy rm
    5. Applied sub-neg11.0

      \[\leadsto x \cdot \color{blue}{\left(\frac{y}{z} + \left(-t \cdot \frac{1}{1 - z}\right)\right)}\]
    6. Applied distribute-lft-in11.0

      \[\leadsto \color{blue}{x \cdot \frac{y}{z} + x \cdot \left(-t \cdot \frac{1}{1 - z}\right)}\]
    7. Simplified11.0

      \[\leadsto x \cdot \frac{y}{z} + \color{blue}{\left(-x\right) \cdot \frac{t}{1 - z}}\]
    8. Using strategy rm
    9. Applied *-un-lft-identity11.0

      \[\leadsto x \cdot \frac{y}{\color{blue}{1 \cdot z}} + \left(-x\right) \cdot \frac{t}{1 - z}\]
    10. Applied add-cube-cbrt11.4

      \[\leadsto x \cdot \frac{\color{blue}{\left(\sqrt[3]{y} \cdot \sqrt[3]{y}\right) \cdot \sqrt[3]{y}}}{1 \cdot z} + \left(-x\right) \cdot \frac{t}{1 - z}\]
    11. Applied times-frac11.4

      \[\leadsto x \cdot \color{blue}{\left(\frac{\sqrt[3]{y} \cdot \sqrt[3]{y}}{1} \cdot \frac{\sqrt[3]{y}}{z}\right)} + \left(-x\right) \cdot \frac{t}{1 - z}\]
    12. Applied associate-*r*5.1

      \[\leadsto \color{blue}{\left(x \cdot \frac{\sqrt[3]{y} \cdot \sqrt[3]{y}}{1}\right) \cdot \frac{\sqrt[3]{y}}{z}} + \left(-x\right) \cdot \frac{t}{1 - z}\]
    13. Simplified5.1

      \[\leadsto \color{blue}{\left(\left(\sqrt[3]{y} \cdot \sqrt[3]{y}\right) \cdot x\right)} \cdot \frac{\sqrt[3]{y}}{z} + \left(-x\right) \cdot \frac{t}{1 - z}\]
    14. Using strategy rm
    15. Applied pow15.1

      \[\leadsto \left(\left(\sqrt[3]{y} \cdot \sqrt[3]{y}\right) \cdot x\right) \cdot \color{blue}{{\left(\frac{\sqrt[3]{y}}{z}\right)}^{1}} + \left(-x\right) \cdot \frac{t}{1 - z}\]
    16. Applied pow15.1

      \[\leadsto \left(\left(\sqrt[3]{y} \cdot \sqrt[3]{y}\right) \cdot \color{blue}{{x}^{1}}\right) \cdot {\left(\frac{\sqrt[3]{y}}{z}\right)}^{1} + \left(-x\right) \cdot \frac{t}{1 - z}\]
    17. Applied pow15.1

      \[\leadsto \left(\left(\sqrt[3]{y} \cdot \color{blue}{{\left(\sqrt[3]{y}\right)}^{1}}\right) \cdot {x}^{1}\right) \cdot {\left(\frac{\sqrt[3]{y}}{z}\right)}^{1} + \left(-x\right) \cdot \frac{t}{1 - z}\]
    18. Applied pow15.1

      \[\leadsto \left(\left(\color{blue}{{\left(\sqrt[3]{y}\right)}^{1}} \cdot {\left(\sqrt[3]{y}\right)}^{1}\right) \cdot {x}^{1}\right) \cdot {\left(\frac{\sqrt[3]{y}}{z}\right)}^{1} + \left(-x\right) \cdot \frac{t}{1 - z}\]
    19. Applied pow-prod-down5.1

      \[\leadsto \left(\color{blue}{{\left(\sqrt[3]{y} \cdot \sqrt[3]{y}\right)}^{1}} \cdot {x}^{1}\right) \cdot {\left(\frac{\sqrt[3]{y}}{z}\right)}^{1} + \left(-x\right) \cdot \frac{t}{1 - z}\]
    20. Applied pow-prod-down5.1

      \[\leadsto \color{blue}{{\left(\left(\sqrt[3]{y} \cdot \sqrt[3]{y}\right) \cdot x\right)}^{1}} \cdot {\left(\frac{\sqrt[3]{y}}{z}\right)}^{1} + \left(-x\right) \cdot \frac{t}{1 - z}\]
    21. Applied pow-prod-down5.1

      \[\leadsto \color{blue}{{\left(\left(\left(\sqrt[3]{y} \cdot \sqrt[3]{y}\right) \cdot x\right) \cdot \frac{\sqrt[3]{y}}{z}\right)}^{1}} + \left(-x\right) \cdot \frac{t}{1 - z}\]
    22. Simplified3.6

      \[\leadsto {\color{blue}{\left(\frac{x \cdot y}{z}\right)}}^{1} + \left(-x\right) \cdot \frac{t}{1 - z}\]

    if -1.7719375982154692e+186 < (- (/ y z) (/ t (- 1.0 z))) < -2.1639032228712916e-24 or 2.379884009843327e-235 < (- (/ y z) (/ t (- 1.0 z))) < 4.61028574925404e+228

    1. Initial program 0.2

      \[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)\]
    2. Using strategy rm
    3. Applied div-inv0.3

      \[\leadsto x \cdot \left(\color{blue}{y \cdot \frac{1}{z}} - \frac{t}{1 - z}\right)\]
    4. Applied fma-neg0.3

      \[\leadsto x \cdot \color{blue}{\mathsf{fma}\left(y, \frac{1}{z}, -\frac{t}{1 - z}\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification1.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y}{z} - \frac{t}{1 - z} \le -1.7719375982154692 \cdot 10^{186} \lor \neg \left(\frac{y}{z} - \frac{t}{1 - z} \le -2.16390322287129159 \cdot 10^{-24} \lor \neg \left(\frac{y}{z} - \frac{t}{1 - z} \le 2.379884009843327 \cdot 10^{-235} \lor \neg \left(\frac{y}{z} - \frac{t}{1 - z} \le 4.61028574925404029 \cdot 10^{228}\right)\right)\right):\\ \;\;\;\;\left(-x\right) \cdot \frac{t}{1 - z} + \frac{x \cdot y}{z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \mathsf{fma}\left(y, \frac{1}{z}, -\frac{t}{1 - z}\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2020057 +o rules:numerics
(FPCore (x y z t)
  :name "Numeric.SpecFunctions:invIncompleteBetaWorker from math-functions-0.1.5.2, C"
  :precision binary64

  :herbie-target
  (if (< (* x (- (/ y z) (/ t (- 1 z)))) -7.623226303312042e-196) (* x (- (/ y z) (* t (/ 1 (- 1 z))))) (if (< (* x (- (/ y z) (/ t (- 1 z)))) 1.4133944927702302e-211) (+ (/ (* y x) z) (- (/ (* t x) (- 1 z)))) (* x (- (/ y z) (* t (/ 1 (- 1 z)))))))

  (* x (- (/ y z) (/ t (- 1 z)))))