
(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 7 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 t) (- z y)))))
double code(double x, double y, double z, double t) {
return 1.0 + (x / ((y - t) * (z - 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 - t) * (z - y)))
end function
public static double code(double x, double y, double z, double t) {
return 1.0 + (x / ((y - t) * (z - y)));
}
def code(x, y, z, t): return 1.0 + (x / ((y - t) * (z - y)))
function code(x, y, z, t) return Float64(1.0 + Float64(x / Float64(Float64(y - t) * Float64(z - y)))) end
function tmp = code(x, y, z, t) tmp = 1.0 + (x / ((y - t) * (z - y))); end
code[x_, y_, z_, t_] := N[(1.0 + N[(x / N[(N[(y - t), $MachinePrecision] * N[(z - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \frac{x}{\left(y - t\right) \cdot \left(z - y\right)}
\end{array}
Initial program 99.9%
Final simplification99.9%
(FPCore (x y z t) :precision binary64 (if (or (<= y -6.2e-80) (not (<= y 2.7e-17))) (- 1.0 (/ (/ x y) (- y t))) (+ 1.0 (/ (/ x t) (- y z)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -6.2e-80) || !(y <= 2.7e-17)) {
tmp = 1.0 - ((x / y) / (y - t));
} else {
tmp = 1.0 + ((x / t) / (y - z));
}
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 <= (-6.2d-80)) .or. (.not. (y <= 2.7d-17))) then
tmp = 1.0d0 - ((x / y) / (y - t))
else
tmp = 1.0d0 + ((x / t) / (y - z))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -6.2e-80) || !(y <= 2.7e-17)) {
tmp = 1.0 - ((x / y) / (y - t));
} else {
tmp = 1.0 + ((x / t) / (y - z));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -6.2e-80) or not (y <= 2.7e-17): tmp = 1.0 - ((x / y) / (y - t)) else: tmp = 1.0 + ((x / t) / (y - z)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -6.2e-80) || !(y <= 2.7e-17)) tmp = Float64(1.0 - Float64(Float64(x / y) / Float64(y - t))); else tmp = Float64(1.0 + Float64(Float64(x / t) / Float64(y - z))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= -6.2e-80) || ~((y <= 2.7e-17))) tmp = 1.0 - ((x / y) / (y - t)); else tmp = 1.0 + ((x / t) / (y - z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -6.2e-80], N[Not[LessEqual[y, 2.7e-17]], $MachinePrecision]], N[(1.0 - N[(N[(x / y), $MachinePrecision] / N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(x / t), $MachinePrecision] / N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.2 \cdot 10^{-80} \lor \neg \left(y \leq 2.7 \cdot 10^{-17}\right):\\
\;\;\;\;1 - \frac{\frac{x}{y}}{y - t}\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{\frac{x}{t}}{y - z}\\
\end{array}
\end{array}
if y < -6.20000000000000032e-80 or 2.7000000000000001e-17 < y Initial program 100.0%
Taylor expanded in z around 0 95.5%
sub-neg95.5%
associate-/r*95.5%
distribute-neg-frac295.5%
neg-sub095.5%
sub-neg95.5%
+-commutative95.5%
associate--r+95.5%
neg-sub095.5%
remove-double-neg95.5%
Simplified95.5%
if -6.20000000000000032e-80 < y < 2.7000000000000001e-17Initial program 99.9%
Taylor expanded in t around inf 87.3%
associate-/r*85.4%
Simplified85.4%
Final simplification91.6%
(FPCore (x y z t)
:precision binary64
(if (<= z -5.2e-77)
(+ 1.0 (/ (/ x z) (- y t)))
(if (<= z 2.4e-185)
(- 1.0 (/ (/ x y) (- y t)))
(+ 1.0 (/ (/ x t) (- y z))))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -5.2e-77) {
tmp = 1.0 + ((x / z) / (y - t));
} else if (z <= 2.4e-185) {
tmp = 1.0 - ((x / y) / (y - t));
} else {
tmp = 1.0 + ((x / t) / (y - z));
}
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.2d-77)) then
tmp = 1.0d0 + ((x / z) / (y - t))
else if (z <= 2.4d-185) then
tmp = 1.0d0 - ((x / y) / (y - t))
else
tmp = 1.0d0 + ((x / t) / (y - z))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -5.2e-77) {
tmp = 1.0 + ((x / z) / (y - t));
} else if (z <= 2.4e-185) {
tmp = 1.0 - ((x / y) / (y - t));
} else {
tmp = 1.0 + ((x / t) / (y - z));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -5.2e-77: tmp = 1.0 + ((x / z) / (y - t)) elif z <= 2.4e-185: tmp = 1.0 - ((x / y) / (y - t)) else: tmp = 1.0 + ((x / t) / (y - z)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -5.2e-77) tmp = Float64(1.0 + Float64(Float64(x / z) / Float64(y - t))); elseif (z <= 2.4e-185) tmp = Float64(1.0 - Float64(Float64(x / y) / Float64(y - t))); else tmp = Float64(1.0 + Float64(Float64(x / t) / Float64(y - z))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -5.2e-77) tmp = 1.0 + ((x / z) / (y - t)); elseif (z <= 2.4e-185) tmp = 1.0 - ((x / y) / (y - t)); else tmp = 1.0 + ((x / t) / (y - z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -5.2e-77], N[(1.0 + N[(N[(x / z), $MachinePrecision] / N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2.4e-185], N[(1.0 - N[(N[(x / y), $MachinePrecision] / N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(x / t), $MachinePrecision] / N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.2 \cdot 10^{-77}:\\
\;\;\;\;1 + \frac{\frac{x}{z}}{y - t}\\
\mathbf{elif}\;z \leq 2.4 \cdot 10^{-185}:\\
\;\;\;\;1 - \frac{\frac{x}{y}}{y - t}\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{\frac{x}{t}}{y - z}\\
\end{array}
\end{array}
if z < -5.2000000000000002e-77Initial program 99.9%
Taylor expanded in z around inf 96.2%
associate-/r*94.5%
Simplified94.5%
if -5.2000000000000002e-77 < z < 2.4000000000000001e-185Initial program 99.9%
Taylor expanded in z around 0 90.8%
sub-neg90.8%
associate-/r*88.6%
distribute-neg-frac288.6%
neg-sub088.6%
sub-neg88.6%
+-commutative88.6%
associate--r+88.6%
neg-sub088.6%
remove-double-neg88.6%
Simplified88.6%
if 2.4000000000000001e-185 < z Initial program 99.9%
Taylor expanded in t around inf 79.7%
associate-/r*78.8%
Simplified78.8%
Final simplification86.7%
(FPCore (x y z t) :precision binary64 (if (<= y -1.2e-64) 1.0 (if (<= y 1.9e+40) (+ 1.0 (/ (/ x t) (- y z))) 1.0)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.2e-64) {
tmp = 1.0;
} else if (y <= 1.9e+40) {
tmp = 1.0 + ((x / t) / (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 (y <= (-1.2d-64)) then
tmp = 1.0d0
else if (y <= 1.9d+40) then
tmp = 1.0d0 + ((x / t) / (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 (y <= -1.2e-64) {
tmp = 1.0;
} else if (y <= 1.9e+40) {
tmp = 1.0 + ((x / t) / (y - z));
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -1.2e-64: tmp = 1.0 elif y <= 1.9e+40: tmp = 1.0 + ((x / t) / (y - z)) else: tmp = 1.0 return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -1.2e-64) tmp = 1.0; elseif (y <= 1.9e+40) tmp = Float64(1.0 + Float64(Float64(x / t) / Float64(y - z))); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= -1.2e-64) tmp = 1.0; elseif (y <= 1.9e+40) tmp = 1.0 + ((x / t) / (y - z)); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -1.2e-64], 1.0, If[LessEqual[y, 1.9e+40], N[(1.0 + N[(N[(x / t), $MachinePrecision] / N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.2 \cdot 10^{-64}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 1.9 \cdot 10^{+40}:\\
\;\;\;\;1 + \frac{\frac{x}{t}}{y - z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1.19999999999999999e-64 or 1.90000000000000002e40 < y Initial program 100.0%
Taylor expanded in x around 0 94.6%
if -1.19999999999999999e-64 < y < 1.90000000000000002e40Initial program 99.9%
Taylor expanded in t around inf 84.4%
associate-/r*82.7%
Simplified82.7%
(FPCore (x y z t) :precision binary64 (if (<= y -2.7e-70) 1.0 (if (<= y 1.6e-113) (- 1.0 (/ x (* z t))) 1.0)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -2.7e-70) {
tmp = 1.0;
} else if (y <= 1.6e-113) {
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 <= (-2.7d-70)) then
tmp = 1.0d0
else if (y <= 1.6d-113) 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 <= -2.7e-70) {
tmp = 1.0;
} else if (y <= 1.6e-113) {
tmp = 1.0 - (x / (z * t));
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -2.7e-70: tmp = 1.0 elif y <= 1.6e-113: tmp = 1.0 - (x / (z * t)) else: tmp = 1.0 return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -2.7e-70) tmp = 1.0; elseif (y <= 1.6e-113) 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 <= -2.7e-70) tmp = 1.0; elseif (y <= 1.6e-113) tmp = 1.0 - (x / (z * t)); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -2.7e-70], 1.0, If[LessEqual[y, 1.6e-113], N[(1.0 - N[(x / N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.7 \cdot 10^{-70}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 1.6 \cdot 10^{-113}:\\
\;\;\;\;1 - \frac{x}{z \cdot t}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -2.7000000000000001e-70 or 1.6000000000000001e-113 < y Initial program 100.0%
Taylor expanded in x around 0 89.0%
if -2.7000000000000001e-70 < y < 1.6000000000000001e-113Initial program 99.8%
Taylor expanded in y around 0 84.7%
Final simplification87.6%
(FPCore (x y z t) :precision binary64 (if (<= y -4.6e-198) 1.0 (if (<= y 4.4e-283) (/ x (* z (- t))) 1.0)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -4.6e-198) {
tmp = 1.0;
} else if (y <= 4.4e-283) {
tmp = 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 <= (-4.6d-198)) then
tmp = 1.0d0
else if (y <= 4.4d-283) then
tmp = 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 <= -4.6e-198) {
tmp = 1.0;
} else if (y <= 4.4e-283) {
tmp = x / (z * -t);
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -4.6e-198: tmp = 1.0 elif y <= 4.4e-283: tmp = x / (z * -t) else: tmp = 1.0 return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -4.6e-198) tmp = 1.0; elseif (y <= 4.4e-283) tmp = Float64(x / Float64(z * Float64(-t))); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= -4.6e-198) tmp = 1.0; elseif (y <= 4.4e-283) tmp = x / (z * -t); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -4.6e-198], 1.0, If[LessEqual[y, 4.4e-283], N[(x / N[(z * (-t)), $MachinePrecision]), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.6 \cdot 10^{-198}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 4.4 \cdot 10^{-283}:\\
\;\;\;\;\frac{x}{z \cdot \left(-t\right)}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -4.60000000000000027e-198 or 4.3999999999999996e-283 < y Initial program 100.0%
Taylor expanded in x around 0 82.4%
if -4.60000000000000027e-198 < y < 4.3999999999999996e-283Initial program 99.7%
Taylor expanded in y around 0 95.5%
Taylor expanded in x around inf 72.1%
associate-*r/72.1%
neg-mul-172.1%
Simplified72.1%
Final simplification81.4%
(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.9%
Taylor expanded in x around 0 76.8%
herbie shell --seed 2024172
(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)))))