Average Error: 7.2 → 0.8
Time: 16.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) \le -3.818540540467079267699977309316411928156 \cdot 10^{275}:\\ \;\;\;\;\frac{x \cdot \frac{1}{y - z}}{t - z}\\ \mathbf{elif}\;\left(y - z\right) \cdot \left(t - z\right) \le 3.342850604960242252109859433923772722235 \cdot 10^{212}:\\ \;\;\;\;\frac{x}{\left(y - z\right) \cdot \left(t - z\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{t - z}}{y - z}\\ \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) \le -3.818540540467079267699977309316411928156 \cdot 10^{275}:\\
\;\;\;\;\frac{x \cdot \frac{1}{y - z}}{t - z}\\

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

\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{t - z}}{y - z}\\

\end{array}
double f(double x, double y, double z, double t) {
        double r537647 = x;
        double r537648 = y;
        double r537649 = z;
        double r537650 = r537648 - r537649;
        double r537651 = t;
        double r537652 = r537651 - r537649;
        double r537653 = r537650 * r537652;
        double r537654 = r537647 / r537653;
        return r537654;
}

double f(double x, double y, double z, double t) {
        double r537655 = y;
        double r537656 = z;
        double r537657 = r537655 - r537656;
        double r537658 = t;
        double r537659 = r537658 - r537656;
        double r537660 = r537657 * r537659;
        double r537661 = -3.818540540467079e+275;
        bool r537662 = r537660 <= r537661;
        double r537663 = x;
        double r537664 = 1.0;
        double r537665 = r537664 / r537657;
        double r537666 = r537663 * r537665;
        double r537667 = r537666 / r537659;
        double r537668 = 3.3428506049602423e+212;
        bool r537669 = r537660 <= r537668;
        double r537670 = r537663 / r537660;
        double r537671 = r537663 / r537659;
        double r537672 = r537671 / r537657;
        double r537673 = r537669 ? r537670 : r537672;
        double r537674 = r537662 ? r537667 : r537673;
        return r537674;
}

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.2
Target8.1
Herbie0.8
\[\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)) < -3.818540540467079e+275

    1. Initial program 16.6

      \[\frac{x}{\left(y - z\right) \cdot \left(t - z\right)}\]
    2. Using strategy rm
    3. Applied associate-/r*0.1

      \[\leadsto \color{blue}{\frac{\frac{x}{y - z}}{t - z}}\]
    4. Using strategy rm
    5. Applied div-inv0.1

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

    if -3.818540540467079e+275 < (* (- y z) (- t z)) < 3.3428506049602423e+212

    1. Initial program 1.6

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

    if 3.3428506049602423e+212 < (* (- y z) (- t z))

    1. Initial program 11.6

      \[\frac{x}{\left(y - z\right) \cdot \left(t - z\right)}\]
    2. Using strategy rm
    3. Applied associate-/r*0.2

      \[\leadsto \color{blue}{\frac{\frac{x}{y - z}}{t - z}}\]
    4. Using strategy rm
    5. Applied div-inv0.3

      \[\leadsto \color{blue}{\frac{x}{y - z} \cdot \frac{1}{t - z}}\]
    6. Using strategy rm
    7. Applied associate-*l/0.2

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

      \[\leadsto \frac{\color{blue}{\frac{x}{t - z}}}{y - z}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(y - z\right) \cdot \left(t - z\right) \le -3.818540540467079267699977309316411928156 \cdot 10^{275}:\\ \;\;\;\;\frac{x \cdot \frac{1}{y - z}}{t - z}\\ \mathbf{elif}\;\left(y - z\right) \cdot \left(t - z\right) \le 3.342850604960242252109859433923772722235 \cdot 10^{212}:\\ \;\;\;\;\frac{x}{\left(y - z\right) \cdot \left(t - z\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{t - z}}{y - z}\\ \end{array}\]

Reproduce

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