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

Percentage Accurate: 99.2% → 98.4%
Time: 8.3s
Alternatives: 12
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 12 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.2% 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.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 99.6%

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

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

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

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

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

Alternative 2: 85.3% accurate, 0.8× speedup?

\[\begin{array}{l} [z, t] = \mathsf{sort}([z, t])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq -6.2 \cdot 10^{-98} \lor \neg \left(y \leq 3.3 \cdot 10^{-42}\right):\\ \;\;\;\;1 - \frac{x}{y \cdot \left(y - z\right)}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{\frac{x}{t}}{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 -6.2e-98) (not (<= y 3.3e-42)))
   (- 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 <= -6.2e-98) || !(y <= 3.3e-42)) {
		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 <= (-6.2d-98)) .or. (.not. (y <= 3.3d-42))) 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 <= -6.2e-98) || !(y <= 3.3e-42)) {
		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 <= -6.2e-98) or not (y <= 3.3e-42):
		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 <= -6.2e-98) || !(y <= 3.3e-42))
		tmp = Float64(1.0 - Float64(x / Float64(y * Float64(y - z))));
	else
		tmp = Float64(1.0 - Float64(Float64(x / 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 <= -6.2e-98) || ~((y <= 3.3e-42)))
		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, -6.2e-98], N[Not[LessEqual[y, 3.3e-42]], $MachinePrecision]], N[(1.0 - N[(x / N[(y * N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(N[(x / t), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.2 \cdot 10^{-98} \lor \neg \left(y \leq 3.3 \cdot 10^{-42}\right):\\
\;\;\;\;1 - \frac{x}{y \cdot \left(y - z\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -6.2e-98 or 3.3000000000000002e-42 < y

    1. Initial program 100.0%

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

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

    if -6.2e-98 < y < 3.3000000000000002e-42

    1. Initial program 98.9%

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

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

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

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

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

Alternative 3: 91.3% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 99.9%

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

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

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

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

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

    if -2.7999999999999999e-70 < z < 2.15000000000000007e-10

    1. Initial program 99.0%

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

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

    if 2.15000000000000007e-10 < z

    1. Initial program 100.0%

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

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

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

Alternative 4: 92.5% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 99.9%

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

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

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

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

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

    if -2.8999999999999998e-69 < z < 6.1999999999999996e-156

    1. Initial program 98.8%

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

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

    if 6.1999999999999996e-156 < z

    1. Initial program 99.9%

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

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

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

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

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

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

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

Alternative 5: 92.5% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 99.9%

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

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

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

      \[\leadsto 1 - \color{blue}{\frac{x}{y - z} \cdot \frac{1}{y - t}} \]
    4. Step-by-step derivation
      1. un-div-inv99.9%

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

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

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

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

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

        \[\leadsto 1 - \color{blue}{\frac{\frac{-1 \cdot x}{z}}{y - t}} \]
      4. neg-mul-197.7%

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

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

    if -3.30000000000000016e-70 < z < 1.2e-152

    1. Initial program 98.8%

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

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

    if 1.2e-152 < z

    1. Initial program 99.9%

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

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

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

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

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

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

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

Alternative 6: 71.7% accurate, 1.0× speedup?

\[\begin{array}{l} [z, t] = \mathsf{sort}([z, t])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq -1600 \lor \neg \left(y \leq 880\right):\\ \;\;\;\;1 - \frac{x}{y \cdot t}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{x}{z \cdot t}\\ \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 -1600.0) (not (<= y 880.0)))
   (- 1.0 (/ x (* y t)))
   (- 1.0 (/ x (* z t)))))
assert(z < t);
double code(double x, double y, double z, double t) {
	double tmp;
	if ((y <= -1600.0) || !(y <= 880.0)) {
		tmp = 1.0 - (x / (y * t));
	} else {
		tmp = 1.0 - (x / (z * t));
	}
	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 <= (-1600.0d0)) .or. (.not. (y <= 880.0d0))) then
        tmp = 1.0d0 - (x / (y * t))
    else
        tmp = 1.0d0 - (x / (z * t))
    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 <= -1600.0) || !(y <= 880.0)) {
		tmp = 1.0 - (x / (y * t));
	} else {
		tmp = 1.0 - (x / (z * t));
	}
	return tmp;
}
[z, t] = sort([z, t])
def code(x, y, z, t):
	tmp = 0
	if (y <= -1600.0) or not (y <= 880.0):
		tmp = 1.0 - (x / (y * t))
	else:
		tmp = 1.0 - (x / (z * t))
	return tmp
z, t = sort([z, t])
function code(x, y, z, t)
	tmp = 0.0
	if ((y <= -1600.0) || !(y <= 880.0))
		tmp = Float64(1.0 - Float64(x / Float64(y * t)));
	else
		tmp = Float64(1.0 - Float64(x / Float64(z * t)));
	end
	return tmp
end
z, t = num2cell(sort([z, t])){:}
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if ((y <= -1600.0) || ~((y <= 880.0)))
		tmp = 1.0 - (x / (y * t));
	else
		tmp = 1.0 - (x / (z * t));
	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, -1600.0], N[Not[LessEqual[y, 880.0]], $MachinePrecision]], N[(1.0 - N[(x / N[(y * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(x / N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1600 \lor \neg \left(y \leq 880\right):\\
\;\;\;\;1 - \frac{x}{y \cdot t}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1600 or 880 < y

    1. Initial program 100.0%

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

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

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

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

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

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

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

        \[\leadsto 1 - \color{blue}{\frac{-1 \cdot x}{y \cdot t}} \]
      2. neg-mul-173.6%

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

      \[\leadsto 1 - \color{blue}{\frac{-x}{y \cdot t}} \]
    8. Step-by-step derivation
      1. expm1-log1p-u72.2%

        \[\leadsto 1 - \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{-x}{y \cdot t}\right)\right)} \]
      2. expm1-udef72.2%

        \[\leadsto 1 - \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{-x}{y \cdot t}\right)} - 1\right)} \]
      3. add-sqr-sqrt28.4%

        \[\leadsto 1 - \left(e^{\mathsf{log1p}\left(\frac{\color{blue}{\sqrt{-x} \cdot \sqrt{-x}}}{y \cdot t}\right)} - 1\right) \]
      4. sqrt-unprod62.9%

        \[\leadsto 1 - \left(e^{\mathsf{log1p}\left(\frac{\color{blue}{\sqrt{\left(-x\right) \cdot \left(-x\right)}}}{y \cdot t}\right)} - 1\right) \]
      5. sqr-neg62.9%

        \[\leadsto 1 - \left(e^{\mathsf{log1p}\left(\frac{\sqrt{\color{blue}{x \cdot x}}}{y \cdot t}\right)} - 1\right) \]
      6. sqrt-unprod43.8%

        \[\leadsto 1 - \left(e^{\mathsf{log1p}\left(\frac{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}{y \cdot t}\right)} - 1\right) \]
      7. add-sqr-sqrt72.3%

        \[\leadsto 1 - \left(e^{\mathsf{log1p}\left(\frac{\color{blue}{x}}{y \cdot t}\right)} - 1\right) \]
    9. Applied egg-rr72.3%

      \[\leadsto 1 - \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{x}{y \cdot t}\right)} - 1\right)} \]
    10. Step-by-step derivation
      1. expm1-def72.3%

        \[\leadsto 1 - \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{x}{y \cdot t}\right)\right)} \]
      2. expm1-log1p72.8%

        \[\leadsto 1 - \color{blue}{\frac{x}{y \cdot t}} \]
    11. Simplified72.8%

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

    if -1600 < y < 880

    1. Initial program 99.1%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1600 \lor \neg \left(y \leq 880\right):\\ \;\;\;\;1 - \frac{x}{y \cdot t}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{x}{z \cdot t}\\ \end{array} \]

Alternative 7: 81.0% accurate, 1.0× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -2.80000000000000018e46 or 6.59999999999999986e-40 < y

    1. Initial program 100.0%

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

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

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

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

    if -2.80000000000000018e46 < y < 6.59999999999999986e-40

    1. Initial program 99.1%

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

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

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

Alternative 8: 80.7% accurate, 1.0× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -2.80000000000000018e46 or 4.3999999999999999e-36 < y

    1. Initial program 100.0%

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

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

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

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

    if -2.80000000000000018e46 < y < 4.3999999999999999e-36

    1. Initial program 99.1%

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

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

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

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

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

Alternative 9: 80.5% accurate, 1.0× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -2.80000000000000018e46 or 8.1999999999999996e-37 < y

    1. Initial program 100.0%

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

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

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

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

    if -2.80000000000000018e46 < y < 8.1999999999999996e-37

    1. Initial program 99.1%

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

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

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

      \[\leadsto 1 - \color{blue}{\frac{x}{y - z} \cdot \frac{1}{y - t}} \]
    4. Step-by-step derivation
      1. un-div-inv99.2%

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

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

      \[\leadsto 1 - \color{blue}{\frac{x}{t \cdot z}} \]
    7. Step-by-step derivation
      1. associate-/l/79.3%

        \[\leadsto 1 - \color{blue}{\frac{\frac{x}{z}}{t}} \]
    8. Simplified79.3%

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

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

Alternative 10: 99.2% accurate, 1.0× speedup?

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

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

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

Alternative 11: 98.4% accurate, 1.0× speedup?

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

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

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

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

    \[\leadsto 1 - \color{blue}{\frac{x}{y - z} \cdot \frac{1}{y - t}} \]
  4. Step-by-step derivation
    1. un-div-inv99.5%

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

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

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

Alternative 12: 61.0% accurate, 1.6× speedup?

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

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

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

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

Reproduce

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