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

Percentage Accurate: 99.0% → 99.0%
Time: 11.0s
Alternatives: 9
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 9 alternatives:

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

Initial Program: 99.0% accurate, 1.0× speedup?

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

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

Alternative 1: 99.0% accurate, 1.0× speedup?

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

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

    \[1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)} \]
  2. Add Preprocessing
  3. Add Preprocessing

Alternative 2: 81.9% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.2 \cdot 10^{-79}:\\
\;\;\;\;1\\

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

\mathbf{elif}\;y \leq 3.2 \cdot 10^{-7}:\\
\;\;\;\;\frac{x}{t \cdot y} + 1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -8.19999999999999987e-79

    1. Initial program 100.0%

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

      \[\leadsto expr\]
    4. Simplified0

      \[\leadsto expr\]

    if -8.19999999999999987e-79 < y < 3.60000000000000016e-92

    1. Initial program 97.9%

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

      \[\leadsto expr\]
    4. Simplified0

      \[\leadsto expr\]

    if 3.60000000000000016e-92 < y < 3.2000000000000001e-7

    1. Initial program 99.9%

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

      \[\leadsto expr\]
    4. Simplified0

      \[\leadsto expr\]
    5. Taylor expanded in z around 0 0

      \[\leadsto expr\]
    6. Simplified0

      \[\leadsto expr\]

    if 3.2000000000000001e-7 < y

    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 inf 0

      \[\leadsto expr\]
    4. Simplified0

      \[\leadsto expr\]
    5. Applied egg-rr0

      \[\leadsto expr\]
  3. Recombined 4 regimes into one program.
  4. Add Preprocessing

Alternative 3: 81.9% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.48 \cdot 10^{-77}:\\
\;\;\;\;1\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -1.48000000000000002e-77

    1. Initial program 100.0%

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

      \[\leadsto expr\]
    4. Simplified0

      \[\leadsto expr\]

    if -1.48000000000000002e-77 < y < 2.35000000000000003e-91

    1. Initial program 97.9%

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

      \[\leadsto expr\]
    4. Simplified0

      \[\leadsto expr\]

    if 2.35000000000000003e-91 < y < 5.00000000000000041e-6

    1. Initial program 99.9%

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

      \[\leadsto expr\]
    4. Simplified0

      \[\leadsto expr\]
    5. Taylor expanded in z around 0 0

      \[\leadsto expr\]
    6. Simplified0

      \[\leadsto expr\]

    if 5.00000000000000041e-6 < y

    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 inf 0

      \[\leadsto expr\]
    4. Simplified0

      \[\leadsto expr\]
  3. Recombined 4 regimes into one program.
  4. Add Preprocessing

Alternative 4: 85.6% accurate, 0.6× speedup?

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

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

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

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


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

    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 0

      \[\leadsto expr\]
    4. Simplified0

      \[\leadsto expr\]

    if -6.9999999999999994e-89 < t < 1.1499999999999999e-22

    1. Initial program 98.3%

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

      \[\leadsto expr\]
    4. Simplified0

      \[\leadsto expr\]

    if 1.1499999999999999e-22 < t

    1. Initial program 99.9%

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

      \[\leadsto expr\]
    4. Simplified0

      \[\leadsto expr\]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 5: 85.8% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -9.8 \cdot 10^{-79}:\\
\;\;\;\;1 - \frac{x}{\left(y - z\right) \cdot y}\\

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

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


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

    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 inf 0

      \[\leadsto expr\]
    4. Simplified0

      \[\leadsto expr\]

    if -9.8000000000000001e-79 < y < 7.20000000000000035e-69

    1. Initial program 98.1%

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

      \[\leadsto expr\]
    4. Simplified0

      \[\leadsto expr\]

    if 7.20000000000000035e-69 < y

    1. Initial program 99.9%

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

      \[\leadsto expr\]
    4. Simplified0

      \[\leadsto expr\]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 6: 85.7% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
t_1 := 1 + \frac{\frac{x}{y}}{t - y}\\
\mathbf{if}\;y \leq -1.25 \cdot 10^{-82}:\\
\;\;\;\;t\_1\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.25e-82 or 4.1999999999999999e-69 < y

    1. Initial program 100.0%

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

      \[\leadsto expr\]
    4. Simplified0

      \[\leadsto expr\]

    if -1.25e-82 < y < 4.1999999999999999e-69

    1. Initial program 98.1%

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

      \[\leadsto expr\]
    4. Simplified0

      \[\leadsto expr\]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 7: 83.6% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.22 \cdot 10^{-77}:\\
\;\;\;\;1\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.22000000000000001e-77 or 8.20000000000000007e-72 < y

    1. Initial program 100.0%

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

      \[\leadsto expr\]
    4. Simplified0

      \[\leadsto expr\]

    if -1.22000000000000001e-77 < y < 8.20000000000000007e-72

    1. Initial program 98.0%

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

      \[\leadsto expr\]
    4. Simplified0

      \[\leadsto expr\]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 8: 76.0% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.6 \cdot 10^{-248}:\\
\;\;\;\;1\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -5.6000000000000002e-248 or 2.5499999999999999e-194 < 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 x around 0 0

      \[\leadsto expr\]
    4. Simplified0

      \[\leadsto expr\]

    if -5.6000000000000002e-248 < z < 2.5499999999999999e-194

    1. Initial program 93.9%

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

      \[\leadsto expr\]
    4. Simplified0

      \[\leadsto expr\]
    5. Taylor expanded in z around 0 0

      \[\leadsto expr\]
    6. Simplified0

      \[\leadsto expr\]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 9: 74.5% accurate, 11.0× speedup?

\[\begin{array}{l} \\ 1 \end{array} \]
(FPCore (x y z t) :precision binary64 1.0)
double code(double x, double y, double z, double t) {
	return 1.0;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = 1.0d0
end function
public static double code(double x, double y, double z, double t) {
	return 1.0;
}
def code(x, y, z, t):
	return 1.0
function code(x, y, z, t)
	return 1.0
end
function tmp = code(x, y, z, t)
	tmp = 1.0;
end
code[x_, y_, z_, t_] := 1.0
\begin{array}{l}

\\
1
\end{array}
Derivation
  1. Initial program 99.2%

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

    \[\leadsto expr\]
  4. Simplified0

    \[\leadsto expr\]
  5. Add Preprocessing

Reproduce

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