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

Percentage Accurate: 99.1% → 98.4%
Time: 7.5s
Alternatives: 10
Speedup: 1.0×

Specification

?
\[\begin{array}{l} \\ 1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)} \end{array} \]
(FPCore (x y z t) :precision binary64 (- 1.0 (/ x (* (- y z) (- y t)))))
double code(double x, double y, double z, double t) {
	return 1.0 - (x / ((y - z) * (y - t)));
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = 1.0d0 - (x / ((y - z) * (y - t)))
end function
public static double code(double x, double y, double z, double t) {
	return 1.0 - (x / ((y - z) * (y - t)));
}
def code(x, y, z, t):
	return 1.0 - (x / ((y - z) * (y - t)))
function code(x, y, z, t)
	return Float64(1.0 - Float64(x / Float64(Float64(y - z) * Float64(y - t))))
end
function tmp = code(x, y, z, t)
	tmp = 1.0 - (x / ((y - z) * (y - t)));
end
code[x_, y_, z_, t_] := N[(1.0 - N[(x / N[(N[(y - z), $MachinePrecision] * N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 10 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 99.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ 1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)} \end{array} \]
(FPCore (x y z t) :precision binary64 (- 1.0 (/ x (* (- y z) (- y t)))))
double code(double x, double y, double z, double t) {
	return 1.0 - (x / ((y - z) * (y - t)));
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = 1.0d0 - (x / ((y - z) * (y - t)))
end function
public static double code(double x, double y, double z, double t) {
	return 1.0 - (x / ((y - z) * (y - t)));
}
def code(x, y, z, t):
	return 1.0 - (x / ((y - z) * (y - t)))
function code(x, y, z, t)
	return Float64(1.0 - Float64(x / Float64(Float64(y - z) * Float64(y - t))))
end
function tmp = code(x, y, z, t)
	tmp = 1.0 - (x / ((y - z) * (y - t)));
end
code[x_, y_, z_, t_] := N[(1.0 - N[(x / N[(N[(y - z), $MachinePrecision] * N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)}
\end{array}

Alternative 1: 98.4% accurate, 0.8× speedup?

\[\begin{array}{l} \\ 1 + \frac{x}{y - t} \cdot \frac{-1}{y - z} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (+ 1.0 (* (/ x (- y t)) (/ -1.0 (- y z)))))
double code(double x, double y, double z, double t) {
	return 1.0 + ((x / (y - t)) * (-1.0 / (y - z)));
}
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)) * ((-1.0d0) / (y - z)))
end function
public static double code(double x, double y, double z, double t) {
	return 1.0 + ((x / (y - t)) * (-1.0 / (y - z)));
}
def code(x, y, z, t):
	return 1.0 + ((x / (y - t)) * (-1.0 / (y - z)))
function code(x, y, z, t)
	return Float64(1.0 + Float64(Float64(x / Float64(y - t)) * Float64(-1.0 / Float64(y - z))))
end
function tmp = code(x, y, z, t)
	tmp = 1.0 + ((x / (y - t)) * (-1.0 / (y - z)));
end
code[x_, y_, z_, t_] := N[(1.0 + N[(N[(x / N[(y - t), $MachinePrecision]), $MachinePrecision] * N[(-1.0 / N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
1 + \frac{x}{y - t} \cdot \frac{-1}{y - z}
\end{array}
Derivation
  1. Initial program 99.2%

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

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

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

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

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

Alternative 2: 83.8% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := 1 - \frac{x}{y \cdot \left(y - t\right)}\\ \mathbf{if}\;y \leq -5.4 \cdot 10^{-14}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -1.5 \cdot 10^{-122}:\\ \;\;\;\;1 + \frac{x}{y \cdot z}\\ \mathbf{elif}\;y \leq -3.7 \cdot 10^{-162} \lor \neg \left(y \leq 9.6 \cdot 10^{-45}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{x}{z \cdot t}\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (- 1.0 (/ x (* y (- y t))))))
   (if (<= y -5.4e-14)
     t_1
     (if (<= y -1.5e-122)
       (+ 1.0 (/ x (* y z)))
       (if (or (<= y -3.7e-162) (not (<= y 9.6e-45)))
         t_1
         (- 1.0 (/ x (* z t))))))))
double code(double x, double y, double z, double t) {
	double t_1 = 1.0 - (x / (y * (y - t)));
	double tmp;
	if (y <= -5.4e-14) {
		tmp = t_1;
	} else if (y <= -1.5e-122) {
		tmp = 1.0 + (x / (y * z));
	} else if ((y <= -3.7e-162) || !(y <= 9.6e-45)) {
		tmp = t_1;
	} else {
		tmp = 1.0 - (x / (z * t));
	}
	return tmp;
}
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 / (y * (y - t)))
    if (y <= (-5.4d-14)) then
        tmp = t_1
    else if (y <= (-1.5d-122)) then
        tmp = 1.0d0 + (x / (y * z))
    else if ((y <= (-3.7d-162)) .or. (.not. (y <= 9.6d-45))) then
        tmp = t_1
    else
        tmp = 1.0d0 - (x / (z * t))
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double t_1 = 1.0 - (x / (y * (y - t)));
	double tmp;
	if (y <= -5.4e-14) {
		tmp = t_1;
	} else if (y <= -1.5e-122) {
		tmp = 1.0 + (x / (y * z));
	} else if ((y <= -3.7e-162) || !(y <= 9.6e-45)) {
		tmp = t_1;
	} else {
		tmp = 1.0 - (x / (z * t));
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = 1.0 - (x / (y * (y - t)))
	tmp = 0
	if y <= -5.4e-14:
		tmp = t_1
	elif y <= -1.5e-122:
		tmp = 1.0 + (x / (y * z))
	elif (y <= -3.7e-162) or not (y <= 9.6e-45):
		tmp = t_1
	else:
		tmp = 1.0 - (x / (z * t))
	return tmp
function code(x, y, z, t)
	t_1 = Float64(1.0 - Float64(x / Float64(y * Float64(y - t))))
	tmp = 0.0
	if (y <= -5.4e-14)
		tmp = t_1;
	elseif (y <= -1.5e-122)
		tmp = Float64(1.0 + Float64(x / Float64(y * z)));
	elseif ((y <= -3.7e-162) || !(y <= 9.6e-45))
		tmp = t_1;
	else
		tmp = Float64(1.0 - Float64(x / Float64(z * t)));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = 1.0 - (x / (y * (y - t)));
	tmp = 0.0;
	if (y <= -5.4e-14)
		tmp = t_1;
	elseif (y <= -1.5e-122)
		tmp = 1.0 + (x / (y * z));
	elseif ((y <= -3.7e-162) || ~((y <= 9.6e-45)))
		tmp = t_1;
	else
		tmp = 1.0 - (x / (z * t));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(1.0 - N[(x / N[(y * N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -5.4e-14], t$95$1, If[LessEqual[y, -1.5e-122], N[(1.0 + N[(x / N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[y, -3.7e-162], N[Not[LessEqual[y, 9.6e-45]], $MachinePrecision]], t$95$1, N[(1.0 - N[(x / N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := 1 - \frac{x}{y \cdot \left(y - t\right)}\\
\mathbf{if}\;y \leq -5.4 \cdot 10^{-14}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y \leq -1.5 \cdot 10^{-122}:\\
\;\;\;\;1 + \frac{x}{y \cdot z}\\

\mathbf{elif}\;y \leq -3.7 \cdot 10^{-162} \lor \neg \left(y \leq 9.6 \cdot 10^{-45}\right):\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -5.3999999999999997e-14 or -1.50000000000000002e-122 < y < -3.7000000000000002e-162 or 9.5999999999999996e-45 < y

    1. Initial program 99.9%

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

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

    if -5.3999999999999997e-14 < y < -1.50000000000000002e-122

    1. Initial program 99.9%

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

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

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

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

        \[\leadsto 1 - \frac{\color{blue}{-x}}{y \cdot z} \]
      3. *-commutative49.7%

        \[\leadsto 1 - \frac{-x}{\color{blue}{z \cdot y}} \]
    5. Simplified49.7%

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

    if -3.7000000000000002e-162 < y < 9.5999999999999996e-45

    1. Initial program 97.7%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -5.4 \cdot 10^{-14}:\\ \;\;\;\;1 - \frac{x}{y \cdot \left(y - t\right)}\\ \mathbf{elif}\;y \leq -1.5 \cdot 10^{-122}:\\ \;\;\;\;1 + \frac{x}{y \cdot z}\\ \mathbf{elif}\;y \leq -3.7 \cdot 10^{-162} \lor \neg \left(y \leq 9.6 \cdot 10^{-45}\right):\\ \;\;\;\;1 - \frac{x}{y \cdot \left(y - t\right)}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{x}{z \cdot t}\\ \end{array} \]

Alternative 3: 81.1% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := 1 - \frac{\frac{x}{y}}{y}\\ \mathbf{if}\;y \leq -2.2 \cdot 10^{-13}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -1.25 \cdot 10^{-144}:\\ \;\;\;\;1 + \frac{x}{y \cdot z}\\ \mathbf{elif}\;y \leq 2.9 \cdot 10^{-43}:\\ \;\;\;\;1 - \frac{x}{z \cdot t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (- 1.0 (/ (/ x y) y))))
   (if (<= y -2.2e-13)
     t_1
     (if (<= y -1.25e-144)
       (+ 1.0 (/ x (* y z)))
       (if (<= y 2.9e-43) (- 1.0 (/ x (* z t))) t_1)))))
double code(double x, double y, double z, double t) {
	double t_1 = 1.0 - ((x / y) / y);
	double tmp;
	if (y <= -2.2e-13) {
		tmp = t_1;
	} else if (y <= -1.25e-144) {
		tmp = 1.0 + (x / (y * z));
	} else if (y <= 2.9e-43) {
		tmp = 1.0 - (x / (z * t));
	} else {
		tmp = t_1;
	}
	return tmp;
}
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 / y) / y)
    if (y <= (-2.2d-13)) then
        tmp = t_1
    else if (y <= (-1.25d-144)) then
        tmp = 1.0d0 + (x / (y * z))
    else if (y <= 2.9d-43) then
        tmp = 1.0d0 - (x / (z * t))
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double t_1 = 1.0 - ((x / y) / y);
	double tmp;
	if (y <= -2.2e-13) {
		tmp = t_1;
	} else if (y <= -1.25e-144) {
		tmp = 1.0 + (x / (y * z));
	} else if (y <= 2.9e-43) {
		tmp = 1.0 - (x / (z * t));
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = 1.0 - ((x / y) / y)
	tmp = 0
	if y <= -2.2e-13:
		tmp = t_1
	elif y <= -1.25e-144:
		tmp = 1.0 + (x / (y * z))
	elif y <= 2.9e-43:
		tmp = 1.0 - (x / (z * t))
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t)
	t_1 = Float64(1.0 - Float64(Float64(x / y) / y))
	tmp = 0.0
	if (y <= -2.2e-13)
		tmp = t_1;
	elseif (y <= -1.25e-144)
		tmp = Float64(1.0 + Float64(x / Float64(y * z)));
	elseif (y <= 2.9e-43)
		tmp = Float64(1.0 - Float64(x / Float64(z * t)));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = 1.0 - ((x / y) / y);
	tmp = 0.0;
	if (y <= -2.2e-13)
		tmp = t_1;
	elseif (y <= -1.25e-144)
		tmp = 1.0 + (x / (y * z));
	elseif (y <= 2.9e-43)
		tmp = 1.0 - (x / (z * t));
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(1.0 - N[(N[(x / y), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2.2e-13], t$95$1, If[LessEqual[y, -1.25e-144], N[(1.0 + N[(x / N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.9e-43], N[(1.0 - N[(x / N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := 1 - \frac{\frac{x}{y}}{y}\\
\mathbf{if}\;y \leq -2.2 \cdot 10^{-13}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y \leq -1.25 \cdot 10^{-144}:\\
\;\;\;\;1 + \frac{x}{y \cdot z}\\

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

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -2.19999999999999997e-13 or 2.9000000000000001e-43 < y

    1. Initial program 100.0%

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

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

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

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

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

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

    if -2.19999999999999997e-13 < y < -1.2499999999999999e-144

    1. Initial program 99.9%

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

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

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

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

        \[\leadsto 1 - \frac{\color{blue}{-x}}{y \cdot z} \]
      3. *-commutative50.3%

        \[\leadsto 1 - \frac{-x}{\color{blue}{z \cdot y}} \]
    5. Simplified50.3%

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

    if -1.2499999999999999e-144 < y < 2.9000000000000001e-43

    1. Initial program 97.8%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.2 \cdot 10^{-13}:\\ \;\;\;\;1 - \frac{\frac{x}{y}}{y}\\ \mathbf{elif}\;y \leq -1.25 \cdot 10^{-144}:\\ \;\;\;\;1 + \frac{x}{y \cdot z}\\ \mathbf{elif}\;y \leq 2.9 \cdot 10^{-43}:\\ \;\;\;\;1 - \frac{x}{z \cdot t}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{\frac{x}{y}}{y}\\ \end{array} \]

Alternative 4: 81.1% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := 1 - \frac{\frac{x}{y}}{y}\\ \mathbf{if}\;y \leq -1.38 \cdot 10^{-12}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -1.5 \cdot 10^{-144}:\\ \;\;\;\;1 + \frac{\frac{x}{z}}{y}\\ \mathbf{elif}\;y \leq 1.7 \cdot 10^{-43}:\\ \;\;\;\;1 - \frac{x}{z \cdot t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (- 1.0 (/ (/ x y) y))))
   (if (<= y -1.38e-12)
     t_1
     (if (<= y -1.5e-144)
       (+ 1.0 (/ (/ x z) y))
       (if (<= y 1.7e-43) (- 1.0 (/ x (* z t))) t_1)))))
double code(double x, double y, double z, double t) {
	double t_1 = 1.0 - ((x / y) / y);
	double tmp;
	if (y <= -1.38e-12) {
		tmp = t_1;
	} else if (y <= -1.5e-144) {
		tmp = 1.0 + ((x / z) / y);
	} else if (y <= 1.7e-43) {
		tmp = 1.0 - (x / (z * t));
	} else {
		tmp = t_1;
	}
	return tmp;
}
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 / y) / y)
    if (y <= (-1.38d-12)) then
        tmp = t_1
    else if (y <= (-1.5d-144)) then
        tmp = 1.0d0 + ((x / z) / y)
    else if (y <= 1.7d-43) then
        tmp = 1.0d0 - (x / (z * t))
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double t_1 = 1.0 - ((x / y) / y);
	double tmp;
	if (y <= -1.38e-12) {
		tmp = t_1;
	} else if (y <= -1.5e-144) {
		tmp = 1.0 + ((x / z) / y);
	} else if (y <= 1.7e-43) {
		tmp = 1.0 - (x / (z * t));
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = 1.0 - ((x / y) / y)
	tmp = 0
	if y <= -1.38e-12:
		tmp = t_1
	elif y <= -1.5e-144:
		tmp = 1.0 + ((x / z) / y)
	elif y <= 1.7e-43:
		tmp = 1.0 - (x / (z * t))
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t)
	t_1 = Float64(1.0 - Float64(Float64(x / y) / y))
	tmp = 0.0
	if (y <= -1.38e-12)
		tmp = t_1;
	elseif (y <= -1.5e-144)
		tmp = Float64(1.0 + Float64(Float64(x / z) / y));
	elseif (y <= 1.7e-43)
		tmp = Float64(1.0 - Float64(x / Float64(z * t)));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = 1.0 - ((x / y) / y);
	tmp = 0.0;
	if (y <= -1.38e-12)
		tmp = t_1;
	elseif (y <= -1.5e-144)
		tmp = 1.0 + ((x / z) / y);
	elseif (y <= 1.7e-43)
		tmp = 1.0 - (x / (z * t));
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(1.0 - N[(N[(x / y), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.38e-12], t$95$1, If[LessEqual[y, -1.5e-144], N[(1.0 + N[(N[(x / z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.7e-43], N[(1.0 - N[(x / N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := 1 - \frac{\frac{x}{y}}{y}\\
\mathbf{if}\;y \leq -1.38 \cdot 10^{-12}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y \leq -1.5 \cdot 10^{-144}:\\
\;\;\;\;1 + \frac{\frac{x}{z}}{y}\\

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

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.37999999999999998e-12 or 1.7e-43 < y

    1. Initial program 100.0%

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

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

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

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

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

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

    if -1.37999999999999998e-12 < y < -1.4999999999999999e-144

    1. Initial program 99.9%

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

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

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

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

        \[\leadsto 1 - \frac{\color{blue}{-x}}{y \cdot z} \]
      3. *-commutative50.3%

        \[\leadsto 1 - \frac{-x}{\color{blue}{z \cdot y}} \]
    5. Simplified50.3%

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

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

        \[\leadsto 1 - \color{blue}{\frac{-1 \cdot x}{y \cdot z}} \]
      2. *-commutative50.3%

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

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

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

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

    if -1.4999999999999999e-144 < y < 1.7e-43

    1. Initial program 97.8%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.38 \cdot 10^{-12}:\\ \;\;\;\;1 - \frac{\frac{x}{y}}{y}\\ \mathbf{elif}\;y \leq -1.5 \cdot 10^{-144}:\\ \;\;\;\;1 + \frac{\frac{x}{z}}{y}\\ \mathbf{elif}\;y \leq 1.7 \cdot 10^{-43}:\\ \;\;\;\;1 - \frac{x}{z \cdot t}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{\frac{x}{y}}{y}\\ \end{array} \]

Alternative 5: 86.0% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -2.5 \cdot 10^{-144} \lor \neg \left(y \leq 3.2 \cdot 10^{-45}\right):\\ \;\;\;\;1 - \frac{x}{y \cdot \left(y - z\right)}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{x}{z \cdot t}\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (or (<= y -2.5e-144) (not (<= y 3.2e-45)))
   (- 1.0 (/ x (* y (- y z))))
   (- 1.0 (/ x (* z t)))))
double code(double x, double y, double z, double t) {
	double tmp;
	if ((y <= -2.5e-144) || !(y <= 3.2e-45)) {
		tmp = 1.0 - (x / (y * (y - z)));
	} else {
		tmp = 1.0 - (x / (z * t));
	}
	return tmp;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: tmp
    if ((y <= (-2.5d-144)) .or. (.not. (y <= 3.2d-45))) then
        tmp = 1.0d0 - (x / (y * (y - z)))
    else
        tmp = 1.0d0 - (x / (z * t))
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double tmp;
	if ((y <= -2.5e-144) || !(y <= 3.2e-45)) {
		tmp = 1.0 - (x / (y * (y - z)));
	} else {
		tmp = 1.0 - (x / (z * t));
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if (y <= -2.5e-144) or not (y <= 3.2e-45):
		tmp = 1.0 - (x / (y * (y - z)))
	else:
		tmp = 1.0 - (x / (z * t))
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if ((y <= -2.5e-144) || !(y <= 3.2e-45))
		tmp = Float64(1.0 - Float64(x / Float64(y * Float64(y - z))));
	else
		tmp = Float64(1.0 - Float64(x / Float64(z * t)));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if ((y <= -2.5e-144) || ~((y <= 3.2e-45)))
		tmp = 1.0 - (x / (y * (y - z)));
	else
		tmp = 1.0 - (x / (z * t));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -2.5e-144], N[Not[LessEqual[y, 3.2e-45]], $MachinePrecision]], N[(1.0 - N[(x / N[(y * N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(x / N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.5 \cdot 10^{-144} \lor \neg \left(y \leq 3.2 \cdot 10^{-45}\right):\\
\;\;\;\;1 - \frac{x}{y \cdot \left(y - z\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -2.4999999999999999e-144 or 3.20000000000000007e-45 < y

    1. Initial program 100.0%

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

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

    if -2.4999999999999999e-144 < y < 3.20000000000000007e-45

    1. Initial program 97.8%

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

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

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

Alternative 6: 86.2% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;t \leq -2.25 \cdot 10^{-7}:\\ \;\;\;\;1 - \frac{\frac{x}{t}}{z}\\ \mathbf{elif}\;t \leq 3.7 \cdot 10^{-106}:\\ \;\;\;\;1 - \frac{\frac{x}{y - z}}{y}\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{x}{\left(y - z\right) \cdot t}\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (<= t -2.25e-7)
   (- 1.0 (/ (/ x t) z))
   (if (<= t 3.7e-106)
     (- 1.0 (/ (/ x (- y z)) y))
     (+ 1.0 (/ x (* (- y z) t))))))
double code(double x, double y, double z, double t) {
	double tmp;
	if (t <= -2.25e-7) {
		tmp = 1.0 - ((x / t) / z);
	} else if (t <= 3.7e-106) {
		tmp = 1.0 - ((x / (y - z)) / y);
	} else {
		tmp = 1.0 + (x / ((y - z) * t));
	}
	return tmp;
}
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 <= (-2.25d-7)) then
        tmp = 1.0d0 - ((x / t) / z)
    else if (t <= 3.7d-106) then
        tmp = 1.0d0 - ((x / (y - z)) / y)
    else
        tmp = 1.0d0 + (x / ((y - z) * t))
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (t <= -2.25e-7) {
		tmp = 1.0 - ((x / t) / z);
	} else if (t <= 3.7e-106) {
		tmp = 1.0 - ((x / (y - z)) / y);
	} else {
		tmp = 1.0 + (x / ((y - z) * t));
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if t <= -2.25e-7:
		tmp = 1.0 - ((x / t) / z)
	elif t <= 3.7e-106:
		tmp = 1.0 - ((x / (y - z)) / y)
	else:
		tmp = 1.0 + (x / ((y - z) * t))
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if (t <= -2.25e-7)
		tmp = Float64(1.0 - Float64(Float64(x / t) / z));
	elseif (t <= 3.7e-106)
		tmp = Float64(1.0 - Float64(Float64(x / Float64(y - z)) / y));
	else
		tmp = Float64(1.0 + Float64(x / Float64(Float64(y - z) * t)));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (t <= -2.25e-7)
		tmp = 1.0 - ((x / t) / z);
	elseif (t <= 3.7e-106)
		tmp = 1.0 - ((x / (y - z)) / y);
	else
		tmp = 1.0 + (x / ((y - z) * t));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[LessEqual[t, -2.25e-7], N[(1.0 - N[(N[(x / t), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 3.7e-106], N[(1.0 - N[(N[(x / N[(y - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(x / N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;t \leq -2.25 \cdot 10^{-7}:\\
\;\;\;\;1 - \frac{\frac{x}{t}}{z}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if t < -2.2499999999999999e-7

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

    if -2.2499999999999999e-7 < t < 3.69999999999999979e-106

    1. Initial program 98.0%

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

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

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

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

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

    if 3.69999999999999979e-106 < t

    1. Initial program 99.9%

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

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

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

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

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

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

Alternative 7: 71.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -4.2 \cdot 10^{+52} \lor \neg \left(y \leq 2 \cdot 10^{+85}\right):\\ \;\;\;\;1 - \frac{x}{y \cdot z}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{x}{z \cdot t}\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (or (<= y -4.2e+52) (not (<= y 2e+85)))
   (- 1.0 (/ x (* y z)))
   (- 1.0 (/ x (* z t)))))
double code(double x, double y, double z, double t) {
	double tmp;
	if ((y <= -4.2e+52) || !(y <= 2e+85)) {
		tmp = 1.0 - (x / (y * z));
	} else {
		tmp = 1.0 - (x / (z * t));
	}
	return tmp;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: tmp
    if ((y <= (-4.2d+52)) .or. (.not. (y <= 2d+85))) then
        tmp = 1.0d0 - (x / (y * z))
    else
        tmp = 1.0d0 - (x / (z * t))
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double tmp;
	if ((y <= -4.2e+52) || !(y <= 2e+85)) {
		tmp = 1.0 - (x / (y * z));
	} else {
		tmp = 1.0 - (x / (z * t));
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if (y <= -4.2e+52) or not (y <= 2e+85):
		tmp = 1.0 - (x / (y * z))
	else:
		tmp = 1.0 - (x / (z * t))
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if ((y <= -4.2e+52) || !(y <= 2e+85))
		tmp = Float64(1.0 - Float64(x / Float64(y * z)));
	else
		tmp = Float64(1.0 - Float64(x / Float64(z * t)));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if ((y <= -4.2e+52) || ~((y <= 2e+85)))
		tmp = 1.0 - (x / (y * z));
	else
		tmp = 1.0 - (x / (z * t));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -4.2e+52], N[Not[LessEqual[y, 2e+85]], $MachinePrecision]], N[(1.0 - N[(x / N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(x / N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.2 \cdot 10^{+52} \lor \neg \left(y \leq 2 \cdot 10^{+85}\right):\\
\;\;\;\;1 - \frac{x}{y \cdot z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -4.2e52 or 2e85 < y

    1. Initial program 100.0%

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

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

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

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

        \[\leadsto 1 - \frac{\color{blue}{-x}}{y \cdot z} \]
      3. *-commutative72.4%

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

      \[\leadsto 1 - \color{blue}{\frac{-x}{z \cdot y}} \]
    6. Step-by-step derivation
      1. expm1-log1p-u71.6%

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

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

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

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

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

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

        \[\leadsto 1 - \left(e^{\mathsf{log1p}\left(\frac{\color{blue}{x}}{z \cdot y}\right)} - 1\right) \]
      8. associate-/r*71.8%

        \[\leadsto 1 - \left(e^{\mathsf{log1p}\left(\color{blue}{\frac{\frac{x}{z}}{y}}\right)} - 1\right) \]
    7. Applied egg-rr71.8%

      \[\leadsto 1 - \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{\frac{x}{z}}{y}\right)} - 1\right)} \]
    8. Step-by-step derivation
      1. expm1-def71.8%

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

        \[\leadsto 1 - \color{blue}{\frac{\frac{x}{z}}{y}} \]
      3. associate-/l/72.4%

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

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

    if -4.2e52 < y < 2e85

    1. Initial program 98.7%

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

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

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

Alternative 8: 81.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -3.8 \cdot 10^{-101} \lor \neg \left(y \leq 6 \cdot 10^{-44}\right):\\ \;\;\;\;1 - \frac{\frac{x}{y}}{y}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{x}{z \cdot t}\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (or (<= y -3.8e-101) (not (<= y 6e-44)))
   (- 1.0 (/ (/ x y) y))
   (- 1.0 (/ x (* z t)))))
double code(double x, double y, double z, double t) {
	double tmp;
	if ((y <= -3.8e-101) || !(y <= 6e-44)) {
		tmp = 1.0 - ((x / y) / y);
	} else {
		tmp = 1.0 - (x / (z * t));
	}
	return tmp;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: tmp
    if ((y <= (-3.8d-101)) .or. (.not. (y <= 6d-44))) then
        tmp = 1.0d0 - ((x / y) / y)
    else
        tmp = 1.0d0 - (x / (z * t))
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double tmp;
	if ((y <= -3.8e-101) || !(y <= 6e-44)) {
		tmp = 1.0 - ((x / y) / y);
	} else {
		tmp = 1.0 - (x / (z * t));
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if (y <= -3.8e-101) or not (y <= 6e-44):
		tmp = 1.0 - ((x / y) / y)
	else:
		tmp = 1.0 - (x / (z * t))
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if ((y <= -3.8e-101) || !(y <= 6e-44))
		tmp = Float64(1.0 - Float64(Float64(x / y) / y));
	else
		tmp = Float64(1.0 - Float64(x / Float64(z * t)));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if ((y <= -3.8e-101) || ~((y <= 6e-44)))
		tmp = 1.0 - ((x / y) / y);
	else
		tmp = 1.0 - (x / (z * t));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -3.8e-101], N[Not[LessEqual[y, 6e-44]], $MachinePrecision]], N[(1.0 - N[(N[(x / y), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(x / N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.8 \cdot 10^{-101} \lor \neg \left(y \leq 6 \cdot 10^{-44}\right):\\
\;\;\;\;1 - \frac{\frac{x}{y}}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -3.8000000000000001e-101 or 6.0000000000000005e-44 < y

    1. Initial program 100.0%

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

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

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

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

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

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

    if -3.8000000000000001e-101 < y < 6.0000000000000005e-44

    1. Initial program 98.1%

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

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

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

Alternative 9: 99.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ 1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)} \end{array} \]
(FPCore (x y z t) :precision binary64 (- 1.0 (/ x (* (- y z) (- y t)))))
double code(double x, double y, double z, double t) {
	return 1.0 - (x / ((y - z) * (y - t)));
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = 1.0d0 - (x / ((y - z) * (y - t)))
end function
public static double code(double x, double y, double z, double t) {
	return 1.0 - (x / ((y - z) * (y - t)));
}
def code(x, y, z, t):
	return 1.0 - (x / ((y - z) * (y - t)))
function code(x, y, z, t)
	return Float64(1.0 - Float64(x / Float64(Float64(y - z) * Float64(y - t))))
end
function tmp = code(x, y, z, t)
	tmp = 1.0 - (x / ((y - z) * (y - t)));
end
code[x_, y_, z_, t_] := N[(1.0 - N[(x / N[(N[(y - z), $MachinePrecision] * N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)}
\end{array}
Derivation
  1. Initial program 99.2%

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

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

Alternative 10: 61.7% accurate, 1.6× speedup?

\[\begin{array}{l} \\ 1 - \frac{x}{z \cdot t} \end{array} \]
(FPCore (x y z t) :precision binary64 (- 1.0 (/ x (* z t))))
double code(double x, double y, double z, double t) {
	return 1.0 - (x / (z * 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 / (z * t))
end function
public static double code(double x, double y, double z, double t) {
	return 1.0 - (x / (z * t));
}
def code(x, y, z, t):
	return 1.0 - (x / (z * t))
function code(x, y, z, t)
	return Float64(1.0 - Float64(x / Float64(z * t)))
end
function tmp = code(x, y, z, t)
	tmp = 1.0 - (x / (z * t));
end
code[x_, y_, z_, t_] := N[(1.0 - N[(x / N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
1 - \frac{x}{z \cdot t}
\end{array}
Derivation
  1. Initial program 99.2%

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

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

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

Reproduce

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