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

Percentage Accurate: 99.0% → 98.8%
Time: 9.5s
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.8% accurate, 0.0× speedup?

\[\begin{array}{l} [z, t] = \mathsf{sort}([z, t])\\ \\ \begin{array}{l} t_1 := \sqrt[3]{y - z}\\ 1 - \frac{\frac{x}{\left(y - t\right) \cdot t_1}}{{t_1}^{2}} \end{array} \end{array} \]
NOTE: z and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (cbrt (- y z)))) (- 1.0 (/ (/ x (* (- y t) t_1)) (pow t_1 2.0)))))
assert(z < t);
double code(double x, double y, double z, double t) {
	double t_1 = cbrt((y - z));
	return 1.0 - ((x / ((y - t) * t_1)) / pow(t_1, 2.0));
}
assert z < t;
public static double code(double x, double y, double z, double t) {
	double t_1 = Math.cbrt((y - z));
	return 1.0 - ((x / ((y - t) * t_1)) / Math.pow(t_1, 2.0));
}
z, t = sort([z, t])
function code(x, y, z, t)
	t_1 = cbrt(Float64(y - z))
	return Float64(1.0 - Float64(Float64(x / Float64(Float64(y - t) * t_1)) / (t_1 ^ 2.0)))
end
NOTE: z and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Power[N[(y - z), $MachinePrecision], 1/3], $MachinePrecision]}, N[(1.0 - N[(N[(x / N[(N[(y - t), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision] / N[Power[t$95$1, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
t_1 := \sqrt[3]{y - z}\\
1 - \frac{\frac{x}{\left(y - t\right) \cdot t_1}}{{t_1}^{2}}
\end{array}
\end{array}
Derivation
  1. Initial program 98.5%

    \[1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)} \]
  2. Step-by-step derivation
    1. associate-/l/99.2%

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

      \[\leadsto 1 - \frac{\color{blue}{x \cdot \frac{1}{y - t}}}{y - z} \]
    3. add-cube-cbrt98.8%

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

      \[\leadsto 1 - \color{blue}{\frac{x}{\sqrt[3]{y - z} \cdot \sqrt[3]{y - z}} \cdot \frac{\frac{1}{y - t}}{\sqrt[3]{y - z}}} \]
    5. pow299.2%

      \[\leadsto 1 - \frac{x}{\color{blue}{{\left(\sqrt[3]{y - z}\right)}^{2}}} \cdot \frac{\frac{1}{y - t}}{\sqrt[3]{y - z}} \]
  3. Applied egg-rr99.2%

    \[\leadsto 1 - \color{blue}{\frac{x}{{\left(\sqrt[3]{y - z}\right)}^{2}} \cdot \frac{\frac{1}{y - t}}{\sqrt[3]{y - z}}} \]
  4. Step-by-step derivation
    1. associate-*l/99.2%

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

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

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

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

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

    \[\leadsto 1 - \color{blue}{\frac{\frac{x}{\left(y - t\right) \cdot \sqrt[3]{y - z}}}{{\left(\sqrt[3]{y - z}\right)}^{2}}} \]
  6. Final simplification99.2%

    \[\leadsto 1 - \frac{\frac{x}{\left(y - t\right) \cdot \sqrt[3]{y - z}}}{{\left(\sqrt[3]{y - z}\right)}^{2}} \]

Alternative 2: 85.5% accurate, 0.8× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.05e-112 or 7.1999999999999996e-65 < y

    1. Initial program 99.7%

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

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

    if -1.05e-112 < y < 7.1999999999999996e-65

    1. Initial program 96.1%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.05 \cdot 10^{-112} \lor \neg \left(y \leq 7.2 \cdot 10^{-65}\right):\\ \;\;\;\;1 - \frac{x}{y \cdot \left(y - z\right)}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{x}{t \cdot z}\\ \end{array} \]

Alternative 3: 85.1% accurate, 0.8× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -4.79999999999999985e-124 or 5.59999999999999984e-161 < y

    1. Initial program 99.4%

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

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

    if -4.79999999999999985e-124 < y < 5.59999999999999984e-161

    1. Initial program 95.7%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -4.8 \cdot 10^{-124} \lor \neg \left(y \leq 5.6 \cdot 10^{-161}\right):\\ \;\;\;\;1 - \frac{x}{y \cdot \left(y - t\right)}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{x}{t \cdot z}\\ \end{array} \]

Alternative 4: 84.7% accurate, 0.8× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.05e-123 or 5.59999999999999984e-161 < y

    1. Initial program 99.4%

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

      \[\leadsto 1 - \color{blue}{\frac{x}{\left(y - t\right) \cdot y}} \]
    3. Step-by-step derivation
      1. associate-/l/89.8%

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

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

    if -1.05e-123 < y < 5.59999999999999984e-161

    1. Initial program 95.7%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.05 \cdot 10^{-123} \lor \neg \left(y \leq 5.6 \cdot 10^{-161}\right):\\ \;\;\;\;1 - \frac{\frac{x}{y}}{y - t}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{x}{t \cdot z}\\ \end{array} \]

Alternative 5: 91.0% accurate, 0.8× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -8.80000000000000035e-61 or 2.3999999999999998e-24 < t

    1. Initial program 99.7%

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

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

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

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

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

    if -8.80000000000000035e-61 < t < 2.3999999999999998e-24

    1. Initial program 96.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -8.8 \cdot 10^{-61} \lor \neg \left(t \leq 2.4 \cdot 10^{-24}\right):\\ \;\;\;\;1 + \frac{x}{t \cdot \left(y - z\right)}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{x}{y \cdot \left(y - z\right)}\\ \end{array} \]

Alternative 6: 81.4% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 99.6%

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

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

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

    if -3.0000000000000002e-126 < y < 6.59999999999999968e-24

    1. Initial program 96.4%

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

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

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

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

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

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

        \[\leadsto 1 - \color{blue}{\frac{1 \cdot 1}{\frac{t}{x} \cdot z}} \]
      3. metadata-eval72.5%

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

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

    if 6.59999999999999968e-24 < y

    1. Initial program 99.9%

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

      \[\leadsto 1 - \color{blue}{\frac{x}{{y}^{2}}} \]
    3. Step-by-step derivation
      1. unpow294.4%

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

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

      \[\leadsto 1 - \color{blue}{\frac{\frac{x}{y}}{y}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification83.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3 \cdot 10^{-126}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 6.6 \cdot 10^{-24}:\\ \;\;\;\;1 + \frac{-1}{z \cdot \frac{t}{x}}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{\frac{x}{y}}{y}\\ \end{array} \]

Alternative 7: 84.9% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 99.6%

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

      \[\leadsto 1 - \color{blue}{\frac{x}{\left(y - t\right) \cdot y}} \]
    3. Step-by-step derivation
      1. associate-/l/92.1%

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

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

    if -6.9999999999999995e-129 < y < 5.59999999999999984e-161

    1. Initial program 95.7%

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

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

    if 5.59999999999999984e-161 < y

    1. Initial program 99.3%

      \[1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)} \]
    2. Step-by-step derivation
      1. associate-/l/100.0%

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

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

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

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

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

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

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

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

        \[\leadsto 1 - \color{blue}{\frac{\frac{x}{y - t}}{y}} \]
    8. Simplified88.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -7 \cdot 10^{-129}:\\ \;\;\;\;1 - \frac{\frac{x}{y}}{y - t}\\ \mathbf{elif}\;y \leq 5.6 \cdot 10^{-161}:\\ \;\;\;\;1 - \frac{x}{t \cdot z}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{\frac{x}{y - t}}{y}\\ \end{array} \]

Alternative 8: 92.5% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 99.5%

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

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

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

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

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

    if -1.4499999999999999e-53 < z < 1.6500000000000001e-219

    1. Initial program 96.4%

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

      \[\leadsto 1 - \color{blue}{\frac{x}{\left(y - t\right) \cdot y}} \]
    3. Step-by-step derivation
      1. associate-/l/88.1%

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

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

    if 1.6500000000000001e-219 < z

    1. Initial program 99.3%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.45 \cdot 10^{-53}:\\ \;\;\;\;1 + \frac{x}{\left(y - t\right) \cdot z}\\ \mathbf{elif}\;z \leq 1.65 \cdot 10^{-219}:\\ \;\;\;\;1 - \frac{\frac{x}{y}}{y - t}\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{x}{t \cdot \left(y - z\right)}\\ \end{array} \]

Alternative 9: 98.4% accurate, 0.8× speedup?

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

    \[1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)} \]
  2. Step-by-step derivation
    1. associate-/r*98.8%

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

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

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

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

Alternative 10: 82.9% accurate, 1.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -4.79999999999999985e-124 or 6.00000000000000024e-61 < y

    1. Initial program 99.7%

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

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

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

    if -4.79999999999999985e-124 < y < 6.00000000000000024e-61

    1. Initial program 95.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -4.8 \cdot 10^{-124}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 6 \cdot 10^{-61}:\\ \;\;\;\;1 - \frac{x}{t \cdot z}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]

Alternative 11: 81.8% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 99.6%

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

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

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

    if -1.05e-123 < y < 6.5999999999999997e-26

    1. Initial program 96.4%

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

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

    if 6.5999999999999997e-26 < y

    1. Initial program 99.9%

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

      \[\leadsto 1 - \color{blue}{\frac{x}{{y}^{2}}} \]
    3. Step-by-step derivation
      1. unpow294.4%

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

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

      \[\leadsto 1 - \color{blue}{\frac{\frac{x}{y}}{y}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification83.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.05 \cdot 10^{-123}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 6.6 \cdot 10^{-26}:\\ \;\;\;\;1 - \frac{x}{t \cdot z}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{\frac{x}{y}}{y}\\ \end{array} \]

Alternative 12: 99.0% accurate, 1.0× speedup?

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

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

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

Alternative 13: 98.4% accurate, 1.0× speedup?

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

    \[1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)} \]
  2. Step-by-step derivation
    1. associate-/l/99.2%

      \[\leadsto 1 - \color{blue}{\frac{\frac{x}{y - t}}{y - z}} \]
  3. Simplified99.2%

    \[\leadsto \color{blue}{1 - \frac{\frac{x}{y - t}}{y - z}} \]
  4. Final simplification99.2%

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

Alternative 14: 74.5% accurate, 11.0× speedup?

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

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

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

    \[\leadsto \color{blue}{1} \]
  4. Final simplification74.6%

    \[\leadsto 1 \]

Reproduce

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