Average Error: 7.6 → 0.9
Time: 3.5s
Precision: binary64
\[ \begin{array}{c}[y, t] = \mathsf{sort}([y, t])\\ \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 -4 \cdot 10^{+220}:\\ \;\;\;\;\frac{\frac{x}{z - y}}{z - t}\\ \mathbf{elif}\;t_1 \leq 4 \cdot 10^{+250}:\\ \;\;\;\;\frac{x}{t_1}\\ \mathbf{else}:\\ \;\;\;\;{\left(\left(z - y\right) \cdot \frac{z - t}{x}\right)}^{-1}\\ \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 -4e+220)
     (/ (/ x (- z y)) (- z t))
     (if (<= t_1 4e+250) (/ x t_1) (pow (* (- z y) (/ (- z t) x)) -1.0)))))
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 <= -4e+220) {
		tmp = (x / (z - y)) / (z - t);
	} else if (t_1 <= 4e+250) {
		tmp = x / t_1;
	} else {
		tmp = pow(((z - y) * ((z - t) / x)), -1.0);
	}
	return tmp;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = x / ((y - z) * (t - z))
end function
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: t_1
    real(8) :: tmp
    t_1 = (y - z) * (t - z)
    if (t_1 <= (-4d+220)) then
        tmp = (x / (z - y)) / (z - t)
    else if (t_1 <= 4d+250) then
        tmp = x / t_1
    else
        tmp = ((z - y) * ((z - t) / x)) ** (-1.0d0)
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	return x / ((y - z) * (t - z));
}
public static double code(double x, double y, double z, double t) {
	double t_1 = (y - z) * (t - z);
	double tmp;
	if (t_1 <= -4e+220) {
		tmp = (x / (z - y)) / (z - t);
	} else if (t_1 <= 4e+250) {
		tmp = x / t_1;
	} else {
		tmp = Math.pow(((z - y) * ((z - t) / x)), -1.0);
	}
	return tmp;
}
def code(x, y, z, t):
	return x / ((y - z) * (t - z))
def code(x, y, z, t):
	t_1 = (y - z) * (t - z)
	tmp = 0
	if t_1 <= -4e+220:
		tmp = (x / (z - y)) / (z - t)
	elif t_1 <= 4e+250:
		tmp = x / t_1
	else:
		tmp = math.pow(((z - y) * ((z - t) / x)), -1.0)
	return tmp
function code(x, y, z, t)
	return Float64(x / Float64(Float64(y - z) * Float64(t - z)))
end
function code(x, y, z, t)
	t_1 = Float64(Float64(y - z) * Float64(t - z))
	tmp = 0.0
	if (t_1 <= -4e+220)
		tmp = Float64(Float64(x / Float64(z - y)) / Float64(z - t));
	elseif (t_1 <= 4e+250)
		tmp = Float64(x / t_1);
	else
		tmp = Float64(Float64(z - y) * Float64(Float64(z - t) / x)) ^ -1.0;
	end
	return tmp
end
function tmp = code(x, y, z, t)
	tmp = x / ((y - z) * (t - z));
end
function tmp_2 = code(x, y, z, t)
	t_1 = (y - z) * (t - z);
	tmp = 0.0;
	if (t_1 <= -4e+220)
		tmp = (x / (z - y)) / (z - t);
	elseif (t_1 <= 4e+250)
		tmp = x / t_1;
	else
		tmp = ((z - y) * ((z - t) / x)) ^ -1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := N[(x / N[(N[(y - z), $MachinePrecision] * N[(t - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(y - z), $MachinePrecision] * N[(t - z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -4e+220], N[(N[(x / N[(z - y), $MachinePrecision]), $MachinePrecision] / N[(z - t), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 4e+250], N[(x / t$95$1), $MachinePrecision], N[Power[N[(N[(z - y), $MachinePrecision] * N[(N[(z - t), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision]]]]
\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 -4 \cdot 10^{+220}:\\
\;\;\;\;\frac{\frac{x}{z - y}}{z - t}\\

\mathbf{elif}\;t_1 \leq 4 \cdot 10^{+250}:\\
\;\;\;\;\frac{x}{t_1}\\

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


\end{array}

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.6
Target8.3
Herbie0.9
\[\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)) < -4e220

    1. Initial program 13.0

      \[\frac{x}{\left(y - z\right) \cdot \left(t - z\right)} \]
    2. Simplified0.2

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

    if -4e220 < (*.f64 (-.f64 y z) (-.f64 t z)) < 3.9999999999999997e250

    1. Initial program 1.3

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

    if 3.9999999999999997e250 < (*.f64 (-.f64 y z) (-.f64 t z))

    1. Initial program 14.0

      \[\frac{x}{\left(y - z\right) \cdot \left(t - z\right)} \]
    2. Simplified0.1

      \[\leadsto \color{blue}{\frac{\frac{x}{z - y}}{z - t}} \]
    3. Applied egg-rr0.7

      \[\leadsto \color{blue}{{\left(\frac{z - t}{x} \cdot \left(z - y\right)\right)}^{-1}} \]
  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) \leq -4 \cdot 10^{+220}:\\ \;\;\;\;\frac{\frac{x}{z - y}}{z - t}\\ \mathbf{elif}\;\left(y - z\right) \cdot \left(t - z\right) \leq 4 \cdot 10^{+250}:\\ \;\;\;\;\frac{x}{\left(y - z\right) \cdot \left(t - z\right)}\\ \mathbf{else}:\\ \;\;\;\;{\left(\left(z - y\right) \cdot \frac{z - t}{x}\right)}^{-1}\\ \end{array} \]

Reproduce

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