Data.Random.Distribution.Triangular:triangularCDF from random-fu-0.2.6.2, A

Percentage Accurate: 99.0% → 98.7%
Time: 8.9s
Alternatives: 14
Speedup: 1.0×

Specification

?
\[\begin{array}{l} \\ 1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)} \end{array} \]
(FPCore (x y z t) :precision binary64 (- 1.0 (/ x (* (- y z) (- y t)))))
double code(double x, double y, double z, double t) {
	return 1.0 - (x / ((y - z) * (y - t)));
}
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 = 1.0d0 - (x / ((y - z) * (y - t)))
end function
public static double code(double x, double y, double z, double t) {
	return 1.0 - (x / ((y - z) * (y - t)));
}
def code(x, y, z, t):
	return 1.0 - (x / ((y - z) * (y - t)))
function code(x, y, z, t)
	return Float64(1.0 - Float64(x / Float64(Float64(y - z) * Float64(y - t))))
end
function tmp = code(x, y, z, t)
	tmp = 1.0 - (x / ((y - z) * (y - t)));
end
code[x_, y_, z_, t_] := N[(1.0 - N[(x / N[(N[(y - z), $MachinePrecision] * N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 14 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 99.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ 1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)} \end{array} \]
(FPCore (x y z t) :precision binary64 (- 1.0 (/ x (* (- y z) (- y t)))))
double code(double x, double y, double z, double t) {
	return 1.0 - (x / ((y - z) * (y - t)));
}
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 = 1.0d0 - (x / ((y - z) * (y - t)))
end function
public static double code(double x, double y, double z, double t) {
	return 1.0 - (x / ((y - z) * (y - t)));
}
def code(x, y, z, t):
	return 1.0 - (x / ((y - z) * (y - t)))
function code(x, y, z, t)
	return Float64(1.0 - Float64(x / Float64(Float64(y - z) * Float64(y - t))))
end
function tmp = code(x, y, z, t)
	tmp = 1.0 - (x / ((y - z) * (y - t)));
end
code[x_, y_, z_, t_] := N[(1.0 - N[(x / N[(N[(y - z), $MachinePrecision] * N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)}
\end{array}

Alternative 1: 98.7% accurate, 0.1× speedup?

\[\begin{array}{l} [x, y, z, t] = \mathsf{sort}([x, y, z, t])\\ \\ 1 - {\left(\left(y - z\right) \cdot \frac{y - t}{x}\right)}^{-1} \end{array} \]
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
 :precision binary64
 (- 1.0 (pow (* (- y z) (/ (- y t) x)) -1.0)))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
	return 1.0 - pow(((y - z) * ((y - t) / x)), -1.0);
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this 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
    code = 1.0d0 - (((y - z) * ((y - t) / x)) ** (-1.0d0))
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
	return 1.0 - Math.pow(((y - z) * ((y - t) / x)), -1.0);
}
[x, y, z, t] = sort([x, y, z, t])
def code(x, y, z, t):
	return 1.0 - math.pow(((y - z) * ((y - t) / x)), -1.0)
x, y, z, t = sort([x, y, z, t])
function code(x, y, z, t)
	return Float64(1.0 - (Float64(Float64(y - z) * Float64(Float64(y - t) / x)) ^ -1.0))
end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp = code(x, y, z, t)
	tmp = 1.0 - (((y - z) * ((y - t) / x)) ^ -1.0);
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := N[(1.0 - N[Power[N[(N[(y - z), $MachinePrecision] * N[(N[(y - t), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
1 - {\left(\left(y - z\right) \cdot \frac{y - t}{x}\right)}^{-1}
\end{array}
Derivation
  1. Initial program 98.3%

    \[1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. clear-num98.3%

      \[\leadsto 1 - \color{blue}{\frac{1}{\frac{\left(y - z\right) \cdot \left(y - t\right)}{x}}} \]
    2. inv-pow98.3%

      \[\leadsto 1 - \color{blue}{{\left(\frac{\left(y - z\right) \cdot \left(y - t\right)}{x}\right)}^{-1}} \]
    3. associate-/l*97.8%

      \[\leadsto 1 - {\color{blue}{\left(\left(y - z\right) \cdot \frac{y - t}{x}\right)}}^{-1} \]
  4. Applied egg-rr97.8%

    \[\leadsto 1 - \color{blue}{{\left(\left(y - z\right) \cdot \frac{y - t}{x}\right)}^{-1}} \]
  5. Add Preprocessing

Alternative 2: 85.8% accurate, 0.6× speedup?

\[\begin{array}{l} [x, y, z, t] = \mathsf{sort}([x, y, z, t])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq -5 \cdot 10^{-67} \lor \neg \left(y \leq 3.5 \cdot 10^{-150}\right):\\ \;\;\;\;1 + \frac{x}{y \cdot \left(t - y\right)}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{x}{z \cdot t}\\ \end{array} \end{array} \]
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
 :precision binary64
 (if (or (<= y -5e-67) (not (<= y 3.5e-150)))
   (+ 1.0 (/ x (* y (- t y))))
   (- 1.0 (/ x (* z t)))))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
	double tmp;
	if ((y <= -5e-67) || !(y <= 3.5e-150)) {
		tmp = 1.0 + (x / (y * (t - y)));
	} else {
		tmp = 1.0 - (x / (z * t));
	}
	return tmp;
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this 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) :: tmp
    if ((y <= (-5d-67)) .or. (.not. (y <= 3.5d-150))) then
        tmp = 1.0d0 + (x / (y * (t - y)))
    else
        tmp = 1.0d0 - (x / (z * t))
    end if
    code = tmp
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
	double tmp;
	if ((y <= -5e-67) || !(y <= 3.5e-150)) {
		tmp = 1.0 + (x / (y * (t - y)));
	} else {
		tmp = 1.0 - (x / (z * t));
	}
	return tmp;
}
[x, y, z, t] = sort([x, y, z, t])
def code(x, y, z, t):
	tmp = 0
	if (y <= -5e-67) or not (y <= 3.5e-150):
		tmp = 1.0 + (x / (y * (t - y)))
	else:
		tmp = 1.0 - (x / (z * t))
	return tmp
x, y, z, t = sort([x, y, z, t])
function code(x, y, z, t)
	tmp = 0.0
	if ((y <= -5e-67) || !(y <= 3.5e-150))
		tmp = Float64(1.0 + Float64(x / Float64(y * Float64(t - y))));
	else
		tmp = Float64(1.0 - Float64(x / Float64(z * t)));
	end
	return tmp
end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if ((y <= -5e-67) || ~((y <= 3.5e-150)))
		tmp = 1.0 + (x / (y * (t - y)));
	else
		tmp = 1.0 - (x / (z * t));
	end
	tmp_2 = tmp;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -5e-67], N[Not[LessEqual[y, 3.5e-150]], $MachinePrecision]], N[(1.0 + N[(x / N[(y * N[(t - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(x / N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5 \cdot 10^{-67} \lor \neg \left(y \leq 3.5 \cdot 10^{-150}\right):\\
\;\;\;\;1 + \frac{x}{y \cdot \left(t - y\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -4.9999999999999999e-67 or 3.4999999999999998e-150 < y

    1. Initial program 99.8%

      \[1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in z around 0 90.2%

      \[\leadsto 1 - \color{blue}{\frac{x}{y \cdot \left(y - t\right)}} \]

    if -4.9999999999999999e-67 < y < 3.4999999999999998e-150

    1. Initial program 95.9%

      \[1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 78.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -5 \cdot 10^{-67} \lor \neg \left(y \leq 3.5 \cdot 10^{-150}\right):\\ \;\;\;\;1 + \frac{x}{y \cdot \left(t - y\right)}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{x}{z \cdot t}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 92.1% accurate, 0.6× speedup?

\[\begin{array}{l} [x, y, z, t] = \mathsf{sort}([x, y, z, t])\\ \\ \begin{array}{l} \mathbf{if}\;t \leq -2 \cdot 10^{-162}:\\ \;\;\;\;1 + \frac{x}{z} \cdot \frac{-1}{t - y}\\ \mathbf{elif}\;t \leq 2.05 \cdot 10^{-57}:\\ \;\;\;\;1 + \frac{\frac{x}{y}}{z - y}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{x}{t \cdot \left(z - y\right)}\\ \end{array} \end{array} \]
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
 :precision binary64
 (if (<= t -2e-162)
   (+ 1.0 (* (/ x z) (/ -1.0 (- t y))))
   (if (<= t 2.05e-57)
     (+ 1.0 (/ (/ x y) (- z y)))
     (- 1.0 (/ x (* t (- z y)))))))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
	double tmp;
	if (t <= -2e-162) {
		tmp = 1.0 + ((x / z) * (-1.0 / (t - y)));
	} else if (t <= 2.05e-57) {
		tmp = 1.0 + ((x / y) / (z - y));
	} else {
		tmp = 1.0 - (x / (t * (z - y)));
	}
	return tmp;
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this 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) :: tmp
    if (t <= (-2d-162)) then
        tmp = 1.0d0 + ((x / z) * ((-1.0d0) / (t - y)))
    else if (t <= 2.05d-57) then
        tmp = 1.0d0 + ((x / y) / (z - y))
    else
        tmp = 1.0d0 - (x / (t * (z - y)))
    end if
    code = tmp
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (t <= -2e-162) {
		tmp = 1.0 + ((x / z) * (-1.0 / (t - y)));
	} else if (t <= 2.05e-57) {
		tmp = 1.0 + ((x / y) / (z - y));
	} else {
		tmp = 1.0 - (x / (t * (z - y)));
	}
	return tmp;
}
[x, y, z, t] = sort([x, y, z, t])
def code(x, y, z, t):
	tmp = 0
	if t <= -2e-162:
		tmp = 1.0 + ((x / z) * (-1.0 / (t - y)))
	elif t <= 2.05e-57:
		tmp = 1.0 + ((x / y) / (z - y))
	else:
		tmp = 1.0 - (x / (t * (z - y)))
	return tmp
x, y, z, t = sort([x, y, z, t])
function code(x, y, z, t)
	tmp = 0.0
	if (t <= -2e-162)
		tmp = Float64(1.0 + Float64(Float64(x / z) * Float64(-1.0 / Float64(t - y))));
	elseif (t <= 2.05e-57)
		tmp = Float64(1.0 + Float64(Float64(x / y) / Float64(z - y)));
	else
		tmp = Float64(1.0 - Float64(x / Float64(t * Float64(z - y))));
	end
	return tmp
end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (t <= -2e-162)
		tmp = 1.0 + ((x / z) * (-1.0 / (t - y)));
	elseif (t <= 2.05e-57)
		tmp = 1.0 + ((x / y) / (z - y));
	else
		tmp = 1.0 - (x / (t * (z - y)));
	end
	tmp_2 = tmp;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := If[LessEqual[t, -2e-162], N[(1.0 + N[(N[(x / z), $MachinePrecision] * N[(-1.0 / N[(t - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 2.05e-57], N[(1.0 + N[(N[(x / y), $MachinePrecision] / N[(z - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(x / N[(t * N[(z - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;t \leq -2 \cdot 10^{-162}:\\
\;\;\;\;1 + \frac{x}{z} \cdot \frac{-1}{t - y}\\

\mathbf{elif}\;t \leq 2.05 \cdot 10^{-57}:\\
\;\;\;\;1 + \frac{\frac{x}{y}}{z - y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if t < -1.99999999999999991e-162

    1. Initial program 99.9%

      \[1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in z around inf 79.4%

      \[\leadsto 1 - \color{blue}{-1 \cdot \frac{x}{z \cdot \left(y - t\right)}} \]
    4. Step-by-step derivation
      1. associate-*r/79.4%

        \[\leadsto 1 - \color{blue}{\frac{-1 \cdot x}{z \cdot \left(y - t\right)}} \]
      2. neg-mul-179.4%

        \[\leadsto 1 - \frac{\color{blue}{-x}}{z \cdot \left(y - t\right)} \]
      3. *-commutative79.4%

        \[\leadsto 1 - \frac{-x}{\color{blue}{\left(y - t\right) \cdot z}} \]
    5. Simplified79.4%

      \[\leadsto 1 - \color{blue}{\frac{-x}{\left(y - t\right) \cdot z}} \]
    6. Step-by-step derivation
      1. neg-mul-179.4%

        \[\leadsto 1 - \frac{\color{blue}{-1 \cdot x}}{\left(y - t\right) \cdot z} \]
      2. times-frac78.5%

        \[\leadsto 1 - \color{blue}{\frac{-1}{y - t} \cdot \frac{x}{z}} \]
    7. Applied egg-rr78.5%

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

    if -1.99999999999999991e-162 < t < 2.0500000000000001e-57

    1. Initial program 95.1%

      \[1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in t around 0 84.5%

      \[\leadsto 1 - \color{blue}{\frac{x}{y \cdot \left(y - z\right)}} \]
    4. Step-by-step derivation
      1. associate-/r*83.6%

        \[\leadsto 1 - \color{blue}{\frac{\frac{x}{y}}{y - z}} \]
    5. Simplified83.6%

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

    if 2.0500000000000001e-57 < t

    1. Initial program 99.7%

      \[1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in t around inf 95.3%

      \[\leadsto 1 - \color{blue}{-1 \cdot \frac{x}{t \cdot \left(y - z\right)}} \]
    4. Step-by-step derivation
      1. associate-*r/95.3%

        \[\leadsto 1 - \color{blue}{\frac{-1 \cdot x}{t \cdot \left(y - z\right)}} \]
      2. neg-mul-195.3%

        \[\leadsto 1 - \frac{\color{blue}{-x}}{t \cdot \left(y - z\right)} \]
    5. Simplified95.3%

      \[\leadsto 1 - \color{blue}{\frac{-x}{t \cdot \left(y - z\right)}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification85.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -2 \cdot 10^{-162}:\\ \;\;\;\;1 + \frac{x}{z} \cdot \frac{-1}{t - y}\\ \mathbf{elif}\;t \leq 2.05 \cdot 10^{-57}:\\ \;\;\;\;1 + \frac{\frac{x}{y}}{z - y}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{x}{t \cdot \left(z - y\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 92.1% accurate, 0.6× speedup?

\[\begin{array}{l} [x, y, z, t] = \mathsf{sort}([x, y, z, t])\\ \\ \begin{array}{l} \mathbf{if}\;t \leq -7.8 \cdot 10^{-162}:\\ \;\;\;\;1 - \frac{x}{z \cdot \left(t - y\right)}\\ \mathbf{elif}\;t \leq 2.2 \cdot 10^{-57}:\\ \;\;\;\;1 + \frac{\frac{x}{y}}{z - y}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{x}{t \cdot \left(z - y\right)}\\ \end{array} \end{array} \]
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
 :precision binary64
 (if (<= t -7.8e-162)
   (- 1.0 (/ x (* z (- t y))))
   (if (<= t 2.2e-57)
     (+ 1.0 (/ (/ x y) (- z y)))
     (- 1.0 (/ x (* t (- z y)))))))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
	double tmp;
	if (t <= -7.8e-162) {
		tmp = 1.0 - (x / (z * (t - y)));
	} else if (t <= 2.2e-57) {
		tmp = 1.0 + ((x / y) / (z - y));
	} else {
		tmp = 1.0 - (x / (t * (z - y)));
	}
	return tmp;
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this 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) :: tmp
    if (t <= (-7.8d-162)) then
        tmp = 1.0d0 - (x / (z * (t - y)))
    else if (t <= 2.2d-57) then
        tmp = 1.0d0 + ((x / y) / (z - y))
    else
        tmp = 1.0d0 - (x / (t * (z - y)))
    end if
    code = tmp
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (t <= -7.8e-162) {
		tmp = 1.0 - (x / (z * (t - y)));
	} else if (t <= 2.2e-57) {
		tmp = 1.0 + ((x / y) / (z - y));
	} else {
		tmp = 1.0 - (x / (t * (z - y)));
	}
	return tmp;
}
[x, y, z, t] = sort([x, y, z, t])
def code(x, y, z, t):
	tmp = 0
	if t <= -7.8e-162:
		tmp = 1.0 - (x / (z * (t - y)))
	elif t <= 2.2e-57:
		tmp = 1.0 + ((x / y) / (z - y))
	else:
		tmp = 1.0 - (x / (t * (z - y)))
	return tmp
x, y, z, t = sort([x, y, z, t])
function code(x, y, z, t)
	tmp = 0.0
	if (t <= -7.8e-162)
		tmp = Float64(1.0 - Float64(x / Float64(z * Float64(t - y))));
	elseif (t <= 2.2e-57)
		tmp = Float64(1.0 + Float64(Float64(x / y) / Float64(z - y)));
	else
		tmp = Float64(1.0 - Float64(x / Float64(t * Float64(z - y))));
	end
	return tmp
end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (t <= -7.8e-162)
		tmp = 1.0 - (x / (z * (t - y)));
	elseif (t <= 2.2e-57)
		tmp = 1.0 + ((x / y) / (z - y));
	else
		tmp = 1.0 - (x / (t * (z - y)));
	end
	tmp_2 = tmp;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := If[LessEqual[t, -7.8e-162], N[(1.0 - N[(x / N[(z * N[(t - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 2.2e-57], N[(1.0 + N[(N[(x / y), $MachinePrecision] / N[(z - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(x / N[(t * N[(z - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;t \leq -7.8 \cdot 10^{-162}:\\
\;\;\;\;1 - \frac{x}{z \cdot \left(t - y\right)}\\

\mathbf{elif}\;t \leq 2.2 \cdot 10^{-57}:\\
\;\;\;\;1 + \frac{\frac{x}{y}}{z - y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if t < -7.7999999999999999e-162

    1. Initial program 99.9%

      \[1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in z around inf 79.2%

      \[\leadsto 1 - \color{blue}{-1 \cdot \frac{x}{z \cdot \left(y - t\right)}} \]
    4. Step-by-step derivation
      1. associate-*r/79.2%

        \[\leadsto 1 - \color{blue}{\frac{-1 \cdot x}{z \cdot \left(y - t\right)}} \]
      2. neg-mul-179.2%

        \[\leadsto 1 - \frac{\color{blue}{-x}}{z \cdot \left(y - t\right)} \]
      3. *-commutative79.2%

        \[\leadsto 1 - \frac{-x}{\color{blue}{\left(y - t\right) \cdot z}} \]
    5. Simplified79.2%

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

    if -7.7999999999999999e-162 < t < 2.19999999999999999e-57

    1. Initial program 95.2%

      \[1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in t around 0 84.7%

      \[\leadsto 1 - \color{blue}{\frac{x}{y \cdot \left(y - z\right)}} \]
    4. Step-by-step derivation
      1. associate-/r*83.8%

        \[\leadsto 1 - \color{blue}{\frac{\frac{x}{y}}{y - z}} \]
    5. Simplified83.8%

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

    if 2.19999999999999999e-57 < t

    1. Initial program 99.7%

      \[1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in t around inf 95.3%

      \[\leadsto 1 - \color{blue}{-1 \cdot \frac{x}{t \cdot \left(y - z\right)}} \]
    4. Step-by-step derivation
      1. associate-*r/95.3%

        \[\leadsto 1 - \color{blue}{\frac{-1 \cdot x}{t \cdot \left(y - z\right)}} \]
      2. neg-mul-195.3%

        \[\leadsto 1 - \frac{\color{blue}{-x}}{t \cdot \left(y - z\right)} \]
    5. Simplified95.3%

      \[\leadsto 1 - \color{blue}{\frac{-x}{t \cdot \left(y - z\right)}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification85.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -7.8 \cdot 10^{-162}:\\ \;\;\;\;1 - \frac{x}{z \cdot \left(t - y\right)}\\ \mathbf{elif}\;t \leq 2.2 \cdot 10^{-57}:\\ \;\;\;\;1 + \frac{\frac{x}{y}}{z - y}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{x}{t \cdot \left(z - y\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 90.9% accurate, 0.6× speedup?

\[\begin{array}{l} [x, y, z, t] = \mathsf{sort}([x, y, z, t])\\ \\ \begin{array}{l} \mathbf{if}\;t \leq -4.5 \cdot 10^{-81}:\\ \;\;\;\;1 - x \cdot \frac{\frac{1}{t}}{z}\\ \mathbf{elif}\;t \leq 6 \cdot 10^{-57}:\\ \;\;\;\;1 + \frac{\frac{x}{y}}{z - y}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{x}{t \cdot \left(z - y\right)}\\ \end{array} \end{array} \]
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
 :precision binary64
 (if (<= t -4.5e-81)
   (- 1.0 (* x (/ (/ 1.0 t) z)))
   (if (<= t 6e-57) (+ 1.0 (/ (/ x y) (- z y))) (- 1.0 (/ x (* t (- z y)))))))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
	double tmp;
	if (t <= -4.5e-81) {
		tmp = 1.0 - (x * ((1.0 / t) / z));
	} else if (t <= 6e-57) {
		tmp = 1.0 + ((x / y) / (z - y));
	} else {
		tmp = 1.0 - (x / (t * (z - y)));
	}
	return tmp;
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this 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) :: tmp
    if (t <= (-4.5d-81)) then
        tmp = 1.0d0 - (x * ((1.0d0 / t) / z))
    else if (t <= 6d-57) then
        tmp = 1.0d0 + ((x / y) / (z - y))
    else
        tmp = 1.0d0 - (x / (t * (z - y)))
    end if
    code = tmp
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (t <= -4.5e-81) {
		tmp = 1.0 - (x * ((1.0 / t) / z));
	} else if (t <= 6e-57) {
		tmp = 1.0 + ((x / y) / (z - y));
	} else {
		tmp = 1.0 - (x / (t * (z - y)));
	}
	return tmp;
}
[x, y, z, t] = sort([x, y, z, t])
def code(x, y, z, t):
	tmp = 0
	if t <= -4.5e-81:
		tmp = 1.0 - (x * ((1.0 / t) / z))
	elif t <= 6e-57:
		tmp = 1.0 + ((x / y) / (z - y))
	else:
		tmp = 1.0 - (x / (t * (z - y)))
	return tmp
x, y, z, t = sort([x, y, z, t])
function code(x, y, z, t)
	tmp = 0.0
	if (t <= -4.5e-81)
		tmp = Float64(1.0 - Float64(x * Float64(Float64(1.0 / t) / z)));
	elseif (t <= 6e-57)
		tmp = Float64(1.0 + Float64(Float64(x / y) / Float64(z - y)));
	else
		tmp = Float64(1.0 - Float64(x / Float64(t * Float64(z - y))));
	end
	return tmp
end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (t <= -4.5e-81)
		tmp = 1.0 - (x * ((1.0 / t) / z));
	elseif (t <= 6e-57)
		tmp = 1.0 + ((x / y) / (z - y));
	else
		tmp = 1.0 - (x / (t * (z - y)));
	end
	tmp_2 = tmp;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := If[LessEqual[t, -4.5e-81], N[(1.0 - N[(x * N[(N[(1.0 / t), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 6e-57], N[(1.0 + N[(N[(x / y), $MachinePrecision] / N[(z - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(x / N[(t * N[(z - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;t \leq -4.5 \cdot 10^{-81}:\\
\;\;\;\;1 - x \cdot \frac{\frac{1}{t}}{z}\\

\mathbf{elif}\;t \leq 6 \cdot 10^{-57}:\\
\;\;\;\;1 + \frac{\frac{x}{y}}{z - y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if t < -4.5e-81

    1. Initial program 99.9%

      \[1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 75.0%

      \[\leadsto 1 - \color{blue}{\frac{x}{t \cdot z}} \]
    4. Step-by-step derivation
      1. clear-num75.1%

        \[\leadsto 1 - \color{blue}{\frac{1}{\frac{t \cdot z}{x}}} \]
      2. inv-pow75.1%

        \[\leadsto 1 - \color{blue}{{\left(\frac{t \cdot z}{x}\right)}^{-1}} \]
      3. *-commutative75.1%

        \[\leadsto 1 - {\left(\frac{\color{blue}{z \cdot t}}{x}\right)}^{-1} \]
      4. associate-/l*72.9%

        \[\leadsto 1 - {\color{blue}{\left(z \cdot \frac{t}{x}\right)}}^{-1} \]
    5. Applied egg-rr72.9%

      \[\leadsto 1 - \color{blue}{{\left(z \cdot \frac{t}{x}\right)}^{-1}} \]
    6. Step-by-step derivation
      1. unpow-172.9%

        \[\leadsto 1 - \color{blue}{\frac{1}{z \cdot \frac{t}{x}}} \]
      2. associate-*r/75.1%

        \[\leadsto 1 - \frac{1}{\color{blue}{\frac{z \cdot t}{x}}} \]
      3. *-commutative75.1%

        \[\leadsto 1 - \frac{1}{\frac{\color{blue}{t \cdot z}}{x}} \]
      4. associate-/l*73.9%

        \[\leadsto 1 - \frac{1}{\color{blue}{t \cdot \frac{z}{x}}} \]
    7. Simplified73.9%

      \[\leadsto 1 - \color{blue}{\frac{1}{t \cdot \frac{z}{x}}} \]
    8. Step-by-step derivation
      1. associate-/r*73.9%

        \[\leadsto 1 - \color{blue}{\frac{\frac{1}{t}}{\frac{z}{x}}} \]
      2. associate-/r/75.1%

        \[\leadsto 1 - \color{blue}{\frac{\frac{1}{t}}{z} \cdot x} \]
    9. Applied egg-rr75.1%

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

    if -4.5e-81 < t < 6.00000000000000001e-57

    1. Initial program 96.0%

      \[1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in t around 0 82.4%

      \[\leadsto 1 - \color{blue}{\frac{x}{y \cdot \left(y - z\right)}} \]
    4. Step-by-step derivation
      1. associate-/r*81.7%

        \[\leadsto 1 - \color{blue}{\frac{\frac{x}{y}}{y - z}} \]
    5. Simplified81.7%

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

    if 6.00000000000000001e-57 < t

    1. Initial program 99.7%

      \[1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in t around inf 95.3%

      \[\leadsto 1 - \color{blue}{-1 \cdot \frac{x}{t \cdot \left(y - z\right)}} \]
    4. Step-by-step derivation
      1. associate-*r/95.3%

        \[\leadsto 1 - \color{blue}{\frac{-1 \cdot x}{t \cdot \left(y - z\right)}} \]
      2. neg-mul-195.3%

        \[\leadsto 1 - \frac{\color{blue}{-x}}{t \cdot \left(y - z\right)} \]
    5. Simplified95.3%

      \[\leadsto 1 - \color{blue}{\frac{-x}{t \cdot \left(y - z\right)}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification83.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -4.5 \cdot 10^{-81}:\\ \;\;\;\;1 - x \cdot \frac{\frac{1}{t}}{z}\\ \mathbf{elif}\;t \leq 6 \cdot 10^{-57}:\\ \;\;\;\;1 + \frac{\frac{x}{y}}{z - y}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{x}{t \cdot \left(z - y\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 85.9% accurate, 0.6× speedup?

\[\begin{array}{l} [x, y, z, t] = \mathsf{sort}([x, y, z, t])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq -8.6 \cdot 10^{-60}:\\ \;\;\;\;1 + \frac{\frac{x}{y}}{z - y}\\ \mathbf{elif}\;y \leq 6.6 \cdot 10^{-150}:\\ \;\;\;\;1 - \frac{x}{z \cdot t}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{x}{y \cdot \left(y - t\right)}\\ \end{array} \end{array} \]
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
 :precision binary64
 (if (<= y -8.6e-60)
   (+ 1.0 (/ (/ x y) (- z y)))
   (if (<= y 6.6e-150) (- 1.0 (/ x (* z t))) (- 1.0 (/ x (* y (- y t)))))))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
	double tmp;
	if (y <= -8.6e-60) {
		tmp = 1.0 + ((x / y) / (z - y));
	} else if (y <= 6.6e-150) {
		tmp = 1.0 - (x / (z * t));
	} else {
		tmp = 1.0 - (x / (y * (y - t)));
	}
	return tmp;
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this 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) :: tmp
    if (y <= (-8.6d-60)) then
        tmp = 1.0d0 + ((x / y) / (z - y))
    else if (y <= 6.6d-150) then
        tmp = 1.0d0 - (x / (z * t))
    else
        tmp = 1.0d0 - (x / (y * (y - t)))
    end if
    code = tmp
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (y <= -8.6e-60) {
		tmp = 1.0 + ((x / y) / (z - y));
	} else if (y <= 6.6e-150) {
		tmp = 1.0 - (x / (z * t));
	} else {
		tmp = 1.0 - (x / (y * (y - t)));
	}
	return tmp;
}
[x, y, z, t] = sort([x, y, z, t])
def code(x, y, z, t):
	tmp = 0
	if y <= -8.6e-60:
		tmp = 1.0 + ((x / y) / (z - y))
	elif y <= 6.6e-150:
		tmp = 1.0 - (x / (z * t))
	else:
		tmp = 1.0 - (x / (y * (y - t)))
	return tmp
x, y, z, t = sort([x, y, z, t])
function code(x, y, z, t)
	tmp = 0.0
	if (y <= -8.6e-60)
		tmp = Float64(1.0 + Float64(Float64(x / y) / Float64(z - y)));
	elseif (y <= 6.6e-150)
		tmp = Float64(1.0 - Float64(x / Float64(z * t)));
	else
		tmp = Float64(1.0 - Float64(x / Float64(y * Float64(y - t))));
	end
	return tmp
end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (y <= -8.6e-60)
		tmp = 1.0 + ((x / y) / (z - y));
	elseif (y <= 6.6e-150)
		tmp = 1.0 - (x / (z * t));
	else
		tmp = 1.0 - (x / (y * (y - t)));
	end
	tmp_2 = tmp;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := If[LessEqual[y, -8.6e-60], N[(1.0 + N[(N[(x / y), $MachinePrecision] / N[(z - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 6.6e-150], N[(1.0 - N[(x / N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(x / N[(y * N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.6 \cdot 10^{-60}:\\
\;\;\;\;1 + \frac{\frac{x}{y}}{z - y}\\

\mathbf{elif}\;y \leq 6.6 \cdot 10^{-150}:\\
\;\;\;\;1 - \frac{x}{z \cdot t}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -8.6000000000000001e-60

    1. Initial program 99.7%

      \[1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in t around 0 90.3%

      \[\leadsto 1 - \color{blue}{\frac{x}{y \cdot \left(y - z\right)}} \]
    4. Step-by-step derivation
      1. associate-/r*90.3%

        \[\leadsto 1 - \color{blue}{\frac{\frac{x}{y}}{y - z}} \]
    5. Simplified90.3%

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

    if -8.6000000000000001e-60 < y < 6.6000000000000003e-150

    1. Initial program 96.0%

      \[1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 78.1%

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

    if 6.6000000000000003e-150 < y

    1. Initial program 99.9%

      \[1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in z around 0 89.0%

      \[\leadsto 1 - \color{blue}{\frac{x}{y \cdot \left(y - t\right)}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification85.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -8.6 \cdot 10^{-60}:\\ \;\;\;\;1 + \frac{\frac{x}{y}}{z - y}\\ \mathbf{elif}\;y \leq 6.6 \cdot 10^{-150}:\\ \;\;\;\;1 - \frac{x}{z \cdot t}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{x}{y \cdot \left(y - t\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 82.6% accurate, 0.6× speedup?

\[\begin{array}{l} [x, y, z, t] = \mathsf{sort}([x, y, z, t])\\ \\ \begin{array}{l} \mathbf{if}\;z \leq -1.5 \cdot 10^{-101}:\\ \;\;\;\;1 + \frac{x}{y \cdot \left(z - y\right)}\\ \mathbf{elif}\;z \leq 7.2 \cdot 10^{-46}:\\ \;\;\;\;1 - \frac{x}{y \cdot \left(y - t\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{z - \frac{x}{t}}{z}\\ \end{array} \end{array} \]
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
 :precision binary64
 (if (<= z -1.5e-101)
   (+ 1.0 (/ x (* y (- z y))))
   (if (<= z 7.2e-46) (- 1.0 (/ x (* y (- y t)))) (/ (- z (/ x t)) z))))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
	double tmp;
	if (z <= -1.5e-101) {
		tmp = 1.0 + (x / (y * (z - y)));
	} else if (z <= 7.2e-46) {
		tmp = 1.0 - (x / (y * (y - t)));
	} else {
		tmp = (z - (x / t)) / z;
	}
	return tmp;
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this 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) :: tmp
    if (z <= (-1.5d-101)) then
        tmp = 1.0d0 + (x / (y * (z - y)))
    else if (z <= 7.2d-46) then
        tmp = 1.0d0 - (x / (y * (y - t)))
    else
        tmp = (z - (x / t)) / z
    end if
    code = tmp
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (z <= -1.5e-101) {
		tmp = 1.0 + (x / (y * (z - y)));
	} else if (z <= 7.2e-46) {
		tmp = 1.0 - (x / (y * (y - t)));
	} else {
		tmp = (z - (x / t)) / z;
	}
	return tmp;
}
[x, y, z, t] = sort([x, y, z, t])
def code(x, y, z, t):
	tmp = 0
	if z <= -1.5e-101:
		tmp = 1.0 + (x / (y * (z - y)))
	elif z <= 7.2e-46:
		tmp = 1.0 - (x / (y * (y - t)))
	else:
		tmp = (z - (x / t)) / z
	return tmp
x, y, z, t = sort([x, y, z, t])
function code(x, y, z, t)
	tmp = 0.0
	if (z <= -1.5e-101)
		tmp = Float64(1.0 + Float64(x / Float64(y * Float64(z - y))));
	elseif (z <= 7.2e-46)
		tmp = Float64(1.0 - Float64(x / Float64(y * Float64(y - t))));
	else
		tmp = Float64(Float64(z - Float64(x / t)) / z);
	end
	return tmp
end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (z <= -1.5e-101)
		tmp = 1.0 + (x / (y * (z - y)));
	elseif (z <= 7.2e-46)
		tmp = 1.0 - (x / (y * (y - t)));
	else
		tmp = (z - (x / t)) / z;
	end
	tmp_2 = tmp;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := If[LessEqual[z, -1.5e-101], N[(1.0 + N[(x / N[(y * N[(z - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 7.2e-46], N[(1.0 - N[(x / N[(y * N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(z - N[(x / t), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.5 \cdot 10^{-101}:\\
\;\;\;\;1 + \frac{x}{y \cdot \left(z - y\right)}\\

\mathbf{elif}\;z \leq 7.2 \cdot 10^{-46}:\\
\;\;\;\;1 - \frac{x}{y \cdot \left(y - t\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1.5000000000000002e-101

    1. Initial program 99.6%

      \[1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in t around 0 77.6%

      \[\leadsto 1 - \color{blue}{\frac{x}{y \cdot \left(y - z\right)}} \]

    if -1.5000000000000002e-101 < z < 7.2e-46

    1. Initial program 95.7%

      \[1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in z around 0 87.1%

      \[\leadsto 1 - \color{blue}{\frac{x}{y \cdot \left(y - t\right)}} \]

    if 7.2e-46 < z

    1. Initial program 99.9%

      \[1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 78.8%

      \[\leadsto 1 - \color{blue}{\frac{x}{t \cdot z}} \]
    4. Taylor expanded in z around 0 75.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.5 \cdot 10^{-101}:\\ \;\;\;\;1 + \frac{x}{y \cdot \left(z - y\right)}\\ \mathbf{elif}\;z \leq 7.2 \cdot 10^{-46}:\\ \;\;\;\;1 - \frac{x}{y \cdot \left(y - t\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{z - \frac{x}{t}}{z}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 83.2% accurate, 0.6× speedup?

\[\begin{array}{l} [x, y, z, t] = \mathsf{sort}([x, y, z, t])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq -4.5 \cdot 10^{-79}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 7 \cdot 10^{-64}:\\ \;\;\;\;\frac{z - \frac{x}{t}}{z}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
 :precision binary64
 (if (<= y -4.5e-79) 1.0 (if (<= y 7e-64) (/ (- z (/ x t)) z) 1.0)))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
	double tmp;
	if (y <= -4.5e-79) {
		tmp = 1.0;
	} else if (y <= 7e-64) {
		tmp = (z - (x / t)) / z;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this 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) :: tmp
    if (y <= (-4.5d-79)) then
        tmp = 1.0d0
    else if (y <= 7d-64) then
        tmp = (z - (x / t)) / z
    else
        tmp = 1.0d0
    end if
    code = tmp
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (y <= -4.5e-79) {
		tmp = 1.0;
	} else if (y <= 7e-64) {
		tmp = (z - (x / t)) / z;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
[x, y, z, t] = sort([x, y, z, t])
def code(x, y, z, t):
	tmp = 0
	if y <= -4.5e-79:
		tmp = 1.0
	elif y <= 7e-64:
		tmp = (z - (x / t)) / z
	else:
		tmp = 1.0
	return tmp
x, y, z, t = sort([x, y, z, t])
function code(x, y, z, t)
	tmp = 0.0
	if (y <= -4.5e-79)
		tmp = 1.0;
	elseif (y <= 7e-64)
		tmp = Float64(Float64(z - Float64(x / t)) / z);
	else
		tmp = 1.0;
	end
	return tmp
end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (y <= -4.5e-79)
		tmp = 1.0;
	elseif (y <= 7e-64)
		tmp = (z - (x / t)) / z;
	else
		tmp = 1.0;
	end
	tmp_2 = tmp;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := If[LessEqual[y, -4.5e-79], 1.0, If[LessEqual[y, 7e-64], N[(N[(z - N[(x / t), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], 1.0]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.5 \cdot 10^{-79}:\\
\;\;\;\;1\\

\mathbf{elif}\;y \leq 7 \cdot 10^{-64}:\\
\;\;\;\;\frac{z - \frac{x}{t}}{z}\\

\mathbf{else}:\\
\;\;\;\;1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -4.5000000000000003e-79 or 7.0000000000000006e-64 < y

    1. Initial program 99.8%

      \[1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 51.1%

      \[\leadsto 1 - \color{blue}{\frac{x}{t \cdot z}} \]
    4. Taylor expanded in x around 0 86.4%

      \[\leadsto \color{blue}{1} \]

    if -4.5000000000000003e-79 < y < 7.0000000000000006e-64

    1. Initial program 96.3%

      \[1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 73.3%

      \[\leadsto 1 - \color{blue}{\frac{x}{t \cdot z}} \]
    4. Taylor expanded in z around 0 71.1%

      \[\leadsto \color{blue}{\frac{z - \frac{x}{t}}{z}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 9: 83.5% accurate, 0.6× speedup?

\[\begin{array}{l} [x, y, z, t] = \mathsf{sort}([x, y, z, t])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq -7 \cdot 10^{-67}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 1.05 \cdot 10^{-60}:\\ \;\;\;\;1 - \frac{x}{z \cdot t}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
 :precision binary64
 (if (<= y -7e-67) 1.0 (if (<= y 1.05e-60) (- 1.0 (/ x (* z t))) 1.0)))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
	double tmp;
	if (y <= -7e-67) {
		tmp = 1.0;
	} else if (y <= 1.05e-60) {
		tmp = 1.0 - (x / (z * t));
	} else {
		tmp = 1.0;
	}
	return tmp;
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this 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) :: tmp
    if (y <= (-7d-67)) then
        tmp = 1.0d0
    else if (y <= 1.05d-60) then
        tmp = 1.0d0 - (x / (z * t))
    else
        tmp = 1.0d0
    end if
    code = tmp
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (y <= -7e-67) {
		tmp = 1.0;
	} else if (y <= 1.05e-60) {
		tmp = 1.0 - (x / (z * t));
	} else {
		tmp = 1.0;
	}
	return tmp;
}
[x, y, z, t] = sort([x, y, z, t])
def code(x, y, z, t):
	tmp = 0
	if y <= -7e-67:
		tmp = 1.0
	elif y <= 1.05e-60:
		tmp = 1.0 - (x / (z * t))
	else:
		tmp = 1.0
	return tmp
x, y, z, t = sort([x, y, z, t])
function code(x, y, z, t)
	tmp = 0.0
	if (y <= -7e-67)
		tmp = 1.0;
	elseif (y <= 1.05e-60)
		tmp = Float64(1.0 - Float64(x / Float64(z * t)));
	else
		tmp = 1.0;
	end
	return tmp
end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (y <= -7e-67)
		tmp = 1.0;
	elseif (y <= 1.05e-60)
		tmp = 1.0 - (x / (z * t));
	else
		tmp = 1.0;
	end
	tmp_2 = tmp;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := If[LessEqual[y, -7e-67], 1.0, If[LessEqual[y, 1.05e-60], N[(1.0 - N[(x / N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1.0]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7 \cdot 10^{-67}:\\
\;\;\;\;1\\

\mathbf{elif}\;y \leq 1.05 \cdot 10^{-60}:\\
\;\;\;\;1 - \frac{x}{z \cdot t}\\

\mathbf{else}:\\
\;\;\;\;1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -7.0000000000000001e-67 or 1.04999999999999996e-60 < y

    1. Initial program 99.8%

      \[1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 50.1%

      \[\leadsto 1 - \color{blue}{\frac{x}{t \cdot z}} \]
    4. Taylor expanded in x around 0 86.6%

      \[\leadsto \color{blue}{1} \]

    if -7.0000000000000001e-67 < y < 1.04999999999999996e-60

    1. Initial program 96.4%

      \[1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 73.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -7 \cdot 10^{-67}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 1.05 \cdot 10^{-60}:\\ \;\;\;\;1 - \frac{x}{z \cdot t}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 71.3% accurate, 0.6× speedup?

\[\begin{array}{l} [x, y, z, t] = \mathsf{sort}([x, y, z, t])\\ \\ \begin{array}{l} \mathbf{if}\;x \leq -1.35 \cdot 10^{+174}:\\ \;\;\;\;\frac{x}{t \cdot \left(-z\right)}\\ \mathbf{elif}\;x \leq 3.6 \cdot 10^{+171}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{x}{y \cdot t}\\ \end{array} \end{array} \]
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
 :precision binary64
 (if (<= x -1.35e+174)
   (/ x (* t (- z)))
   (if (<= x 3.6e+171) 1.0 (+ 1.0 (/ x (* y t))))))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
	double tmp;
	if (x <= -1.35e+174) {
		tmp = x / (t * -z);
	} else if (x <= 3.6e+171) {
		tmp = 1.0;
	} else {
		tmp = 1.0 + (x / (y * t));
	}
	return tmp;
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this 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) :: tmp
    if (x <= (-1.35d+174)) then
        tmp = x / (t * -z)
    else if (x <= 3.6d+171) then
        tmp = 1.0d0
    else
        tmp = 1.0d0 + (x / (y * t))
    end if
    code = tmp
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (x <= -1.35e+174) {
		tmp = x / (t * -z);
	} else if (x <= 3.6e+171) {
		tmp = 1.0;
	} else {
		tmp = 1.0 + (x / (y * t));
	}
	return tmp;
}
[x, y, z, t] = sort([x, y, z, t])
def code(x, y, z, t):
	tmp = 0
	if x <= -1.35e+174:
		tmp = x / (t * -z)
	elif x <= 3.6e+171:
		tmp = 1.0
	else:
		tmp = 1.0 + (x / (y * t))
	return tmp
x, y, z, t = sort([x, y, z, t])
function code(x, y, z, t)
	tmp = 0.0
	if (x <= -1.35e+174)
		tmp = Float64(x / Float64(t * Float64(-z)));
	elseif (x <= 3.6e+171)
		tmp = 1.0;
	else
		tmp = Float64(1.0 + Float64(x / Float64(y * t)));
	end
	return tmp
end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (x <= -1.35e+174)
		tmp = x / (t * -z);
	elseif (x <= 3.6e+171)
		tmp = 1.0;
	else
		tmp = 1.0 + (x / (y * t));
	end
	tmp_2 = tmp;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := If[LessEqual[x, -1.35e+174], N[(x / N[(t * (-z)), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.6e+171], 1.0, N[(1.0 + N[(x / N[(y * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.35 \cdot 10^{+174}:\\
\;\;\;\;\frac{x}{t \cdot \left(-z\right)}\\

\mathbf{elif}\;x \leq 3.6 \cdot 10^{+171}:\\
\;\;\;\;1\\

\mathbf{else}:\\
\;\;\;\;1 + \frac{x}{y \cdot t}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.35e174

    1. Initial program 99.2%

      \[1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 60.5%

      \[\leadsto 1 - \color{blue}{\frac{x}{t \cdot z}} \]
    4. Taylor expanded in x around inf 43.1%

      \[\leadsto \color{blue}{-1 \cdot \frac{x}{t \cdot z}} \]
    5. Step-by-step derivation
      1. associate-*r/43.1%

        \[\leadsto \color{blue}{\frac{-1 \cdot x}{t \cdot z}} \]
      2. mul-1-neg43.1%

        \[\leadsto \frac{\color{blue}{-x}}{t \cdot z} \]
    6. Simplified43.1%

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

    if -1.35e174 < x < 3.60000000000000018e171

    1. Initial program 98.0%

      \[1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 65.4%

      \[\leadsto 1 - \color{blue}{\frac{x}{t \cdot z}} \]
    4. Taylor expanded in x around 0 83.4%

      \[\leadsto \color{blue}{1} \]

    if 3.60000000000000018e171 < x

    1. Initial program 99.7%

      \[1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in t around inf 53.8%

      \[\leadsto 1 - \color{blue}{-1 \cdot \frac{x}{t \cdot \left(y - z\right)}} \]
    4. Step-by-step derivation
      1. associate-*r/53.8%

        \[\leadsto 1 - \color{blue}{\frac{-1 \cdot x}{t \cdot \left(y - z\right)}} \]
      2. neg-mul-153.8%

        \[\leadsto 1 - \frac{\color{blue}{-x}}{t \cdot \left(y - z\right)} \]
    5. Simplified53.8%

      \[\leadsto 1 - \color{blue}{\frac{-x}{t \cdot \left(y - z\right)}} \]
    6. Taylor expanded in y around inf 45.5%

      \[\leadsto \color{blue}{1 + \frac{x}{t \cdot y}} \]
    7. Step-by-step derivation
      1. *-commutative45.5%

        \[\leadsto 1 + \frac{x}{\color{blue}{y \cdot t}} \]
    8. Simplified45.5%

      \[\leadsto \color{blue}{1 + \frac{x}{y \cdot t}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification75.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.35 \cdot 10^{+174}:\\ \;\;\;\;\frac{x}{t \cdot \left(-z\right)}\\ \mathbf{elif}\;x \leq 3.6 \cdot 10^{+171}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{x}{y \cdot t}\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 98.5% accurate, 0.8× speedup?

\[\begin{array}{l} [x, y, z, t] = \mathsf{sort}([x, y, z, t])\\ \\ 1 + \frac{x}{y - t} \cdot \frac{1}{z - y} \end{array} \]
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
 :precision binary64
 (+ 1.0 (* (/ x (- y t)) (/ 1.0 (- z y)))))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
	return 1.0 + ((x / (y - t)) * (1.0 / (z - y)));
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this 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
    code = 1.0d0 + ((x / (y - t)) * (1.0d0 / (z - y)))
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
	return 1.0 + ((x / (y - t)) * (1.0 / (z - y)));
}
[x, y, z, t] = sort([x, y, z, t])
def code(x, y, z, t):
	return 1.0 + ((x / (y - t)) * (1.0 / (z - y)))
x, y, z, t = sort([x, y, z, t])
function code(x, y, z, t)
	return Float64(1.0 + Float64(Float64(x / Float64(y - t)) * Float64(1.0 / Float64(z - y))))
end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp = code(x, y, z, t)
	tmp = 1.0 + ((x / (y - t)) * (1.0 / (z - y)));
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := N[(1.0 + N[(N[(x / N[(y - t), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(z - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
1 + \frac{x}{y - t} \cdot \frac{1}{z - y}
\end{array}
Derivation
  1. Initial program 98.3%

    \[1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. *-un-lft-identity98.3%

      \[\leadsto 1 - \frac{\color{blue}{1 \cdot x}}{\left(y - z\right) \cdot \left(y - t\right)} \]
    2. times-frac97.4%

      \[\leadsto 1 - \color{blue}{\frac{1}{y - z} \cdot \frac{x}{y - t}} \]
  4. Applied egg-rr97.4%

    \[\leadsto 1 - \color{blue}{\frac{1}{y - z} \cdot \frac{x}{y - t}} \]
  5. Final simplification97.4%

    \[\leadsto 1 + \frac{x}{y - t} \cdot \frac{1}{z - y} \]
  6. Add Preprocessing

Alternative 12: 72.8% accurate, 1.0× speedup?

\[\begin{array}{l} [x, y, z, t] = \mathsf{sort}([x, y, z, t])\\ \\ \begin{array}{l} \mathbf{if}\;x \leq -1.35 \cdot 10^{+174}:\\ \;\;\;\;\frac{x}{t \cdot \left(-z\right)}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
 :precision binary64
 (if (<= x -1.35e+174) (/ x (* t (- z))) 1.0))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
	double tmp;
	if (x <= -1.35e+174) {
		tmp = x / (t * -z);
	} else {
		tmp = 1.0;
	}
	return tmp;
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this 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) :: tmp
    if (x <= (-1.35d+174)) then
        tmp = x / (t * -z)
    else
        tmp = 1.0d0
    end if
    code = tmp
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (x <= -1.35e+174) {
		tmp = x / (t * -z);
	} else {
		tmp = 1.0;
	}
	return tmp;
}
[x, y, z, t] = sort([x, y, z, t])
def code(x, y, z, t):
	tmp = 0
	if x <= -1.35e+174:
		tmp = x / (t * -z)
	else:
		tmp = 1.0
	return tmp
x, y, z, t = sort([x, y, z, t])
function code(x, y, z, t)
	tmp = 0.0
	if (x <= -1.35e+174)
		tmp = Float64(x / Float64(t * Float64(-z)));
	else
		tmp = 1.0;
	end
	return tmp
end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (x <= -1.35e+174)
		tmp = x / (t * -z);
	else
		tmp = 1.0;
	end
	tmp_2 = tmp;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := If[LessEqual[x, -1.35e+174], N[(x / N[(t * (-z)), $MachinePrecision]), $MachinePrecision], 1.0]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.35 \cdot 10^{+174}:\\
\;\;\;\;\frac{x}{t \cdot \left(-z\right)}\\

\mathbf{else}:\\
\;\;\;\;1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.35e174

    1. Initial program 99.2%

      \[1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 60.5%

      \[\leadsto 1 - \color{blue}{\frac{x}{t \cdot z}} \]
    4. Taylor expanded in x around inf 43.1%

      \[\leadsto \color{blue}{-1 \cdot \frac{x}{t \cdot z}} \]
    5. Step-by-step derivation
      1. associate-*r/43.1%

        \[\leadsto \color{blue}{\frac{-1 \cdot x}{t \cdot z}} \]
      2. mul-1-neg43.1%

        \[\leadsto \frac{\color{blue}{-x}}{t \cdot z} \]
    6. Simplified43.1%

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

    if -1.35e174 < x

    1. Initial program 98.2%

      \[1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 60.7%

      \[\leadsto 1 - \color{blue}{\frac{x}{t \cdot z}} \]
    4. Taylor expanded in x around 0 77.7%

      \[\leadsto \color{blue}{1} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification73.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.35 \cdot 10^{+174}:\\ \;\;\;\;\frac{x}{t \cdot \left(-z\right)}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
  5. Add Preprocessing

Alternative 13: 99.0% accurate, 1.0× speedup?

\[\begin{array}{l} [x, y, z, t] = \mathsf{sort}([x, y, z, t])\\ \\ 1 + \frac{x}{\left(y - z\right) \cdot \left(t - y\right)} \end{array} \]
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t) :precision binary64 (+ 1.0 (/ x (* (- y z) (- t y)))))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
	return 1.0 + (x / ((y - z) * (t - y)));
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this 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
    code = 1.0d0 + (x / ((y - z) * (t - y)))
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
	return 1.0 + (x / ((y - z) * (t - y)));
}
[x, y, z, t] = sort([x, y, z, t])
def code(x, y, z, t):
	return 1.0 + (x / ((y - z) * (t - y)))
x, y, z, t = sort([x, y, z, t])
function code(x, y, z, t)
	return Float64(1.0 + Float64(x / Float64(Float64(y - z) * Float64(t - y))))
end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp = code(x, y, z, t)
	tmp = 1.0 + (x / ((y - z) * (t - y)));
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := N[(1.0 + N[(x / N[(N[(y - z), $MachinePrecision] * N[(t - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
1 + \frac{x}{\left(y - z\right) \cdot \left(t - y\right)}
\end{array}
Derivation
  1. Initial program 98.3%

    \[1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)} \]
  2. Add Preprocessing
  3. Final simplification98.3%

    \[\leadsto 1 + \frac{x}{\left(y - z\right) \cdot \left(t - y\right)} \]
  4. Add Preprocessing

Alternative 14: 74.7% accurate, 11.0× speedup?

\[\begin{array}{l} [x, y, z, t] = \mathsf{sort}([x, y, z, t])\\ \\ 1 \end{array} \]
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t) :precision binary64 1.0)
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
	return 1.0;
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this 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
    code = 1.0d0
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
	return 1.0;
}
[x, y, z, t] = sort([x, y, z, t])
def code(x, y, z, t):
	return 1.0
x, y, z, t = sort([x, y, z, t])
function code(x, y, z, t)
	return 1.0
end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp = code(x, y, z, t)
	tmp = 1.0;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := 1.0
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
1
\end{array}
Derivation
  1. Initial program 98.3%

    \[1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)} \]
  2. Add Preprocessing
  3. Taylor expanded in y around 0 60.6%

    \[\leadsto 1 - \color{blue}{\frac{x}{t \cdot z}} \]
  4. Taylor expanded in x around 0 71.7%

    \[\leadsto \color{blue}{1} \]
  5. Add Preprocessing

Reproduce

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