Average Error: 7.8 → 0.9
Time: 14.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{\frac{x}{t - z}}{y - z}\\ \mathbf{elif}\;\left(y - z\right) \cdot \left(t - z\right) \le 1.22506240341463963 \cdot 10^{298}:\\ \;\;\;\;\frac{x}{\left(t - z\right) \cdot \left(y - z\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{\frac{t - z}{x}}}{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) = -\infty:\\
\;\;\;\;\frac{\frac{x}{t - z}}{y - z}\\

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

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

\end{array}
double f(double x, double y, double z, double t) {
        double r971894 = x;
        double r971895 = y;
        double r971896 = z;
        double r971897 = r971895 - r971896;
        double r971898 = t;
        double r971899 = r971898 - r971896;
        double r971900 = r971897 * r971899;
        double r971901 = r971894 / r971900;
        return r971901;
}

double f(double x, double y, double z, double t) {
        double r971902 = y;
        double r971903 = z;
        double r971904 = r971902 - r971903;
        double r971905 = t;
        double r971906 = r971905 - r971903;
        double r971907 = r971904 * r971906;
        double r971908 = -inf.0;
        bool r971909 = r971907 <= r971908;
        double r971910 = x;
        double r971911 = r971910 / r971906;
        double r971912 = r971911 / r971904;
        double r971913 = 1.2250624034146396e+298;
        bool r971914 = r971907 <= r971913;
        double r971915 = r971906 * r971904;
        double r971916 = r971910 / r971915;
        double r971917 = 1.0;
        double r971918 = r971906 / r971910;
        double r971919 = r971917 / r971918;
        double r971920 = r971919 / r971904;
        double r971921 = r971914 ? r971916 : r971920;
        double r971922 = r971909 ? r971912 : r971921;
        return r971922;
}

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.8
Target8.6
Herbie0.9
\[\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.1

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

      \[\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 associate-*l/0.1

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

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

    if -inf.0 < (* (- y z) (- t z)) < 1.2250624034146396e+298

    1. Initial program 1.4

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{x}{t - z}}}{y - z}\]
    8. Using strategy rm
    9. Applied div-inv3.5

      \[\leadsto \frac{\color{blue}{x \cdot \frac{1}{t - z}}}{y - z}\]
    10. Applied associate-/l*1.5

      \[\leadsto \color{blue}{\frac{x}{\frac{y - z}{\frac{1}{t - z}}}}\]
    11. Simplified1.4

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

    if 1.2250624034146396e+298 < (* (- y z) (- t z))

    1. Initial program 16.3

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

      \[\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 associate-*l/0.1

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

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

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

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

Reproduce

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