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

Percentage Accurate: 99.0% → 98.5%
Time: 12.8s
Alternatives: 13
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 13 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.5% accurate, 0.8× speedup?

\[\begin{array}{l} [x, y, z, t] = \mathsf{sort}([x, y, z, t])\\ \\ 1 + \frac{\frac{1}{y - z}}{\frac{t - y}{x}} \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 (/ (/ 1.0 (- y z)) (/ (- t y) x))))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
	return 1.0 + ((1.0 / (y - z)) / ((t - y) / x));
}
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 + ((1.0d0 / (y - z)) / ((t - y) / x))
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
	return 1.0 + ((1.0 / (y - z)) / ((t - y) / x));
}
[x, y, z, t] = sort([x, y, z, t])
def code(x, y, z, t):
	return 1.0 + ((1.0 / (y - z)) / ((t - y) / x))
x, y, z, t = sort([x, y, z, t])
function code(x, y, z, t)
	return Float64(1.0 + Float64(Float64(1.0 / Float64(y - z)) / Float64(Float64(t - y) / x)))
end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp = code(x, y, z, t)
	tmp = 1.0 + ((1.0 / (y - z)) / ((t - y) / x));
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[(1.0 / N[(y - z), $MachinePrecision]), $MachinePrecision] / N[(N[(t - y), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
1 + \frac{\frac{1}{y - z}}{\frac{t - y}{x}}
\end{array}
Derivation
  1. Initial program 97.3%

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

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

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

    \[\leadsto 1 - \color{blue}{\frac{1}{y - z} \cdot \frac{x}{y - t}} \]
  5. Step-by-step derivation
    1. clear-num98.7%

      \[\leadsto 1 - \frac{1}{y - z} \cdot \color{blue}{\frac{1}{\frac{y - t}{x}}} \]
    2. div-inv98.8%

      \[\leadsto 1 - \color{blue}{\frac{\frac{1}{y - z}}{\frac{y - t}{x}}} \]
  6. Applied egg-rr98.8%

    \[\leadsto 1 - \color{blue}{\frac{\frac{1}{y - z}}{\frac{y - t}{x}}} \]
  7. Final simplification98.8%

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

Alternative 2: 89.0% accurate, 0.5× speedup?

\[\begin{array}{l} [x, y, z, t] = \mathsf{sort}([x, y, z, t])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq -1.26 \cdot 10^{-76} \lor \neg \left(y \leq 5.8 \cdot 10^{-55}\right):\\ \;\;\;\;1 + \frac{x}{y \cdot \left(z - y\right)}\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{1}{y - z} \cdot \frac{x}{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 -1.26e-76) (not (<= y 5.8e-55)))
   (+ 1.0 (/ x (* y (- z y))))
   (+ 1.0 (* (/ 1.0 (- y z)) (/ x t)))))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
	double tmp;
	if ((y <= -1.26e-76) || !(y <= 5.8e-55)) {
		tmp = 1.0 + (x / (y * (z - y)));
	} else {
		tmp = 1.0 + ((1.0 / (y - z)) * (x / 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 <= (-1.26d-76)) .or. (.not. (y <= 5.8d-55))) then
        tmp = 1.0d0 + (x / (y * (z - y)))
    else
        tmp = 1.0d0 + ((1.0d0 / (y - z)) * (x / 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 <= -1.26e-76) || !(y <= 5.8e-55)) {
		tmp = 1.0 + (x / (y * (z - y)));
	} else {
		tmp = 1.0 + ((1.0 / (y - z)) * (x / t));
	}
	return tmp;
}
[x, y, z, t] = sort([x, y, z, t])
def code(x, y, z, t):
	tmp = 0
	if (y <= -1.26e-76) or not (y <= 5.8e-55):
		tmp = 1.0 + (x / (y * (z - y)))
	else:
		tmp = 1.0 + ((1.0 / (y - z)) * (x / t))
	return tmp
x, y, z, t = sort([x, y, z, t])
function code(x, y, z, t)
	tmp = 0.0
	if ((y <= -1.26e-76) || !(y <= 5.8e-55))
		tmp = Float64(1.0 + Float64(x / Float64(y * Float64(z - y))));
	else
		tmp = Float64(1.0 + Float64(Float64(1.0 / Float64(y - z)) * Float64(x / 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 <= -1.26e-76) || ~((y <= 5.8e-55)))
		tmp = 1.0 + (x / (y * (z - y)));
	else
		tmp = 1.0 + ((1.0 / (y - z)) * (x / 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, -1.26e-76], N[Not[LessEqual[y, 5.8e-55]], $MachinePrecision]], N[(1.0 + N[(x / N[(y * N[(z - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(1.0 / N[(y - z), $MachinePrecision]), $MachinePrecision] * N[(x / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.26 \cdot 10^{-76} \lor \neg \left(y \leq 5.8 \cdot 10^{-55}\right):\\
\;\;\;\;1 + \frac{x}{y \cdot \left(z - y\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.26e-76 or 5.8e-55 < y

    1. Initial program 100.0%

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

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

    if -1.26e-76 < y < 5.8e-55

    1. Initial program 92.6%

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

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

        \[\leadsto 1 + \color{blue}{\frac{\frac{x}{t}}{y - z}} \]
      2. div-inv86.1%

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

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

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

Alternative 3: 89.1% accurate, 0.6× speedup?

\[\begin{array}{l} [x, y, z, t] = \mathsf{sort}([x, y, z, t])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq -2.5 \cdot 10^{-69} \lor \neg \left(y \leq 2.3 \cdot 10^{-55}\right):\\ \;\;\;\;1 + \frac{x}{y \cdot \left(z - y\right)}\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{\frac{x}{t}}{y - 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 (or (<= y -2.5e-69) (not (<= y 2.3e-55)))
   (+ 1.0 (/ x (* y (- z y))))
   (+ 1.0 (/ (/ x t) (- y z)))))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
	double tmp;
	if ((y <= -2.5e-69) || !(y <= 2.3e-55)) {
		tmp = 1.0 + (x / (y * (z - y)));
	} else {
		tmp = 1.0 + ((x / t) / (y - 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 ((y <= (-2.5d-69)) .or. (.not. (y <= 2.3d-55))) then
        tmp = 1.0d0 + (x / (y * (z - y)))
    else
        tmp = 1.0d0 + ((x / t) / (y - 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 ((y <= -2.5e-69) || !(y <= 2.3e-55)) {
		tmp = 1.0 + (x / (y * (z - y)));
	} else {
		tmp = 1.0 + ((x / t) / (y - z));
	}
	return tmp;
}
[x, y, z, t] = sort([x, y, z, t])
def code(x, y, z, t):
	tmp = 0
	if (y <= -2.5e-69) or not (y <= 2.3e-55):
		tmp = 1.0 + (x / (y * (z - y)))
	else:
		tmp = 1.0 + ((x / t) / (y - z))
	return tmp
x, y, z, t = sort([x, y, z, t])
function code(x, y, z, t)
	tmp = 0.0
	if ((y <= -2.5e-69) || !(y <= 2.3e-55))
		tmp = Float64(1.0 + Float64(x / Float64(y * Float64(z - y))));
	else
		tmp = Float64(1.0 + Float64(Float64(x / t) / Float64(y - 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 ((y <= -2.5e-69) || ~((y <= 2.3e-55)))
		tmp = 1.0 + (x / (y * (z - y)));
	else
		tmp = 1.0 + ((x / t) / (y - 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[Or[LessEqual[y, -2.5e-69], N[Not[LessEqual[y, 2.3e-55]], $MachinePrecision]], N[(1.0 + N[(x / N[(y * N[(z - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(x / t), $MachinePrecision] / N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.5 \cdot 10^{-69} \lor \neg \left(y \leq 2.3 \cdot 10^{-55}\right):\\
\;\;\;\;1 + \frac{x}{y \cdot \left(z - y\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -2.50000000000000017e-69 or 2.30000000000000011e-55 < y

    1. Initial program 100.0%

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

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

    if -2.50000000000000017e-69 < y < 2.30000000000000011e-55

    1. Initial program 92.6%

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

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

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

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

        \[\leadsto 1 - \frac{1}{y - z} \cdot \color{blue}{\frac{1}{\frac{y - t}{x}}} \]
      2. div-inv96.9%

        \[\leadsto 1 - \color{blue}{\frac{\frac{1}{y - z}}{\frac{y - t}{x}}} \]
    6. Applied egg-rr96.9%

      \[\leadsto 1 - \color{blue}{\frac{\frac{1}{y - z}}{\frac{y - t}{x}}} \]
    7. Taylor expanded in t around inf 84.4%

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

        \[\leadsto 1 + \color{blue}{\frac{\frac{x}{t}}{y - z}} \]
    9. Simplified86.1%

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

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

Alternative 4: 89.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 -8 \cdot 10^{-69} \lor \neg \left(y \leq 2.2 \cdot 10^{-55}\right):\\ \;\;\;\;1 + \frac{\frac{x}{y}}{t - y}\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{\frac{x}{t}}{y - 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 (or (<= y -8e-69) (not (<= y 2.2e-55)))
   (+ 1.0 (/ (/ x y) (- t y)))
   (+ 1.0 (/ (/ x t) (- y z)))))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
	double tmp;
	if ((y <= -8e-69) || !(y <= 2.2e-55)) {
		tmp = 1.0 + ((x / y) / (t - y));
	} else {
		tmp = 1.0 + ((x / t) / (y - 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 ((y <= (-8d-69)) .or. (.not. (y <= 2.2d-55))) then
        tmp = 1.0d0 + ((x / y) / (t - y))
    else
        tmp = 1.0d0 + ((x / t) / (y - 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 ((y <= -8e-69) || !(y <= 2.2e-55)) {
		tmp = 1.0 + ((x / y) / (t - y));
	} else {
		tmp = 1.0 + ((x / t) / (y - z));
	}
	return tmp;
}
[x, y, z, t] = sort([x, y, z, t])
def code(x, y, z, t):
	tmp = 0
	if (y <= -8e-69) or not (y <= 2.2e-55):
		tmp = 1.0 + ((x / y) / (t - y))
	else:
		tmp = 1.0 + ((x / t) / (y - z))
	return tmp
x, y, z, t = sort([x, y, z, t])
function code(x, y, z, t)
	tmp = 0.0
	if ((y <= -8e-69) || !(y <= 2.2e-55))
		tmp = Float64(1.0 + Float64(Float64(x / y) / Float64(t - y)));
	else
		tmp = Float64(1.0 + Float64(Float64(x / t) / Float64(y - 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 ((y <= -8e-69) || ~((y <= 2.2e-55)))
		tmp = 1.0 + ((x / y) / (t - y));
	else
		tmp = 1.0 + ((x / t) / (y - 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[Or[LessEqual[y, -8e-69], N[Not[LessEqual[y, 2.2e-55]], $MachinePrecision]], N[(1.0 + N[(N[(x / y), $MachinePrecision] / N[(t - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(x / t), $MachinePrecision] / N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8 \cdot 10^{-69} \lor \neg \left(y \leq 2.2 \cdot 10^{-55}\right):\\
\;\;\;\;1 + \frac{\frac{x}{y}}{t - y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -7.9999999999999997e-69 or 2.2e-55 < y

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{1 - \frac{x}{y \cdot \left(y - t\right)}} \]
    4. Step-by-step derivation
      1. sub-neg94.4%

        \[\leadsto \color{blue}{1 + \left(-\frac{x}{y \cdot \left(y - t\right)}\right)} \]
      2. associate-/r*94.4%

        \[\leadsto 1 + \left(-\color{blue}{\frac{\frac{x}{y}}{y - t}}\right) \]
      3. distribute-neg-frac294.4%

        \[\leadsto 1 + \color{blue}{\frac{\frac{x}{y}}{-\left(y - t\right)}} \]
      4. neg-sub094.4%

        \[\leadsto 1 + \frac{\frac{x}{y}}{\color{blue}{0 - \left(y - t\right)}} \]
      5. sub-neg94.4%

        \[\leadsto 1 + \frac{\frac{x}{y}}{0 - \color{blue}{\left(y + \left(-t\right)\right)}} \]
      6. +-commutative94.4%

        \[\leadsto 1 + \frac{\frac{x}{y}}{0 - \color{blue}{\left(\left(-t\right) + y\right)}} \]
      7. associate--r+94.4%

        \[\leadsto 1 + \frac{\frac{x}{y}}{\color{blue}{\left(0 - \left(-t\right)\right) - y}} \]
      8. neg-sub094.4%

        \[\leadsto 1 + \frac{\frac{x}{y}}{\color{blue}{\left(-\left(-t\right)\right)} - y} \]
      9. remove-double-neg94.4%

        \[\leadsto 1 + \frac{\frac{x}{y}}{\color{blue}{t} - y} \]
    5. Simplified94.4%

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

    if -7.9999999999999997e-69 < y < 2.2e-55

    1. Initial program 92.6%

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

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

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

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

        \[\leadsto 1 - \frac{1}{y - z} \cdot \color{blue}{\frac{1}{\frac{y - t}{x}}} \]
      2. div-inv96.9%

        \[\leadsto 1 - \color{blue}{\frac{\frac{1}{y - z}}{\frac{y - t}{x}}} \]
    6. Applied egg-rr96.9%

      \[\leadsto 1 - \color{blue}{\frac{\frac{1}{y - z}}{\frac{y - t}{x}}} \]
    7. Taylor expanded in t around inf 84.4%

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

        \[\leadsto 1 + \color{blue}{\frac{\frac{x}{t}}{y - z}} \]
    9. Simplified86.1%

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

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

Alternative 5: 91.9% accurate, 0.6× speedup?

\[\begin{array}{l} [x, y, z, t] = \mathsf{sort}([x, y, z, t])\\ \\ \begin{array}{l} \mathbf{if}\;z \leq -2 \cdot 10^{-126}:\\ \;\;\;\;1 - \frac{\frac{x}{z}}{t - y}\\ \mathbf{elif}\;z \leq 1.2 \cdot 10^{-226}:\\ \;\;\;\;1 + \frac{\frac{x}{y}}{t - y}\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{x}{\left(y - z\right) \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 (<= z -2e-126)
   (- 1.0 (/ (/ x z) (- t y)))
   (if (<= z 1.2e-226)
     (+ 1.0 (/ (/ x y) (- t y)))
     (+ 1.0 (/ x (* (- y z) t))))))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
	double tmp;
	if (z <= -2e-126) {
		tmp = 1.0 - ((x / z) / (t - y));
	} else if (z <= 1.2e-226) {
		tmp = 1.0 + ((x / y) / (t - y));
	} else {
		tmp = 1.0 + (x / ((y - 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 (z <= (-2d-126)) then
        tmp = 1.0d0 - ((x / z) / (t - y))
    else if (z <= 1.2d-226) then
        tmp = 1.0d0 + ((x / y) / (t - y))
    else
        tmp = 1.0d0 + (x / ((y - 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 (z <= -2e-126) {
		tmp = 1.0 - ((x / z) / (t - y));
	} else if (z <= 1.2e-226) {
		tmp = 1.0 + ((x / y) / (t - y));
	} else {
		tmp = 1.0 + (x / ((y - z) * t));
	}
	return tmp;
}
[x, y, z, t] = sort([x, y, z, t])
def code(x, y, z, t):
	tmp = 0
	if z <= -2e-126:
		tmp = 1.0 - ((x / z) / (t - y))
	elif z <= 1.2e-226:
		tmp = 1.0 + ((x / y) / (t - y))
	else:
		tmp = 1.0 + (x / ((y - z) * t))
	return tmp
x, y, z, t = sort([x, y, z, t])
function code(x, y, z, t)
	tmp = 0.0
	if (z <= -2e-126)
		tmp = Float64(1.0 - Float64(Float64(x / z) / Float64(t - y)));
	elseif (z <= 1.2e-226)
		tmp = Float64(1.0 + Float64(Float64(x / y) / Float64(t - y)));
	else
		tmp = Float64(1.0 + Float64(x / Float64(Float64(y - 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 (z <= -2e-126)
		tmp = 1.0 - ((x / z) / (t - y));
	elseif (z <= 1.2e-226)
		tmp = 1.0 + ((x / y) / (t - y));
	else
		tmp = 1.0 + (x / ((y - 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[LessEqual[z, -2e-126], N[(1.0 - N[(N[(x / z), $MachinePrecision] / N[(t - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.2e-226], N[(1.0 + N[(N[(x / y), $MachinePrecision] / N[(t - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(x / N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2 \cdot 10^{-126}:\\
\;\;\;\;1 - \frac{\frac{x}{z}}{t - y}\\

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

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


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

    1. Initial program 98.9%

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

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

        \[\leadsto 1 + \color{blue}{\frac{\frac{x}{z}}{y - t}} \]
    5. Simplified89.4%

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

    if -1.9999999999999999e-126 < z < 1.2e-226

    1. Initial program 92.2%

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

      \[\leadsto \color{blue}{1 - \frac{x}{y \cdot \left(y - t\right)}} \]
    4. Step-by-step derivation
      1. sub-neg84.1%

        \[\leadsto \color{blue}{1 + \left(-\frac{x}{y \cdot \left(y - t\right)}\right)} \]
      2. associate-/r*85.3%

        \[\leadsto 1 + \left(-\color{blue}{\frac{\frac{x}{y}}{y - t}}\right) \]
      3. distribute-neg-frac285.3%

        \[\leadsto 1 + \color{blue}{\frac{\frac{x}{y}}{-\left(y - t\right)}} \]
      4. neg-sub085.3%

        \[\leadsto 1 + \frac{\frac{x}{y}}{\color{blue}{0 - \left(y - t\right)}} \]
      5. sub-neg85.3%

        \[\leadsto 1 + \frac{\frac{x}{y}}{0 - \color{blue}{\left(y + \left(-t\right)\right)}} \]
      6. +-commutative85.3%

        \[\leadsto 1 + \frac{\frac{x}{y}}{0 - \color{blue}{\left(\left(-t\right) + y\right)}} \]
      7. associate--r+85.3%

        \[\leadsto 1 + \frac{\frac{x}{y}}{\color{blue}{\left(0 - \left(-t\right)\right) - y}} \]
      8. neg-sub085.3%

        \[\leadsto 1 + \frac{\frac{x}{y}}{\color{blue}{\left(-\left(-t\right)\right)} - y} \]
      9. remove-double-neg85.3%

        \[\leadsto 1 + \frac{\frac{x}{y}}{\color{blue}{t} - y} \]
    5. Simplified85.3%

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

    if 1.2e-226 < 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 t around inf 84.5%

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

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

Alternative 6: 87.3% accurate, 0.6× speedup?

\[\begin{array}{l} [x, y, z, t] = \mathsf{sort}([x, y, z, t])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq -2.3 \cdot 10^{-23}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 8.5 \cdot 10^{-55}:\\ \;\;\;\;1 + \frac{\frac{x}{t}}{y - 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 -2.3e-23) 1.0 (if (<= y 8.5e-55) (+ 1.0 (/ (/ x t) (- y z))) 1.0)))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
	double tmp;
	if (y <= -2.3e-23) {
		tmp = 1.0;
	} else if (y <= 8.5e-55) {
		tmp = 1.0 + ((x / t) / (y - 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 <= (-2.3d-23)) then
        tmp = 1.0d0
    else if (y <= 8.5d-55) then
        tmp = 1.0d0 + ((x / t) / (y - 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 <= -2.3e-23) {
		tmp = 1.0;
	} else if (y <= 8.5e-55) {
		tmp = 1.0 + ((x / t) / (y - 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 <= -2.3e-23:
		tmp = 1.0
	elif y <= 8.5e-55:
		tmp = 1.0 + ((x / t) / (y - 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 <= -2.3e-23)
		tmp = 1.0;
	elseif (y <= 8.5e-55)
		tmp = Float64(1.0 + Float64(Float64(x / t) / Float64(y - 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 <= -2.3e-23)
		tmp = 1.0;
	elseif (y <= 8.5e-55)
		tmp = 1.0 + ((x / t) / (y - 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, -2.3e-23], 1.0, If[LessEqual[y, 8.5e-55], N[(1.0 + N[(N[(x / t), $MachinePrecision] / N[(y - z), $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 -2.3 \cdot 10^{-23}:\\
\;\;\;\;1\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -2.3000000000000001e-23 or 8.49999999999999968e-55 < y

    1. Initial program 100.0%

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

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

    if -2.3000000000000001e-23 < y < 8.49999999999999968e-55

    1. Initial program 93.4%

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

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

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

      \[\leadsto 1 - \color{blue}{\frac{1}{y - z} \cdot \frac{x}{y - t}} \]
    5. Step-by-step derivation
      1. clear-num96.8%

        \[\leadsto 1 - \frac{1}{y - z} \cdot \color{blue}{\frac{1}{\frac{y - t}{x}}} \]
      2. div-inv97.2%

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

      \[\leadsto 1 - \color{blue}{\frac{\frac{1}{y - z}}{\frac{y - t}{x}}} \]
    7. Taylor expanded in t around inf 84.3%

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

        \[\leadsto 1 + \color{blue}{\frac{\frac{x}{t}}{y - z}} \]
    9. Simplified85.8%

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

Alternative 7: 87.7% 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^{-23}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 7.6 \cdot 10^{-56}:\\ \;\;\;\;1 + \frac{x}{\left(y - z\right) \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 -8.6e-23) 1.0 (if (<= y 7.6e-56) (+ 1.0 (/ x (* (- y 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 <= -8.6e-23) {
		tmp = 1.0;
	} else if (y <= 7.6e-56) {
		tmp = 1.0 + (x / ((y - 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 <= (-8.6d-23)) then
        tmp = 1.0d0
    else if (y <= 7.6d-56) then
        tmp = 1.0d0 + (x / ((y - 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 <= -8.6e-23) {
		tmp = 1.0;
	} else if (y <= 7.6e-56) {
		tmp = 1.0 + (x / ((y - 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 <= -8.6e-23:
		tmp = 1.0
	elif y <= 7.6e-56:
		tmp = 1.0 + (x / ((y - 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 <= -8.6e-23)
		tmp = 1.0;
	elseif (y <= 7.6e-56)
		tmp = Float64(1.0 + Float64(x / Float64(Float64(y - 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 <= -8.6e-23)
		tmp = 1.0;
	elseif (y <= 7.6e-56)
		tmp = 1.0 + (x / ((y - 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, -8.6e-23], 1.0, If[LessEqual[y, 7.6e-56], N[(1.0 + N[(x / N[(N[(y - z), $MachinePrecision] * 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 -8.6 \cdot 10^{-23}:\\
\;\;\;\;1\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -8.60000000000000004e-23 or 7.6000000000000004e-56 < y

    1. Initial program 100.0%

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

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

    if -8.60000000000000004e-23 < y < 7.6000000000000004e-56

    1. Initial program 93.4%

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

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

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

Alternative 8: 83.4% accurate, 0.6× speedup?

\[\begin{array}{l} [x, y, z, t] = \mathsf{sort}([x, y, z, t])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq -1.5 \cdot 10^{-48}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 7.6 \cdot 10^{-56}:\\ \;\;\;\;1 - \frac{\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 -1.5e-48) 1.0 (if (<= y 7.6e-56) (- 1.0 (/ (/ 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 <= -1.5e-48) {
		tmp = 1.0;
	} else if (y <= 7.6e-56) {
		tmp = 1.0 - ((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 <= (-1.5d-48)) then
        tmp = 1.0d0
    else if (y <= 7.6d-56) then
        tmp = 1.0d0 - ((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 <= -1.5e-48) {
		tmp = 1.0;
	} else if (y <= 7.6e-56) {
		tmp = 1.0 - ((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 <= -1.5e-48:
		tmp = 1.0
	elif y <= 7.6e-56:
		tmp = 1.0 - ((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 <= -1.5e-48)
		tmp = 1.0;
	elseif (y <= 7.6e-56)
		tmp = Float64(1.0 - Float64(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 <= -1.5e-48)
		tmp = 1.0;
	elseif (y <= 7.6e-56)
		tmp = 1.0 - ((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, -1.5e-48], 1.0, If[LessEqual[y, 7.6e-56], N[(1.0 - N[(N[(x / t), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], 1.0]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.5 \cdot 10^{-48}:\\
\;\;\;\;1\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.5e-48 or 7.6000000000000004e-56 < y

    1. Initial program 100.0%

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

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

    if -1.5e-48 < y < 7.6000000000000004e-56

    1. Initial program 93.1%

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

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

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

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

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

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

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

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

        \[\leadsto 1 - \color{blue}{\frac{\frac{x}{t}}{z}} \]
    9. Simplified76.4%

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

Alternative 9: 84.0% accurate, 0.6× speedup?

\[\begin{array}{l} [x, y, z, t] = \mathsf{sort}([x, y, z, t])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq -1.6 \cdot 10^{-48}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 1.6 \cdot 10^{-55}:\\ \;\;\;\;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 -1.6e-48) 1.0 (if (<= y 1.6e-55) (- 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 <= -1.6e-48) {
		tmp = 1.0;
	} else if (y <= 1.6e-55) {
		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 <= (-1.6d-48)) then
        tmp = 1.0d0
    else if (y <= 1.6d-55) 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 <= -1.6e-48) {
		tmp = 1.0;
	} else if (y <= 1.6e-55) {
		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 <= -1.6e-48:
		tmp = 1.0
	elif y <= 1.6e-55:
		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 <= -1.6e-48)
		tmp = 1.0;
	elseif (y <= 1.6e-55)
		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 <= -1.6e-48)
		tmp = 1.0;
	elseif (y <= 1.6e-55)
		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, -1.6e-48], 1.0, If[LessEqual[y, 1.6e-55], 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 -1.6 \cdot 10^{-48}:\\
\;\;\;\;1\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.5999999999999999e-48 or 1.6000000000000001e-55 < y

    1. Initial program 100.0%

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

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

    if -1.5999999999999999e-48 < y < 1.6000000000000001e-55

    1. Initial program 93.1%

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

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

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

Alternative 10: 98.5% accurate, 0.8× speedup?

\[\begin{array}{l} [x, y, z, t] = \mathsf{sort}([x, y, z, t])\\ \\ 1 + \frac{1}{\left(y - z\right) \cdot \frac{t - y}{x}} \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 (/ 1.0 (* (- y z) (/ (- t y) x)))))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
	return 1.0 + (1.0 / ((y - z) * ((t - y) / x)));
}
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 + (1.0d0 / ((y - z) * ((t - y) / x)))
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
	return 1.0 + (1.0 / ((y - z) * ((t - y) / x)));
}
[x, y, z, t] = sort([x, y, z, t])
def code(x, y, z, t):
	return 1.0 + (1.0 / ((y - z) * ((t - y) / x)))
x, y, z, t = sort([x, y, z, t])
function code(x, y, z, t)
	return Float64(1.0 + Float64(1.0 / Float64(Float64(y - z) * Float64(Float64(t - y) / x))))
end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp = code(x, y, z, t)
	tmp = 1.0 + (1.0 / ((y - z) * ((t - y) / x)));
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[(1.0 / N[(N[(y - z), $MachinePrecision] * N[(N[(t - y), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
1 + \frac{1}{\left(y - z\right) \cdot \frac{t - y}{x}}
\end{array}
Derivation
  1. Initial program 97.3%

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

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

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

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

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

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

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

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

Alternative 11: 98.4% accurate, 0.8× speedup?

\[\begin{array}{l} [x, y, z, t] = \mathsf{sort}([x, y, z, t])\\ \\ 1 + \frac{1}{y - z} \cdot \frac{x}{t - 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 (* (/ 1.0 (- y z)) (/ x (- t y)))))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
	return 1.0 + ((1.0 / (y - z)) * (x / (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 + ((1.0d0 / (y - z)) * (x / (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 + ((1.0 / (y - z)) * (x / (t - y)));
}
[x, y, z, t] = sort([x, y, z, t])
def code(x, y, z, t):
	return 1.0 + ((1.0 / (y - z)) * (x / (t - y)))
x, y, z, t = sort([x, y, z, t])
function code(x, y, z, t)
	return Float64(1.0 + Float64(Float64(1.0 / Float64(y - z)) * Float64(x / Float64(t - y))))
end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp = code(x, y, z, t)
	tmp = 1.0 + ((1.0 / (y - z)) * (x / (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[(N[(1.0 / N[(y - z), $MachinePrecision]), $MachinePrecision] * N[(x / N[(t - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
1 + \frac{1}{y - z} \cdot \frac{x}{t - y}
\end{array}
Derivation
  1. Initial program 97.3%

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

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

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

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

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

Alternative 12: 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 97.3%

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

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

Alternative 13: 74.9% 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 97.3%

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

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

Reproduce

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