Average Error: 7.1 → 1.1
Time: 3.5s
Precision: 64
\[\frac{x}{\left(y - z\right) \cdot \left(t - z\right)}\]
\[\begin{array}{l} \mathbf{if}\;\left(y - z\right) \cdot \left(t - z\right) = -\infty:\\ \;\;\;\;\frac{1}{y - z} \cdot \frac{1}{\frac{t - z}{x}}\\ \mathbf{elif}\;\left(y - z\right) \cdot \left(t - z\right) \le -1.173720323052323956659235148309787539083 \cdot 10^{-94}:\\ \;\;\;\;\frac{x}{\left(y - z\right) \cdot \left(t - z\right)}\\ \mathbf{else}:\\ \;\;\;\;{\left(\frac{\frac{x}{t - z}}{y - z}\right)}^{1}\\ \end{array}\]
\frac{x}{\left(y - z\right) \cdot \left(t - z\right)}
\begin{array}{l}
\mathbf{if}\;\left(y - z\right) \cdot \left(t - z\right) = -\infty:\\
\;\;\;\;\frac{1}{y - z} \cdot \frac{1}{\frac{t - z}{x}}\\

\mathbf{elif}\;\left(y - z\right) \cdot \left(t - z\right) \le -1.173720323052323956659235148309787539083 \cdot 10^{-94}:\\
\;\;\;\;\frac{x}{\left(y - z\right) \cdot \left(t - z\right)}\\

\mathbf{else}:\\
\;\;\;\;{\left(\frac{\frac{x}{t - z}}{y - z}\right)}^{1}\\

\end{array}
double f(double x, double y, double z, double t) {
        double r788323 = x;
        double r788324 = y;
        double r788325 = z;
        double r788326 = r788324 - r788325;
        double r788327 = t;
        double r788328 = r788327 - r788325;
        double r788329 = r788326 * r788328;
        double r788330 = r788323 / r788329;
        return r788330;
}

double f(double x, double y, double z, double t) {
        double r788331 = y;
        double r788332 = z;
        double r788333 = r788331 - r788332;
        double r788334 = t;
        double r788335 = r788334 - r788332;
        double r788336 = r788333 * r788335;
        double r788337 = -inf.0;
        bool r788338 = r788336 <= r788337;
        double r788339 = 1.0;
        double r788340 = r788339 / r788333;
        double r788341 = x;
        double r788342 = r788335 / r788341;
        double r788343 = r788339 / r788342;
        double r788344 = r788340 * r788343;
        double r788345 = -1.173720323052324e-94;
        bool r788346 = r788336 <= r788345;
        double r788347 = r788341 / r788336;
        double r788348 = r788341 / r788335;
        double r788349 = r788348 / r788333;
        double r788350 = pow(r788349, r788339);
        double r788351 = r788346 ? r788347 : r788350;
        double r788352 = r788338 ? r788344 : r788351;
        return r788352;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original7.1
Target7.9
Herbie1.1
\[\begin{array}{l} \mathbf{if}\;\frac{x}{\left(y - z\right) \cdot \left(t - z\right)} \lt 0.0:\\ \;\;\;\;\frac{\frac{x}{y - z}}{t - z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{1}{\left(y - z\right) \cdot \left(t - z\right)}\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if (* (- y z) (- t z)) < -inf.0

    1. Initial program 19.0

      \[\frac{x}{\left(y - z\right) \cdot \left(t - z\right)}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity19.0

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

      \[\leadsto \color{blue}{\frac{1}{y - z} \cdot \frac{x}{t - z}}\]
    5. Using strategy rm
    6. Applied clear-num0.1

      \[\leadsto \frac{1}{y - z} \cdot \color{blue}{\frac{1}{\frac{t - z}{x}}}\]

    if -inf.0 < (* (- y z) (- t z)) < -1.173720323052324e-94

    1. Initial program 0.2

      \[\frac{x}{\left(y - z\right) \cdot \left(t - z\right)}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity0.2

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

      \[\leadsto \color{blue}{\frac{1}{y - z} \cdot \frac{x}{t - z}}\]
    5. Using strategy rm
    6. Applied frac-times0.2

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

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

    if -1.173720323052324e-94 < (* (- y z) (- t z))

    1. Initial program 7.5

      \[\frac{x}{\left(y - z\right) \cdot \left(t - z\right)}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity7.5

      \[\leadsto \frac{\color{blue}{1 \cdot x}}{\left(y - z\right) \cdot \left(t - z\right)}\]
    4. Applied times-frac1.6

      \[\leadsto \color{blue}{\frac{1}{y - z} \cdot \frac{x}{t - z}}\]
    5. Using strategy rm
    6. Applied pow11.6

      \[\leadsto \frac{1}{y - z} \cdot \color{blue}{{\left(\frac{x}{t - z}\right)}^{1}}\]
    7. Applied pow11.6

      \[\leadsto \color{blue}{{\left(\frac{1}{y - z}\right)}^{1}} \cdot {\left(\frac{x}{t - z}\right)}^{1}\]
    8. Applied pow-prod-down1.6

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(y - z\right) \cdot \left(t - z\right) = -\infty:\\ \;\;\;\;\frac{1}{y - z} \cdot \frac{1}{\frac{t - z}{x}}\\ \mathbf{elif}\;\left(y - z\right) \cdot \left(t - z\right) \le -1.173720323052323956659235148309787539083 \cdot 10^{-94}:\\ \;\;\;\;\frac{x}{\left(y - z\right) \cdot \left(t - z\right)}\\ \mathbf{else}:\\ \;\;\;\;{\left(\frac{\frac{x}{t - z}}{y - z}\right)}^{1}\\ \end{array}\]

Reproduce

herbie shell --seed 2020001 +o rules:numerics
(FPCore (x y z t)
  :name "Data.Random.Distribution.Triangular:triangularCDF from random-fu-0.2.6.2, B"
  :precision binary64

  :herbie-target
  (if (< (/ x (* (- y z) (- t z))) 0.0) (/ (/ x (- y z)) (- t z)) (* x (/ 1 (* (- y z) (- t z)))))

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