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

Percentage Accurate: 99.2% → 98.5%
Time: 11.0s
Alternatives: 11
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 11 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.5% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 73.3% accurate, 0.4× speedup?

\[\begin{array}{l} [x, y, z, t] = \mathsf{sort}([x, y, z, t])\\ \\ \begin{array}{l} t_1 := 1 - \frac{x}{z \cdot t}\\ t_2 := 1 + \frac{x}{z \cdot y}\\ \mathbf{if}\;z \leq -3.9 \cdot 10^{+18}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;z \leq -3.2 \cdot 10^{-50}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq -3 \cdot 10^{-71}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;z \leq 1.45 \cdot 10^{-155}:\\ \;\;\;\;1 + \frac{x}{y \cdot t}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (- 1.0 (/ x (* z t)))) (t_2 (+ 1.0 (/ x (* z y)))))
   (if (<= z -3.9e+18)
     t_2
     (if (<= z -3.2e-50)
       t_1
       (if (<= z -3e-71)
         t_2
         (if (<= z 1.45e-155) (+ 1.0 (/ x (* y t))) t_1))))))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
	double t_1 = 1.0 - (x / (z * t));
	double t_2 = 1.0 + (x / (z * y));
	double tmp;
	if (z <= -3.9e+18) {
		tmp = t_2;
	} else if (z <= -3.2e-50) {
		tmp = t_1;
	} else if (z <= -3e-71) {
		tmp = t_2;
	} else if (z <= 1.45e-155) {
		tmp = 1.0 + (x / (y * t));
	} else {
		tmp = t_1;
	}
	return tmp;
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_1 = 1.0d0 - (x / (z * t))
    t_2 = 1.0d0 + (x / (z * y))
    if (z <= (-3.9d+18)) then
        tmp = t_2
    else if (z <= (-3.2d-50)) then
        tmp = t_1
    else if (z <= (-3d-71)) then
        tmp = t_2
    else if (z <= 1.45d-155) then
        tmp = 1.0d0 + (x / (y * t))
    else
        tmp = t_1
    end if
    code = tmp
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
	double t_1 = 1.0 - (x / (z * t));
	double t_2 = 1.0 + (x / (z * y));
	double tmp;
	if (z <= -3.9e+18) {
		tmp = t_2;
	} else if (z <= -3.2e-50) {
		tmp = t_1;
	} else if (z <= -3e-71) {
		tmp = t_2;
	} else if (z <= 1.45e-155) {
		tmp = 1.0 + (x / (y * t));
	} else {
		tmp = t_1;
	}
	return tmp;
}
[x, y, z, t] = sort([x, y, z, t])
def code(x, y, z, t):
	t_1 = 1.0 - (x / (z * t))
	t_2 = 1.0 + (x / (z * y))
	tmp = 0
	if z <= -3.9e+18:
		tmp = t_2
	elif z <= -3.2e-50:
		tmp = t_1
	elif z <= -3e-71:
		tmp = t_2
	elif z <= 1.45e-155:
		tmp = 1.0 + (x / (y * t))
	else:
		tmp = t_1
	return tmp
x, y, z, t = sort([x, y, z, t])
function code(x, y, z, t)
	t_1 = Float64(1.0 - Float64(x / Float64(z * t)))
	t_2 = Float64(1.0 + Float64(x / Float64(z * y)))
	tmp = 0.0
	if (z <= -3.9e+18)
		tmp = t_2;
	elseif (z <= -3.2e-50)
		tmp = t_1;
	elseif (z <= -3e-71)
		tmp = t_2;
	elseif (z <= 1.45e-155)
		tmp = Float64(1.0 + Float64(x / Float64(y * t)));
	else
		tmp = t_1;
	end
	return tmp
end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp_2 = code(x, y, z, t)
	t_1 = 1.0 - (x / (z * t));
	t_2 = 1.0 + (x / (z * y));
	tmp = 0.0;
	if (z <= -3.9e+18)
		tmp = t_2;
	elseif (z <= -3.2e-50)
		tmp = t_1;
	elseif (z <= -3e-71)
		tmp = t_2;
	elseif (z <= 1.45e-155)
		tmp = 1.0 + (x / (y * t));
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(1.0 - N[(x / N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(1.0 + N[(x / N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -3.9e+18], t$95$2, If[LessEqual[z, -3.2e-50], t$95$1, If[LessEqual[z, -3e-71], t$95$2, If[LessEqual[z, 1.45e-155], N[(1.0 + N[(x / N[(y * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
t_1 := 1 - \frac{x}{z \cdot t}\\
t_2 := 1 + \frac{x}{z \cdot y}\\
\mathbf{if}\;z \leq -3.9 \cdot 10^{+18}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;z \leq -3.2 \cdot 10^{-50}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;z \leq -3 \cdot 10^{-71}:\\
\;\;\;\;t\_2\\

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

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -3.9e18 or -3.2e-50 < z < -3.0000000000000001e-71

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 1 + \color{blue}{\frac{x}{y \cdot z}} \]
    9. Step-by-step derivation
      1. *-commutative82.8%

        \[\leadsto 1 + \frac{x}{\color{blue}{z \cdot y}} \]
    10. Simplified82.8%

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

    if -3.9e18 < z < -3.2e-50 or 1.45000000000000005e-155 < z

    1. Initial program 99.9%

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

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

    if -3.0000000000000001e-71 < z < 1.45000000000000005e-155

    1. Initial program 95.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -3.9 \cdot 10^{+18}:\\ \;\;\;\;1 + \frac{x}{z \cdot y}\\ \mathbf{elif}\;z \leq -3.2 \cdot 10^{-50}:\\ \;\;\;\;1 - \frac{x}{z \cdot t}\\ \mathbf{elif}\;z \leq -3 \cdot 10^{-71}:\\ \;\;\;\;1 + \frac{x}{z \cdot y}\\ \mathbf{elif}\;z \leq 1.45 \cdot 10^{-155}:\\ \;\;\;\;1 + \frac{x}{y \cdot t}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{x}{z \cdot t}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 73.3% accurate, 0.4× speedup?

\[\begin{array}{l} [x, y, z, t] = \mathsf{sort}([x, y, z, t])\\ \\ \begin{array}{l} t_1 := 1 + \frac{x}{z \cdot y}\\ \mathbf{if}\;z \leq -3.6 \cdot 10^{+18}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq -3 \cdot 10^{-50}:\\ \;\;\;\;1 - \frac{x}{z \cdot t}\\ \mathbf{elif}\;z \leq -3.3 \cdot 10^{-71}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq 2.8 \cdot 10^{-155}:\\ \;\;\;\;1 + \frac{x}{y \cdot t}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{\frac{x}{t}}{z}\\ \end{array} \end{array} \]
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (+ 1.0 (/ x (* z y)))))
   (if (<= z -3.6e+18)
     t_1
     (if (<= z -3e-50)
       (- 1.0 (/ x (* z t)))
       (if (<= z -3.3e-71)
         t_1
         (if (<= z 2.8e-155) (+ 1.0 (/ x (* y t))) (- 1.0 (/ (/ x t) z))))))))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
	double t_1 = 1.0 + (x / (z * y));
	double tmp;
	if (z <= -3.6e+18) {
		tmp = t_1;
	} else if (z <= -3e-50) {
		tmp = 1.0 - (x / (z * t));
	} else if (z <= -3.3e-71) {
		tmp = t_1;
	} else if (z <= 2.8e-155) {
		tmp = 1.0 + (x / (y * t));
	} else {
		tmp = 1.0 - ((x / t) / z);
	}
	return tmp;
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: t_1
    real(8) :: tmp
    t_1 = 1.0d0 + (x / (z * y))
    if (z <= (-3.6d+18)) then
        tmp = t_1
    else if (z <= (-3d-50)) then
        tmp = 1.0d0 - (x / (z * t))
    else if (z <= (-3.3d-71)) then
        tmp = t_1
    else if (z <= 2.8d-155) then
        tmp = 1.0d0 + (x / (y * t))
    else
        tmp = 1.0d0 - ((x / t) / z)
    end if
    code = tmp
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
	double t_1 = 1.0 + (x / (z * y));
	double tmp;
	if (z <= -3.6e+18) {
		tmp = t_1;
	} else if (z <= -3e-50) {
		tmp = 1.0 - (x / (z * t));
	} else if (z <= -3.3e-71) {
		tmp = t_1;
	} else if (z <= 2.8e-155) {
		tmp = 1.0 + (x / (y * t));
	} else {
		tmp = 1.0 - ((x / t) / z);
	}
	return tmp;
}
[x, y, z, t] = sort([x, y, z, t])
def code(x, y, z, t):
	t_1 = 1.0 + (x / (z * y))
	tmp = 0
	if z <= -3.6e+18:
		tmp = t_1
	elif z <= -3e-50:
		tmp = 1.0 - (x / (z * t))
	elif z <= -3.3e-71:
		tmp = t_1
	elif z <= 2.8e-155:
		tmp = 1.0 + (x / (y * t))
	else:
		tmp = 1.0 - ((x / t) / z)
	return tmp
x, y, z, t = sort([x, y, z, t])
function code(x, y, z, t)
	t_1 = Float64(1.0 + Float64(x / Float64(z * y)))
	tmp = 0.0
	if (z <= -3.6e+18)
		tmp = t_1;
	elseif (z <= -3e-50)
		tmp = Float64(1.0 - Float64(x / Float64(z * t)));
	elseif (z <= -3.3e-71)
		tmp = t_1;
	elseif (z <= 2.8e-155)
		tmp = Float64(1.0 + Float64(x / Float64(y * t)));
	else
		tmp = Float64(1.0 - Float64(Float64(x / t) / z));
	end
	return tmp
end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp_2 = code(x, y, z, t)
	t_1 = 1.0 + (x / (z * y));
	tmp = 0.0;
	if (z <= -3.6e+18)
		tmp = t_1;
	elseif (z <= -3e-50)
		tmp = 1.0 - (x / (z * t));
	elseif (z <= -3.3e-71)
		tmp = t_1;
	elseif (z <= 2.8e-155)
		tmp = 1.0 + (x / (y * t));
	else
		tmp = 1.0 - ((x / t) / z);
	end
	tmp_2 = tmp;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(1.0 + N[(x / N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -3.6e+18], t$95$1, If[LessEqual[z, -3e-50], N[(1.0 - N[(x / N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -3.3e-71], t$95$1, If[LessEqual[z, 2.8e-155], N[(1.0 + N[(x / N[(y * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(N[(x / t), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
t_1 := 1 + \frac{x}{z \cdot y}\\
\mathbf{if}\;z \leq -3.6 \cdot 10^{+18}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;z \leq -3 \cdot 10^{-50}:\\
\;\;\;\;1 - \frac{x}{z \cdot t}\\

\mathbf{elif}\;z \leq -3.3 \cdot 10^{-71}:\\
\;\;\;\;t\_1\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if z < -3.6e18 or -2.9999999999999999e-50 < z < -3.3000000000000002e-71

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 1 + \color{blue}{\frac{x}{y \cdot z}} \]
    9. Step-by-step derivation
      1. *-commutative82.8%

        \[\leadsto 1 + \frac{x}{\color{blue}{z \cdot y}} \]
    10. Simplified82.8%

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

    if -3.6e18 < z < -2.9999999999999999e-50

    1. Initial program 100.0%

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

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

    if -3.3000000000000002e-71 < z < 2.8e-155

    1. Initial program 95.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.8e-155 < z

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -3.6 \cdot 10^{+18}:\\ \;\;\;\;1 + \frac{x}{z \cdot y}\\ \mathbf{elif}\;z \leq -3 \cdot 10^{-50}:\\ \;\;\;\;1 - \frac{x}{z \cdot t}\\ \mathbf{elif}\;z \leq -3.3 \cdot 10^{-71}:\\ \;\;\;\;1 + \frac{x}{z \cdot y}\\ \mathbf{elif}\;z \leq 2.8 \cdot 10^{-155}:\\ \;\;\;\;1 + \frac{x}{y \cdot t}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{\frac{x}{t}}{z}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 73.4% accurate, 0.4× speedup?

\[\begin{array}{l} [x, y, z, t] = \mathsf{sort}([x, y, z, t])\\ \\ \begin{array}{l} t_1 := 1 + \frac{x}{z \cdot y}\\ \mathbf{if}\;z \leq -3.8 \cdot 10^{+18}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq -3.2 \cdot 10^{-50}:\\ \;\;\;\;1 - \frac{x}{z \cdot t}\\ \mathbf{elif}\;z \leq -3.3 \cdot 10^{-71}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq 8.6 \cdot 10^{-155}:\\ \;\;\;\;1 + \frac{\frac{x}{t}}{y}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{\frac{x}{t}}{z}\\ \end{array} \end{array} \]
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (+ 1.0 (/ x (* z y)))))
   (if (<= z -3.8e+18)
     t_1
     (if (<= z -3.2e-50)
       (- 1.0 (/ x (* z t)))
       (if (<= z -3.3e-71)
         t_1
         (if (<= z 8.6e-155) (+ 1.0 (/ (/ x t) y)) (- 1.0 (/ (/ x t) z))))))))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
	double t_1 = 1.0 + (x / (z * y));
	double tmp;
	if (z <= -3.8e+18) {
		tmp = t_1;
	} else if (z <= -3.2e-50) {
		tmp = 1.0 - (x / (z * t));
	} else if (z <= -3.3e-71) {
		tmp = t_1;
	} else if (z <= 8.6e-155) {
		tmp = 1.0 + ((x / t) / y);
	} else {
		tmp = 1.0 - ((x / t) / z);
	}
	return tmp;
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: t_1
    real(8) :: tmp
    t_1 = 1.0d0 + (x / (z * y))
    if (z <= (-3.8d+18)) then
        tmp = t_1
    else if (z <= (-3.2d-50)) then
        tmp = 1.0d0 - (x / (z * t))
    else if (z <= (-3.3d-71)) then
        tmp = t_1
    else if (z <= 8.6d-155) then
        tmp = 1.0d0 + ((x / t) / y)
    else
        tmp = 1.0d0 - ((x / t) / z)
    end if
    code = tmp
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
	double t_1 = 1.0 + (x / (z * y));
	double tmp;
	if (z <= -3.8e+18) {
		tmp = t_1;
	} else if (z <= -3.2e-50) {
		tmp = 1.0 - (x / (z * t));
	} else if (z <= -3.3e-71) {
		tmp = t_1;
	} else if (z <= 8.6e-155) {
		tmp = 1.0 + ((x / t) / y);
	} else {
		tmp = 1.0 - ((x / t) / z);
	}
	return tmp;
}
[x, y, z, t] = sort([x, y, z, t])
def code(x, y, z, t):
	t_1 = 1.0 + (x / (z * y))
	tmp = 0
	if z <= -3.8e+18:
		tmp = t_1
	elif z <= -3.2e-50:
		tmp = 1.0 - (x / (z * t))
	elif z <= -3.3e-71:
		tmp = t_1
	elif z <= 8.6e-155:
		tmp = 1.0 + ((x / t) / y)
	else:
		tmp = 1.0 - ((x / t) / z)
	return tmp
x, y, z, t = sort([x, y, z, t])
function code(x, y, z, t)
	t_1 = Float64(1.0 + Float64(x / Float64(z * y)))
	tmp = 0.0
	if (z <= -3.8e+18)
		tmp = t_1;
	elseif (z <= -3.2e-50)
		tmp = Float64(1.0 - Float64(x / Float64(z * t)));
	elseif (z <= -3.3e-71)
		tmp = t_1;
	elseif (z <= 8.6e-155)
		tmp = Float64(1.0 + Float64(Float64(x / t) / y));
	else
		tmp = Float64(1.0 - Float64(Float64(x / t) / z));
	end
	return tmp
end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp_2 = code(x, y, z, t)
	t_1 = 1.0 + (x / (z * y));
	tmp = 0.0;
	if (z <= -3.8e+18)
		tmp = t_1;
	elseif (z <= -3.2e-50)
		tmp = 1.0 - (x / (z * t));
	elseif (z <= -3.3e-71)
		tmp = t_1;
	elseif (z <= 8.6e-155)
		tmp = 1.0 + ((x / t) / y);
	else
		tmp = 1.0 - ((x / t) / z);
	end
	tmp_2 = tmp;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(1.0 + N[(x / N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -3.8e+18], t$95$1, If[LessEqual[z, -3.2e-50], N[(1.0 - N[(x / N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -3.3e-71], t$95$1, If[LessEqual[z, 8.6e-155], N[(1.0 + N[(N[(x / t), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(N[(x / t), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
t_1 := 1 + \frac{x}{z \cdot y}\\
\mathbf{if}\;z \leq -3.8 \cdot 10^{+18}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;z \leq -3.2 \cdot 10^{-50}:\\
\;\;\;\;1 - \frac{x}{z \cdot t}\\

\mathbf{elif}\;z \leq -3.3 \cdot 10^{-71}:\\
\;\;\;\;t\_1\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if z < -3.8e18 or -3.2e-50 < z < -3.3000000000000002e-71

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 1 + \color{blue}{\frac{x}{y \cdot z}} \]
    9. Step-by-step derivation
      1. *-commutative82.8%

        \[\leadsto 1 + \frac{x}{\color{blue}{z \cdot y}} \]
    10. Simplified82.8%

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

    if -3.8e18 < z < -3.2e-50

    1. Initial program 100.0%

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

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

    if -3.3000000000000002e-71 < z < 8.60000000000000016e-155

    1. Initial program 95.9%

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

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

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

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

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

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

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

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

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

      \[\leadsto 1 - \color{blue}{-1 \cdot \frac{x}{t \cdot y}} \]
    9. Step-by-step derivation
      1. mul-1-neg67.7%

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

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

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

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

    if 8.60000000000000016e-155 < z

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -3.8 \cdot 10^{+18}:\\ \;\;\;\;1 + \frac{x}{z \cdot y}\\ \mathbf{elif}\;z \leq -3.2 \cdot 10^{-50}:\\ \;\;\;\;1 - \frac{x}{z \cdot t}\\ \mathbf{elif}\;z \leq -3.3 \cdot 10^{-71}:\\ \;\;\;\;1 + \frac{x}{z \cdot y}\\ \mathbf{elif}\;z \leq 8.6 \cdot 10^{-155}:\\ \;\;\;\;1 + \frac{\frac{x}{t}}{y}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{\frac{x}{t}}{z}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 85.8% accurate, 0.6× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -2.85e-195 or 4.49999999999999989e-159 < z

    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. neg-mul-199.9%

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

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

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

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

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

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

        \[\leadsto 1 + \frac{\color{blue}{\frac{1 \cdot x}{-1 \cdot \left(y - z\right)}}}{y - t} \]
      9. *-lft-identity99.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. Add Preprocessing
    5. Taylor expanded in z around inf 88.6%

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

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

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

    if -2.85e-195 < z < 4.49999999999999989e-159

    1. Initial program 94.4%

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

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

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

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

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

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

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

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

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

      \[\leadsto 1 - \color{blue}{-1 \cdot \frac{x}{t \cdot y}} \]
    9. Step-by-step derivation
      1. mul-1-neg70.5%

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

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

        \[\leadsto 1 - \color{blue}{\frac{-\frac{x}{t}}{y}} \]
    10. Simplified70.9%

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

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

Alternative 6: 91.3% accurate, 0.6× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -3.30000000000000004e-62 or 9.80000000000000026e-155 < z

    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. neg-mul-199.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.30000000000000004e-62 < z < 9.80000000000000026e-155

    1. Initial program 96.0%

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

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

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

Alternative 7: 91.1% accurate, 0.6× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -2.1999999999999999e-60 or 9.80000000000000026e-155 < z

    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. neg-mul-199.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.1999999999999999e-60 < z < 9.80000000000000026e-155

    1. Initial program 96.0%

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

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

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

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

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

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

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

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

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

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

Alternative 8: 67.7% accurate, 0.6× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -8.79999999999999984e-28 or 8.9999999999999997e-54 < z

    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. neg-mul-199.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{1 + \frac{\frac{x}{z - y}}{y - t}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. clear-num99.9%

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

        \[\leadsto 1 + \color{blue}{{\left(\frac{y - t}{\frac{x}{z - y}}\right)}^{-1}} \]
      3. div-inv99.9%

        \[\leadsto 1 + {\color{blue}{\left(\left(y - t\right) \cdot \frac{1}{\frac{x}{z - y}}\right)}}^{-1} \]
      4. clear-num99.9%

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

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

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

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

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

      \[\leadsto 1 + \color{blue}{-1 \cdot \frac{x}{t \cdot z}} \]
    10. Step-by-step derivation
      1. mul-1-neg77.5%

        \[\leadsto 1 + \color{blue}{\left(-\frac{x}{t \cdot z}\right)} \]
      2. associate-/l/77.5%

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

        \[\leadsto 1 + \color{blue}{\frac{-\frac{x}{z}}{t}} \]
      4. distribute-neg-frac77.5%

        \[\leadsto 1 + \frac{\color{blue}{\frac{-x}{z}}}{t} \]
    11. Simplified77.5%

      \[\leadsto 1 + \color{blue}{\frac{\frac{-x}{z}}{t}} \]
    12. Step-by-step derivation
      1. expm1-log1p-u75.3%

        \[\leadsto 1 + \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\frac{-x}{z}}{t}\right)\right)} \]
      2. expm1-udef75.3%

        \[\leadsto 1 + \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{\frac{-x}{z}}{t}\right)} - 1\right)} \]
      3. add-cbrt-cube74.6%

        \[\leadsto 1 + \left(e^{\mathsf{log1p}\left(\color{blue}{\sqrt[3]{\left(\frac{\frac{-x}{z}}{t} \cdot \frac{\frac{-x}{z}}{t}\right) \cdot \frac{\frac{-x}{z}}{t}}}\right)} - 1\right) \]
      4. add-cbrt-cube75.3%

        \[\leadsto 1 + \left(e^{\mathsf{log1p}\left(\color{blue}{\frac{\frac{-x}{z}}{t}}\right)} - 1\right) \]
      5. frac-2neg75.3%

        \[\leadsto 1 + \left(e^{\mathsf{log1p}\left(\frac{\color{blue}{\frac{-\left(-x\right)}{-z}}}{t}\right)} - 1\right) \]
      6. remove-double-neg75.3%

        \[\leadsto 1 + \left(e^{\mathsf{log1p}\left(\frac{\frac{\color{blue}{x}}{-z}}{t}\right)} - 1\right) \]
      7. associate-/l/75.3%

        \[\leadsto 1 + \left(e^{\mathsf{log1p}\left(\color{blue}{\frac{x}{t \cdot \left(-z\right)}}\right)} - 1\right) \]
      8. frac-2neg75.3%

        \[\leadsto 1 + \left(e^{\mathsf{log1p}\left(\color{blue}{\frac{-x}{-t \cdot \left(-z\right)}}\right)} - 1\right) \]
      9. add-sqr-sqrt33.3%

        \[\leadsto 1 + \left(e^{\mathsf{log1p}\left(\frac{\color{blue}{\sqrt{-x} \cdot \sqrt{-x}}}{-t \cdot \left(-z\right)}\right)} - 1\right) \]
      10. sqrt-unprod67.0%

        \[\leadsto 1 + \left(e^{\mathsf{log1p}\left(\frac{\color{blue}{\sqrt{\left(-x\right) \cdot \left(-x\right)}}}{-t \cdot \left(-z\right)}\right)} - 1\right) \]
      11. sqr-neg67.0%

        \[\leadsto 1 + \left(e^{\mathsf{log1p}\left(\frac{\sqrt{\color{blue}{x \cdot x}}}{-t \cdot \left(-z\right)}\right)} - 1\right) \]
      12. sqrt-unprod40.7%

        \[\leadsto 1 + \left(e^{\mathsf{log1p}\left(\frac{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}{-t \cdot \left(-z\right)}\right)} - 1\right) \]
      13. add-sqr-sqrt73.2%

        \[\leadsto 1 + \left(e^{\mathsf{log1p}\left(\frac{\color{blue}{x}}{-t \cdot \left(-z\right)}\right)} - 1\right) \]
      14. distribute-rgt-neg-out73.2%

        \[\leadsto 1 + \left(e^{\mathsf{log1p}\left(\frac{x}{-\color{blue}{\left(-t \cdot z\right)}}\right)} - 1\right) \]
      15. remove-double-neg73.2%

        \[\leadsto 1 + \left(e^{\mathsf{log1p}\left(\frac{x}{\color{blue}{t \cdot z}}\right)} - 1\right) \]
    13. Applied egg-rr73.2%

      \[\leadsto 1 + \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{x}{t \cdot z}\right)} - 1\right)} \]
    14. Step-by-step derivation
      1. expm1-def73.2%

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

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

        \[\leadsto 1 + \frac{x}{\color{blue}{z \cdot t}} \]
    15. Simplified75.5%

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

    if -8.79999999999999984e-28 < z < 8.9999999999999997e-54

    1. Initial program 97.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 73.0% accurate, 0.6× speedup?

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 1 + \color{blue}{\frac{x}{y \cdot z}} \]
    9. Step-by-step derivation
      1. *-commutative78.4%

        \[\leadsto 1 + \frac{x}{\color{blue}{z \cdot y}} \]
    10. Simplified78.4%

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

    if -1.9999999999999998e-71 < z < 2.70000000000000026e-54

    1. Initial program 96.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.70000000000000026e-54 < z

    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. neg-mul-199.9%

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

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

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

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

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

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

        \[\leadsto 1 + \frac{\color{blue}{\frac{1 \cdot x}{-1 \cdot \left(y - z\right)}}}{y - t} \]
      9. *-lft-identity99.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. Add Preprocessing
    5. Step-by-step derivation
      1. clear-num99.9%

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

        \[\leadsto 1 + \color{blue}{{\left(\frac{y - t}{\frac{x}{z - y}}\right)}^{-1}} \]
      3. div-inv99.9%

        \[\leadsto 1 + {\color{blue}{\left(\left(y - t\right) \cdot \frac{1}{\frac{x}{z - y}}\right)}}^{-1} \]
      4. clear-num99.9%

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

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

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

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

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

      \[\leadsto 1 + \color{blue}{-1 \cdot \frac{x}{t \cdot z}} \]
    10. Step-by-step derivation
      1. mul-1-neg78.5%

        \[\leadsto 1 + \color{blue}{\left(-\frac{x}{t \cdot z}\right)} \]
      2. associate-/l/78.5%

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

        \[\leadsto 1 + \color{blue}{\frac{-\frac{x}{z}}{t}} \]
      4. distribute-neg-frac78.5%

        \[\leadsto 1 + \frac{\color{blue}{\frac{-x}{z}}}{t} \]
    11. Simplified78.5%

      \[\leadsto 1 + \color{blue}{\frac{\frac{-x}{z}}{t}} \]
    12. Step-by-step derivation
      1. expm1-log1p-u74.3%

        \[\leadsto 1 + \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\frac{-x}{z}}{t}\right)\right)} \]
      2. expm1-udef74.3%

        \[\leadsto 1 + \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{\frac{-x}{z}}{t}\right)} - 1\right)} \]
      3. add-cbrt-cube74.2%

        \[\leadsto 1 + \left(e^{\mathsf{log1p}\left(\color{blue}{\sqrt[3]{\left(\frac{\frac{-x}{z}}{t} \cdot \frac{\frac{-x}{z}}{t}\right) \cdot \frac{\frac{-x}{z}}{t}}}\right)} - 1\right) \]
      4. add-cbrt-cube74.3%

        \[\leadsto 1 + \left(e^{\mathsf{log1p}\left(\color{blue}{\frac{\frac{-x}{z}}{t}}\right)} - 1\right) \]
      5. frac-2neg74.3%

        \[\leadsto 1 + \left(e^{\mathsf{log1p}\left(\frac{\color{blue}{\frac{-\left(-x\right)}{-z}}}{t}\right)} - 1\right) \]
      6. remove-double-neg74.3%

        \[\leadsto 1 + \left(e^{\mathsf{log1p}\left(\frac{\frac{\color{blue}{x}}{-z}}{t}\right)} - 1\right) \]
      7. associate-/l/74.3%

        \[\leadsto 1 + \left(e^{\mathsf{log1p}\left(\color{blue}{\frac{x}{t \cdot \left(-z\right)}}\right)} - 1\right) \]
      8. frac-2neg74.3%

        \[\leadsto 1 + \left(e^{\mathsf{log1p}\left(\color{blue}{\frac{-x}{-t \cdot \left(-z\right)}}\right)} - 1\right) \]
      9. add-sqr-sqrt33.9%

        \[\leadsto 1 + \left(e^{\mathsf{log1p}\left(\frac{\color{blue}{\sqrt{-x} \cdot \sqrt{-x}}}{-t \cdot \left(-z\right)}\right)} - 1\right) \]
      10. sqrt-unprod66.4%

        \[\leadsto 1 + \left(e^{\mathsf{log1p}\left(\frac{\color{blue}{\sqrt{\left(-x\right) \cdot \left(-x\right)}}}{-t \cdot \left(-z\right)}\right)} - 1\right) \]
      11. sqr-neg66.4%

        \[\leadsto 1 + \left(e^{\mathsf{log1p}\left(\frac{\sqrt{\color{blue}{x \cdot x}}}{-t \cdot \left(-z\right)}\right)} - 1\right) \]
      12. sqrt-unprod39.9%

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

        \[\leadsto 1 + \left(e^{\mathsf{log1p}\left(\frac{\color{blue}{x}}{-t \cdot \left(-z\right)}\right)} - 1\right) \]
      14. distribute-rgt-neg-out73.7%

        \[\leadsto 1 + \left(e^{\mathsf{log1p}\left(\frac{x}{-\color{blue}{\left(-t \cdot z\right)}}\right)} - 1\right) \]
      15. remove-double-neg73.7%

        \[\leadsto 1 + \left(e^{\mathsf{log1p}\left(\frac{x}{\color{blue}{t \cdot z}}\right)} - 1\right) \]
    13. Applied egg-rr73.7%

      \[\leadsto 1 + \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{x}{t \cdot z}\right)} - 1\right)} \]
    14. Step-by-step derivation
      1. expm1-def73.7%

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

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

        \[\leadsto 1 + \frac{x}{\color{blue}{z \cdot t}} \]
    15. Simplified76.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -2 \cdot 10^{-71}:\\ \;\;\;\;1 + \frac{x}{z \cdot y}\\ \mathbf{elif}\;z \leq 2.7 \cdot 10^{-54}:\\ \;\;\;\;1 + \frac{x}{y \cdot t}\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{x}{z \cdot t}\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 90.2% accurate, 0.8× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < 9.79999999999999961e-132

    1. Initial program 98.8%

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

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

    if 9.79999999999999961e-132 < t

    1. Initial program 98.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 58.0% accurate, 1.6× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto 1 + \color{blue}{\frac{x}{t \cdot y}} \]
  9. Final simplification58.0%

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

Reproduce

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