Average Error: 7.5 → 1.3
Time: 13.8s
Precision: 64
\[\frac{x}{\left(y - z\right) \cdot \left(t - z\right)}\]
\[\begin{array}{l} \mathbf{if}\;\frac{x}{\left(y - z\right) \cdot \left(t - z\right)} \le 0.0:\\ \;\;\;\;\frac{1}{y - z} \cdot \frac{x}{t - z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\left(y - z\right) \cdot \left(t - z\right)}\\ \end{array}\]
\frac{x}{\left(y - z\right) \cdot \left(t - z\right)}
\begin{array}{l}
\mathbf{if}\;\frac{x}{\left(y - z\right) \cdot \left(t - z\right)} \le 0.0:\\
\;\;\;\;\frac{1}{y - z} \cdot \frac{x}{t - z}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r621942 = x;
        double r621943 = y;
        double r621944 = z;
        double r621945 = r621943 - r621944;
        double r621946 = t;
        double r621947 = r621946 - r621944;
        double r621948 = r621945 * r621947;
        double r621949 = r621942 / r621948;
        return r621949;
}

double f(double x, double y, double z, double t) {
        double r621950 = x;
        double r621951 = y;
        double r621952 = z;
        double r621953 = r621951 - r621952;
        double r621954 = t;
        double r621955 = r621954 - r621952;
        double r621956 = r621953 * r621955;
        double r621957 = r621950 / r621956;
        double r621958 = 0.0;
        bool r621959 = r621957 <= r621958;
        double r621960 = 1.0;
        double r621961 = r621960 / r621953;
        double r621962 = r621950 / r621955;
        double r621963 = r621961 * r621962;
        double r621964 = r621959 ? r621963 : r621957;
        return r621964;
}

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.5
Target8.4
Herbie1.3
\[\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 2 regimes
  2. if (/ x (* (- y z) (- t z))) < 0.0

    1. Initial program 7.7

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

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

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

    if 0.0 < (/ x (* (- y z) (- t z)))

    1. Initial program 7.3

      \[\frac{x}{\left(y - z\right) \cdot \left(t - z\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification1.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x}{\left(y - z\right) \cdot \left(t - z\right)} \le 0.0:\\ \;\;\;\;\frac{1}{y - z} \cdot \frac{x}{t - z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\left(y - z\right) \cdot \left(t - z\right)}\\ \end{array}\]

Reproduce

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

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

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