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

Percentage Accurate: 99.1% → 98.6%
Time: 7.5s
Alternatives: 9
Speedup: N/A×

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 9 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.1% 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.6% accurate, 1.0× speedup?

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

    \[1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)} \]
  2. Step-by-step derivation
    1. sub-neg98.4%

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

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

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

      \[\leadsto 1 + 1 \cdot \color{blue}{\frac{\frac{-x}{y - z}}{y - t}} \]
    5. associate-*r/98.1%

      \[\leadsto 1 + \color{blue}{\frac{1 \cdot \frac{-x}{y - z}}{y - t}} \]
    6. metadata-eval98.1%

      \[\leadsto 1 + \frac{\color{blue}{\frac{-1}{-1}} \cdot \frac{-x}{y - z}}{y - t} \]
    7. times-frac98.1%

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

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

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

      \[\leadsto 1 + \frac{\frac{x}{\color{blue}{-\left(y - z\right)}}}{y - t} \]
    11. sub-neg98.1%

      \[\leadsto 1 + \frac{\frac{x}{-\color{blue}{\left(y + \left(-z\right)\right)}}}{y - t} \]
    12. +-commutative98.1%

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

      \[\leadsto 1 + \frac{\frac{x}{\color{blue}{\left(-\left(-z\right)\right) + \left(-y\right)}}}{y - t} \]
    14. remove-double-neg98.1%

      \[\leadsto 1 + \frac{\frac{x}{\color{blue}{z} + \left(-y\right)}}{y - t} \]
    15. sub-neg98.1%

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

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

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

Alternative 2: 86.6% accurate, 0.8× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -2.7e89

    1. Initial program 100.0%

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

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

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

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

    if -2.7e89 < y < 4200

    1. Initial program 97.1%

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

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

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

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

        \[\leadsto 1 + 1 \cdot \color{blue}{\frac{\frac{-x}{y - z}}{y - t}} \]
      5. associate-*r/96.5%

        \[\leadsto 1 + \color{blue}{\frac{1 \cdot \frac{-x}{y - z}}{y - t}} \]
      6. metadata-eval96.5%

        \[\leadsto 1 + \frac{\color{blue}{\frac{-1}{-1}} \cdot \frac{-x}{y - z}}{y - t} \]
      7. times-frac96.5%

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

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

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

        \[\leadsto 1 + \frac{\frac{x}{\color{blue}{-\left(y - z\right)}}}{y - t} \]
      11. sub-neg96.5%

        \[\leadsto 1 + \frac{\frac{x}{-\color{blue}{\left(y + \left(-z\right)\right)}}}{y - t} \]
      12. +-commutative96.5%

        \[\leadsto 1 + \frac{\frac{x}{-\color{blue}{\left(\left(-z\right) + y\right)}}}{y - t} \]
      13. distribute-neg-out96.5%

        \[\leadsto 1 + \frac{\frac{x}{\color{blue}{\left(-\left(-z\right)\right) + \left(-y\right)}}}{y - t} \]
      14. remove-double-neg96.5%

        \[\leadsto 1 + \frac{\frac{x}{\color{blue}{z} + \left(-y\right)}}{y - t} \]
      15. sub-neg96.5%

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

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

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

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

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

    if 4200 < y

    1. Initial program 100.0%

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

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

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

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

Alternative 3: 93.1% accurate, 0.8× speedup?

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

\mathbf{elif}\;z \leq 9.2 \cdot 10^{-141}:\\
\;\;\;\;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 < -1.5000000000000001e-66

    1. Initial program 99.9%

      \[1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)} \]
    2. Step-by-step derivation
      1. sub-neg99.9%

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

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

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

        \[\leadsto 1 + 1 \cdot \color{blue}{\frac{\frac{-x}{y - z}}{y - t}} \]
      5. associate-*r/99.9%

        \[\leadsto 1 + \color{blue}{\frac{1 \cdot \frac{-x}{y - z}}{y - t}} \]
      6. metadata-eval99.9%

        \[\leadsto 1 + \frac{\color{blue}{\frac{-1}{-1}} \cdot \frac{-x}{y - z}}{y - t} \]
      7. times-frac99.9%

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

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

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

        \[\leadsto 1 + \frac{\frac{x}{\color{blue}{-\left(y - z\right)}}}{y - t} \]
      11. sub-neg99.9%

        \[\leadsto 1 + \frac{\frac{x}{-\color{blue}{\left(y + \left(-z\right)\right)}}}{y - t} \]
      12. +-commutative99.9%

        \[\leadsto 1 + \frac{\frac{x}{-\color{blue}{\left(\left(-z\right) + y\right)}}}{y - t} \]
      13. distribute-neg-out99.9%

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

        \[\leadsto 1 + \frac{\frac{x}{\color{blue}{z} + \left(-y\right)}}{y - t} \]
      15. sub-neg99.9%

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

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

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

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

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

    if -1.5000000000000001e-66 < z < 9.1999999999999998e-141

    1. Initial program 95.2%

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

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

    if 9.1999999999999998e-141 < 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 76.9%

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

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

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

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

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

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

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

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

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

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

Alternative 4: 92.8% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 99.9%

      \[1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)} \]
    2. Step-by-step derivation
      1. sub-neg99.9%

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

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

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

        \[\leadsto 1 + 1 \cdot \color{blue}{\frac{\frac{-x}{y - z}}{y - t}} \]
      5. associate-*r/99.9%

        \[\leadsto 1 + \color{blue}{\frac{1 \cdot \frac{-x}{y - z}}{y - t}} \]
      6. metadata-eval99.9%

        \[\leadsto 1 + \frac{\color{blue}{\frac{-1}{-1}} \cdot \frac{-x}{y - z}}{y - t} \]
      7. times-frac99.9%

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

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

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

        \[\leadsto 1 + \frac{\frac{x}{\color{blue}{-\left(y - z\right)}}}{y - t} \]
      11. sub-neg99.9%

        \[\leadsto 1 + \frac{\frac{x}{-\color{blue}{\left(y + \left(-z\right)\right)}}}{y - t} \]
      12. +-commutative99.9%

        \[\leadsto 1 + \frac{\frac{x}{-\color{blue}{\left(\left(-z\right) + y\right)}}}{y - t} \]
      13. distribute-neg-out99.9%

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

        \[\leadsto 1 + \frac{\frac{x}{\color{blue}{z} + \left(-y\right)}}{y - t} \]
      15. sub-neg99.9%

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

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

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

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

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

    if -1.24999999999999996e-65 < z < 1.5999999999999999e-143

    1. Initial program 95.2%

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

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

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

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

    if 1.5999999999999999e-143 < 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 76.9%

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

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

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

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

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

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

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

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

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

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

Alternative 5: 75.9% accurate, 1.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -7.4000000000000002e-196 or 2.59999999999999996e-307 < z

    1. Initial program 98.3%

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

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

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

    if -7.4000000000000002e-196 < z < 2.59999999999999996e-307

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{x}{t \cdot y} + 1} \]
    7. Simplified88.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -7.4 \cdot 10^{-196}:\\ \;\;\;\;1\\ \mathbf{elif}\;z \leq 2.6 \cdot 10^{-307}:\\ \;\;\;\;1 + \frac{x}{y \cdot t}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]

Alternative 6: 83.6% accurate, 1.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -8.0000000000000002e-58 or 2.25e-100 < y

    1. Initial program 100.0%

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

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

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

    if -8.0000000000000002e-58 < y < 2.25e-100

    1. Initial program 95.7%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -8 \cdot 10^{-58}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 2.25 \cdot 10^{-100}:\\ \;\;\;\;1 - \frac{x}{z \cdot t}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]

Alternative 7: 83.3% accurate, 1.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -7.20000000000000019e-58 or 6.1999999999999997e-99 < y

    1. Initial program 100.0%

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

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

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

    if -7.20000000000000019e-58 < y < 6.1999999999999997e-99

    1. Initial program 95.7%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -7.2 \cdot 10^{-58}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 6.2 \cdot 10^{-99}:\\ \;\;\;\;1 - \frac{\frac{x}{t}}{z}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]

Alternative 8: 89.0% accurate, 1.0× speedup?

\[\begin{array}{l} [z, t] = \mathsf{sort}([z, t])\\ \\ \begin{array}{l} \mathbf{if}\;z \leq -3.7 \cdot 10^{-97}:\\ \;\;\;\;1 + \frac{x}{z \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.7e-97) (+ 1.0 (/ x (* z (- 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.7e-97) {
		tmp = 1.0 + (x / (z * (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.7d-97)) then
        tmp = 1.0d0 + (x / (z * (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.7e-97) {
		tmp = 1.0 + (x / (z * (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.7e-97:
		tmp = 1.0 + (x / (z * (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.7e-97)
		tmp = Float64(1.0 + Float64(x / Float64(z * 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.7e-97)
		tmp = 1.0 + (x / (z * (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.7e-97], N[(1.0 + N[(x / N[(z * 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.7 \cdot 10^{-97}:\\
\;\;\;\;1 + \frac{x}{z \cdot \left(y - t\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -3.69999999999999976e-97

    1. Initial program 99.9%

      \[1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)} \]
    2. Step-by-step derivation
      1. sub-neg99.9%

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

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

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

        \[\leadsto 1 + 1 \cdot \color{blue}{\frac{\frac{-x}{y - z}}{y - t}} \]
      5. associate-*r/99.9%

        \[\leadsto 1 + \color{blue}{\frac{1 \cdot \frac{-x}{y - z}}{y - t}} \]
      6. metadata-eval99.9%

        \[\leadsto 1 + \frac{\color{blue}{\frac{-1}{-1}} \cdot \frac{-x}{y - z}}{y - t} \]
      7. times-frac99.9%

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

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

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

        \[\leadsto 1 + \frac{\frac{x}{\color{blue}{-\left(y - z\right)}}}{y - t} \]
      11. sub-neg99.9%

        \[\leadsto 1 + \frac{\frac{x}{-\color{blue}{\left(y + \left(-z\right)\right)}}}{y - t} \]
      12. +-commutative99.9%

        \[\leadsto 1 + \frac{\frac{x}{-\color{blue}{\left(\left(-z\right) + y\right)}}}{y - t} \]
      13. distribute-neg-out99.9%

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

        \[\leadsto 1 + \frac{\frac{x}{\color{blue}{z} + \left(-y\right)}}{y - t} \]
      15. sub-neg99.9%

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

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

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

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

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

    if -3.69999999999999976e-97 < z

    1. Initial program 97.6%

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 75.1% 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.4%

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

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

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

    \[\leadsto 1 \]

Reproduce

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