Average Error: 7.0 → 2.0
Time: 5.6s
Precision: binary64
\[[y, t] = \mathsf{sort}([y, t]) \\]
\[\frac{x}{\left(y - z\right) \cdot \left(t - z\right)} \]
\[\begin{array}{l} \mathbf{if}\;x \leq -2.0212189911353896 \cdot 10^{-50}:\\ \;\;\;\;\frac{\frac{x}{y - z}}{t - z}\\ \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}\;x \leq -2.0212189911353896 \cdot 10^{-50}:\\
\;\;\;\;\frac{\frac{x}{y - z}}{t - z}\\

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


\end{array}
(FPCore (x y z t) :precision binary64 (/ x (* (- y z) (- t z))))
(FPCore (x y z t)
 :precision binary64
 (if (<= x -2.0212189911353896e-50)
   (/ (/ x (- y z)) (- t z))
   (/ (/ x (- t z)) (- y z))))
double code(double x, double y, double z, double t) {
	return x / ((y - z) * (t - z));
}
double code(double x, double y, double z, double t) {
	double tmp;
	if (x <= -2.0212189911353896e-50) {
		tmp = (x / (y - z)) / (t - z);
	} else {
		tmp = (x / (t - z)) / (y - z);
	}
	return tmp;
}

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.0
Target7.8
Herbie2.0
\[\begin{array}{l} \mathbf{if}\;\frac{x}{\left(y - z\right) \cdot \left(t - z\right)} < 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 < -2.0212189911353896e-50

    1. Initial program 11.6

      \[\frac{x}{\left(y - z\right) \cdot \left(t - z\right)} \]
    2. Applied egg-rr2.3

      \[\leadsto \color{blue}{\frac{1}{y - z} \cdot \frac{x}{t - z}} \]
    3. Applied egg-rr2.0

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

    if -2.0212189911353896e-50 < x

    1. Initial program 5.3

      \[\frac{x}{\left(y - z\right) \cdot \left(t - z\right)} \]
    2. Applied egg-rr2.0

      \[\leadsto \color{blue}{\frac{1}{y - z} \cdot \frac{x}{t - z}} \]
    3. Applied egg-rr2.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.0212189911353896 \cdot 10^{-50}:\\ \;\;\;\;\frac{\frac{x}{y - z}}{t - z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{t - z}}{y - z}\\ \end{array} \]

Reproduce

herbie shell --seed 2022130 
(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.0 (* (- y z) (- t z)))))

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