Average Error: 7.3 → 1.3
Time: 5.4s
Precision: binary64
\[[y, t] = \mathsf{sort}([y, t]) \\]
\[\frac{x}{\left(y - z\right) \cdot \left(t - z\right)} \]
\[\begin{array}{l} t_1 := \left(y - z\right) \cdot \left(t - z\right)\\ \mathbf{if}\;t_1 \leq -1.1139773717897069 \cdot 10^{+73}:\\ \;\;\;\;\frac{\frac{x}{y - z}}{t - z}\\ \mathbf{elif}\;t_1 \leq 3.615670797450081 \cdot 10^{+109}:\\ \;\;\;\;\frac{x}{\left({z}^{2} + y \cdot t\right) - \left(y \cdot z + z \cdot t\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}
t_1 := \left(y - z\right) \cdot \left(t - z\right)\\
\mathbf{if}\;t_1 \leq -1.1139773717897069 \cdot 10^{+73}:\\
\;\;\;\;\frac{\frac{x}{y - z}}{t - z}\\

\mathbf{elif}\;t_1 \leq 3.615670797450081 \cdot 10^{+109}:\\
\;\;\;\;\frac{x}{\left({z}^{2} + y \cdot t\right) - \left(y \cdot z + z \cdot t\right)}\\

\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
 (let* ((t_1 (* (- y z) (- t z))))
   (if (<= t_1 -1.1139773717897069e+73)
     (/ (/ x (- y z)) (- t z))
     (if (<= t_1 3.615670797450081e+109)
       (/ x (- (+ (pow z 2.0) (* y t)) (+ (* y z) (* z t))))
       (/ (/ 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 t_1 = (y - z) * (t - z);
	double tmp;
	if (t_1 <= -1.1139773717897069e+73) {
		tmp = (x / (y - z)) / (t - z);
	} else if (t_1 <= 3.615670797450081e+109) {
		tmp = x / ((pow(z, 2.0) + (y * t)) - ((y * z) + (z * t)));
	} 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.3
Target8.2
Herbie1.3
\[\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 3 regimes
  2. if (*.f64 (-.f64 y z) (-.f64 t z)) < -1.1139773717897069e73

    1. Initial program 8.4

      \[\frac{x}{\left(y - z\right) \cdot \left(t - z\right)} \]
    2. Applied associate-/r*_binary641.5

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

    if -1.1139773717897069e73 < (*.f64 (-.f64 y z) (-.f64 t z)) < 3.615670797450081e109

    1. Initial program 2.4

      \[\frac{x}{\left(y - z\right) \cdot \left(t - z\right)} \]
    2. Taylor expanded in x around inf 2.4

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

    if 3.615670797450081e109 < (*.f64 (-.f64 y z) (-.f64 t z))

    1. Initial program 9.7

      \[\frac{x}{\left(y - z\right) \cdot \left(t - z\right)} \]
    2. Applied associate-/r*_binary640.5

      \[\leadsto \color{blue}{\frac{\frac{x}{y - z}}{t - z}} \]
    3. Applied clear-num_binary641.2

      \[\leadsto \color{blue}{\frac{1}{\frac{t - z}{\frac{x}{y - z}}}} \]
    4. Applied associate-/r/_binary641.2

      \[\leadsto \frac{1}{\color{blue}{\frac{t - z}{x} \cdot \left(y - z\right)}} \]
    5. Applied associate-/r*_binary640.7

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(y - z\right) \cdot \left(t - z\right) \leq -1.1139773717897069 \cdot 10^{+73}:\\ \;\;\;\;\frac{\frac{x}{y - z}}{t - z}\\ \mathbf{elif}\;\left(y - z\right) \cdot \left(t - z\right) \leq 3.615670797450081 \cdot 10^{+109}:\\ \;\;\;\;\frac{x}{\left({z}^{2} + y \cdot t\right) - \left(y \cdot z + z \cdot t\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{t - z}}{y - z}\\ \end{array} \]

Reproduce

herbie shell --seed 2022097 
(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))))