Average Error: 0.7 → 0.3
Time: 4.1s
Precision: binary64
\[[z, t]=\mathsf{sort}([z, t])\]
\[1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)} \]
\[\begin{array}{l} \mathbf{if}\;z \leq -5.9303573156645634 \cdot 10^{+94}:\\ \;\;\;\;1 + \frac{\frac{x}{z}}{y - t}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{\frac{x}{y - t}}{y - z}\\ \end{array} \]
1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)}
\begin{array}{l}
\mathbf{if}\;z \leq -5.9303573156645634 \cdot 10^{+94}:\\
\;\;\;\;1 + \frac{\frac{x}{z}}{y - t}\\

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


\end{array}
(FPCore (x y z t) :precision binary64 (- 1.0 (/ x (* (- y z) (- y t)))))
(FPCore (x y z t)
 :precision binary64
 (if (<= z -5.9303573156645634e+94)
   (+ 1.0 (/ (/ x z) (- y t)))
   (- 1.0 (/ (/ x (- y t)) (- y z)))))
double code(double x, double y, double z, double t) {
	return 1.0 - (x / ((y - z) * (y - t)));
}
double code(double x, double y, double z, double t) {
	double tmp;
	if (z <= -5.9303573156645634e+94) {
		tmp = 1.0 + ((x / z) / (y - t));
	} else {
		tmp = 1.0 - ((x / (y - t)) / (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

Derivation

  1. Split input into 2 regimes
  2. if z < -5.9303573156645634e94

    1. Initial program 0.0

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

      \[\leadsto 1 - \color{blue}{\frac{\frac{x}{y - z}}{y - t}} \]
    3. Taylor expanded in y around 0 0.2

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

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

    if -5.9303573156645634e94 < z

    1. Initial program 1.0

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

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

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

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

Reproduce

herbie shell --seed 2021275 
(FPCore (x y z t)
  :name "Data.Random.Distribution.Triangular:triangularCDF from random-fu-0.2.6.2, A"
  :precision binary64
  (- 1.0 (/ x (* (- y z) (- y t)))))