
(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:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(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}
(FPCore (x y z t) :precision binary64 (+ 1.0 (/ x (* (- y z) (- t y)))))
double code(double x, double y, double z, double t) {
return 1.0 + (x / ((y - z) * (t - y)));
}
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) * (t - y)))
end function
public static double code(double x, double y, double z, double t) {
return 1.0 + (x / ((y - z) * (t - y)));
}
def code(x, y, z, t): return 1.0 + (x / ((y - z) * (t - y)))
function code(x, y, z, t) return Float64(1.0 + Float64(x / Float64(Float64(y - z) * Float64(t - y)))) end
function tmp = code(x, y, z, t) tmp = 1.0 + (x / ((y - z) * (t - y))); end
code[x_, y_, z_, t_] := N[(1.0 + N[(x / N[(N[(y - z), $MachinePrecision] * N[(t - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \frac{x}{\left(y - z\right) \cdot \left(t - y\right)}
\end{array}
Initial program 99.8%
Final simplification99.8%
(FPCore (x y z t) :precision binary64 (if (or (<= y -1.5e-81) (not (<= y 7.2e-31))) (+ 1.0 (/ (/ x y) (- t y))) (+ 1.0 (/ (/ x z) (- y t)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -1.5e-81) || !(y <= 7.2e-31)) {
tmp = 1.0 + ((x / y) / (t - y));
} else {
tmp = 1.0 + ((x / z) / (y - 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 <= (-1.5d-81)) .or. (.not. (y <= 7.2d-31))) then
tmp = 1.0d0 + ((x / y) / (t - y))
else
tmp = 1.0d0 + ((x / z) / (y - t))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -1.5e-81) || !(y <= 7.2e-31)) {
tmp = 1.0 + ((x / y) / (t - y));
} else {
tmp = 1.0 + ((x / z) / (y - t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -1.5e-81) or not (y <= 7.2e-31): tmp = 1.0 + ((x / y) / (t - y)) else: tmp = 1.0 + ((x / z) / (y - t)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -1.5e-81) || !(y <= 7.2e-31)) tmp = Float64(1.0 + Float64(Float64(x / y) / Float64(t - y))); else tmp = Float64(1.0 + Float64(Float64(x / z) / Float64(y - t))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= -1.5e-81) || ~((y <= 7.2e-31))) tmp = 1.0 + ((x / y) / (t - y)); else tmp = 1.0 + ((x / z) / (y - t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -1.5e-81], N[Not[LessEqual[y, 7.2e-31]], $MachinePrecision]], N[(1.0 + N[(N[(x / y), $MachinePrecision] / N[(t - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(x / z), $MachinePrecision] / N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.5 \cdot 10^{-81} \lor \neg \left(y \leq 7.2 \cdot 10^{-31}\right):\\
\;\;\;\;1 + \frac{\frac{x}{y}}{t - y}\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{\frac{x}{z}}{y - t}\\
\end{array}
\end{array}
if y < -1.4999999999999999e-81 or 7.20000000000000007e-31 < y Initial program 99.9%
Taylor expanded in z around 0 92.0%
sub-neg92.0%
associate-/r*92.0%
distribute-neg-frac292.0%
neg-sub092.0%
sub-neg92.0%
+-commutative92.0%
associate--r+92.0%
neg-sub092.0%
remove-double-neg92.0%
Simplified92.0%
if -1.4999999999999999e-81 < y < 7.20000000000000007e-31Initial program 99.5%
Taylor expanded in z around inf 89.0%
associate-/r*86.4%
Simplified86.4%
Final simplification89.7%
(FPCore (x y z t) :precision binary64 (if (or (<= y -2.4e-88) (not (<= y 1.5e-149))) (+ 1.0 (/ (/ x y) (- t y))) (- 1.0 (/ x (* z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -2.4e-88) || !(y <= 1.5e-149)) {
tmp = 1.0 + ((x / y) / (t - 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 <= (-2.4d-88)) .or. (.not. (y <= 1.5d-149))) then
tmp = 1.0d0 + ((x / y) / (t - 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 <= -2.4e-88) || !(y <= 1.5e-149)) {
tmp = 1.0 + ((x / y) / (t - y));
} else {
tmp = 1.0 - (x / (z * t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -2.4e-88) or not (y <= 1.5e-149): tmp = 1.0 + ((x / y) / (t - y)) else: tmp = 1.0 - (x / (z * t)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -2.4e-88) || !(y <= 1.5e-149)) tmp = Float64(1.0 + Float64(Float64(x / y) / Float64(t - 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 <= -2.4e-88) || ~((y <= 1.5e-149))) tmp = 1.0 + ((x / y) / (t - y)); else tmp = 1.0 - (x / (z * t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -2.4e-88], N[Not[LessEqual[y, 1.5e-149]], $MachinePrecision]], N[(1.0 + N[(N[(x / y), $MachinePrecision] / N[(t - y), $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.4 \cdot 10^{-88} \lor \neg \left(y \leq 1.5 \cdot 10^{-149}\right):\\
\;\;\;\;1 + \frac{\frac{x}{y}}{t - y}\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{x}{z \cdot t}\\
\end{array}
\end{array}
if y < -2.4e-88 or 1.5000000000000001e-149 < y Initial program 99.9%
Taylor expanded in z around 0 86.7%
sub-neg86.7%
associate-/r*86.7%
distribute-neg-frac286.7%
neg-sub086.7%
sub-neg86.7%
+-commutative86.7%
associate--r+86.7%
neg-sub086.7%
remove-double-neg86.7%
Simplified86.7%
if -2.4e-88 < y < 1.5000000000000001e-149Initial program 99.3%
Taylor expanded in y around 0 87.2%
Final simplification86.9%
(FPCore (x y z t) :precision binary64 (if (<= y -9.1e-66) 1.0 (if (<= y 3.5e-137) (- 1.0 (/ x (* z t))) 1.0)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -9.1e-66) {
tmp = 1.0;
} else if (y <= 3.5e-137) {
tmp = 1.0 - (x / (z * t));
} 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 <= (-9.1d-66)) then
tmp = 1.0d0
else if (y <= 3.5d-137) then
tmp = 1.0d0 - (x / (z * t))
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 <= -9.1e-66) {
tmp = 1.0;
} else if (y <= 3.5e-137) {
tmp = 1.0 - (x / (z * t));
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -9.1e-66: tmp = 1.0 elif y <= 3.5e-137: tmp = 1.0 - (x / (z * t)) else: tmp = 1.0 return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -9.1e-66) tmp = 1.0; elseif (y <= 3.5e-137) tmp = Float64(1.0 - Float64(x / Float64(z * t))); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= -9.1e-66) tmp = 1.0; elseif (y <= 3.5e-137) tmp = 1.0 - (x / (z * t)); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -9.1e-66], 1.0, If[LessEqual[y, 3.5e-137], N[(1.0 - N[(x / N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9.1 \cdot 10^{-66}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 3.5 \cdot 10^{-137}:\\
\;\;\;\;1 - \frac{x}{z \cdot t}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -9.1000000000000001e-66 or 3.5000000000000001e-137 < y Initial program 99.9%
Taylor expanded in x around 0 87.1%
if -9.1000000000000001e-66 < y < 3.5000000000000001e-137Initial program 99.4%
Taylor expanded in y around 0 85.0%
Final simplification86.5%
(FPCore (x y z t) :precision binary64 (if (<= t -9.8e-111) 1.0 (if (<= t 2.4e-235) (+ 1.0 (/ x (* y z))) 1.0)))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -9.8e-111) {
tmp = 1.0;
} else if (t <= 2.4e-235) {
tmp = 1.0 + (x / (y * 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 (t <= (-9.8d-111)) then
tmp = 1.0d0
else if (t <= 2.4d-235) then
tmp = 1.0d0 + (x / (y * 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 (t <= -9.8e-111) {
tmp = 1.0;
} else if (t <= 2.4e-235) {
tmp = 1.0 + (x / (y * z));
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= -9.8e-111: tmp = 1.0 elif t <= 2.4e-235: tmp = 1.0 + (x / (y * z)) else: tmp = 1.0 return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= -9.8e-111) tmp = 1.0; elseif (t <= 2.4e-235) tmp = Float64(1.0 + Float64(x / Float64(y * z))); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= -9.8e-111) tmp = 1.0; elseif (t <= 2.4e-235) tmp = 1.0 + (x / (y * z)); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, -9.8e-111], 1.0, If[LessEqual[t, 2.4e-235], N[(1.0 + N[(x / N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -9.8 \cdot 10^{-111}:\\
\;\;\;\;1\\
\mathbf{elif}\;t \leq 2.4 \cdot 10^{-235}:\\
\;\;\;\;1 + \frac{x}{y \cdot z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if t < -9.80000000000000038e-111 or 2.40000000000000011e-235 < t Initial program 99.7%
Taylor expanded in x around 0 81.1%
if -9.80000000000000038e-111 < t < 2.40000000000000011e-235Initial program 99.9%
Taylor expanded in z around inf 85.1%
associate-/r*85.0%
Simplified85.0%
Taylor expanded in y around inf 78.2%
(FPCore (x y z t) :precision binary64 (if (<= z -4.3e-85) (+ 1.0 (/ (/ x z) (- y t))) (+ 1.0 (/ 1.0 (/ (* y (- t y)) x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -4.3e-85) {
tmp = 1.0 + ((x / z) / (y - t));
} else {
tmp = 1.0 + (1.0 / ((y * (t - y)) / x));
}
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 <= (-4.3d-85)) then
tmp = 1.0d0 + ((x / z) / (y - t))
else
tmp = 1.0d0 + (1.0d0 / ((y * (t - y)) / x))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -4.3e-85) {
tmp = 1.0 + ((x / z) / (y - t));
} else {
tmp = 1.0 + (1.0 / ((y * (t - y)) / x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -4.3e-85: tmp = 1.0 + ((x / z) / (y - t)) else: tmp = 1.0 + (1.0 / ((y * (t - y)) / x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -4.3e-85) tmp = Float64(1.0 + Float64(Float64(x / z) / Float64(y - t))); else tmp = Float64(1.0 + Float64(1.0 / Float64(Float64(y * Float64(t - y)) / x))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -4.3e-85) tmp = 1.0 + ((x / z) / (y - t)); else tmp = 1.0 + (1.0 / ((y * (t - y)) / x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -4.3e-85], N[(1.0 + N[(N[(x / z), $MachinePrecision] / N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(1.0 / N[(N[(y * N[(t - y), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.3 \cdot 10^{-85}:\\
\;\;\;\;1 + \frac{\frac{x}{z}}{y - t}\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{1}{\frac{y \cdot \left(t - y\right)}{x}}\\
\end{array}
\end{array}
if z < -4.29999999999999999e-85Initial program 100.0%
Taylor expanded in z around inf 96.9%
associate-/r*95.7%
Simplified95.7%
if -4.29999999999999999e-85 < z Initial program 99.7%
clear-num99.6%
inv-pow99.6%
associate-/l*99.1%
Applied egg-rr99.1%
unpow-199.1%
Simplified99.1%
Taylor expanded in z around 0 75.4%
Final simplification81.6%
(FPCore (x y z t) :precision binary64 (if (<= x 7.4e+250) 1.0 (/ x (* y t))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= 7.4e+250) {
tmp = 1.0;
} else {
tmp = x / (y * 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 (x <= 7.4d+250) then
tmp = 1.0d0
else
tmp = x / (y * t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (x <= 7.4e+250) {
tmp = 1.0;
} else {
tmp = x / (y * t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= 7.4e+250: tmp = 1.0 else: tmp = x / (y * t) return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= 7.4e+250) tmp = 1.0; else tmp = Float64(x / Float64(y * t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= 7.4e+250) tmp = 1.0; else tmp = x / (y * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, 7.4e+250], 1.0, N[(x / N[(y * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 7.4 \cdot 10^{+250}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y \cdot t}\\
\end{array}
\end{array}
if x < 7.40000000000000005e250Initial program 99.7%
Taylor expanded in x around 0 78.9%
if 7.40000000000000005e250 < x Initial program 100.0%
Taylor expanded in z around 0 55.5%
sub-neg55.5%
associate-/r*55.5%
distribute-neg-frac255.5%
neg-sub055.5%
sub-neg55.5%
+-commutative55.5%
associate--r+55.5%
neg-sub055.5%
remove-double-neg55.5%
Simplified55.5%
Taylor expanded in y around 0 56.5%
Final simplification77.9%
(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}
Initial program 99.8%
Taylor expanded in x around 0 76.4%
herbie shell --seed 2024184
(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)))))