
(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 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.9%
Final simplification99.9%
(FPCore (x y z t) :precision binary64 (if (<= z -6e-40) (+ 1.0 (/ (/ x z) (- y t))) (if (<= z 1.02e-44) (- 1.0 (/ x (* y (- y t)))) (- 1.0 (/ x (* z t))))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -6e-40) {
tmp = 1.0 + ((x / z) / (y - t));
} else if (z <= 1.02e-44) {
tmp = 1.0 - (x / (y * (y - t)));
} 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 (z <= (-6d-40)) then
tmp = 1.0d0 + ((x / z) / (y - t))
else if (z <= 1.02d-44) then
tmp = 1.0d0 - (x / (y * (y - t)))
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 (z <= -6e-40) {
tmp = 1.0 + ((x / z) / (y - t));
} else if (z <= 1.02e-44) {
tmp = 1.0 - (x / (y * (y - t)));
} else {
tmp = 1.0 - (x / (z * t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -6e-40: tmp = 1.0 + ((x / z) / (y - t)) elif z <= 1.02e-44: tmp = 1.0 - (x / (y * (y - t))) else: tmp = 1.0 - (x / (z * t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -6e-40) tmp = Float64(1.0 + Float64(Float64(x / z) / Float64(y - t))); elseif (z <= 1.02e-44) tmp = Float64(1.0 - Float64(x / Float64(y * Float64(y - t)))); 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 (z <= -6e-40) tmp = 1.0 + ((x / z) / (y - t)); elseif (z <= 1.02e-44) tmp = 1.0 - (x / (y * (y - t))); else tmp = 1.0 - (x / (z * t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -6e-40], N[(1.0 + N[(N[(x / z), $MachinePrecision] / N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.02e-44], N[(1.0 - N[(x / N[(y * N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(x / N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6 \cdot 10^{-40}:\\
\;\;\;\;1 + \frac{\frac{x}{z}}{y - t}\\
\mathbf{elif}\;z \leq 1.02 \cdot 10^{-44}:\\
\;\;\;\;1 - \frac{x}{y \cdot \left(y - t\right)}\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{x}{z \cdot t}\\
\end{array}
\end{array}
if z < -6.00000000000000039e-40Initial program 99.9%
Taylor expanded in z around inf 98.6%
+-commutative98.6%
associate-/r*98.6%
Simplified98.6%
if -6.00000000000000039e-40 < z < 1.0199999999999999e-44Initial program 99.9%
Taylor expanded in z around 0 96.3%
if 1.0199999999999999e-44 < z Initial program 100.0%
Taylor expanded in y around 0 78.0%
Final simplification92.0%
(FPCore (x y z t) :precision binary64 (if (<= y -1150.0) 1.0 (if (<= y 8e-60) (+ 1.0 (/ (/ x t) (- y z))) 1.0)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1150.0) {
tmp = 1.0;
} else if (y <= 8e-60) {
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 <= (-1150.0d0)) then
tmp = 1.0d0
else if (y <= 8d-60) 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 <= -1150.0) {
tmp = 1.0;
} else if (y <= 8e-60) {
tmp = 1.0 + ((x / t) / (y - z));
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -1150.0: tmp = 1.0 elif y <= 8e-60: tmp = 1.0 + ((x / t) / (y - z)) else: tmp = 1.0 return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -1150.0) tmp = 1.0; elseif (y <= 8e-60) 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 <= -1150.0) tmp = 1.0; elseif (y <= 8e-60) tmp = 1.0 + ((x / t) / (y - z)); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -1150.0], 1.0, If[LessEqual[y, 8e-60], 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 -1150:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 8 \cdot 10^{-60}:\\
\;\;\;\;1 + \frac{\frac{x}{t}}{y - z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1150 or 7.9999999999999998e-60 < y Initial program 100.0%
Taylor expanded in x around 0 91.4%
if -1150 < y < 7.9999999999999998e-60Initial program 99.9%
Taylor expanded in t around inf 86.1%
+-commutative86.1%
associate-/r*84.2%
Simplified84.2%
Final simplification88.4%
(FPCore (x y z t) :precision binary64 (if (<= y -2.85e-9) 1.0 (if (<= y 1.16e-142) (+ 1.0 (/ x (* z (- y t)))) 1.0)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -2.85e-9) {
tmp = 1.0;
} else if (y <= 1.16e-142) {
tmp = 1.0 + (x / (z * (y - 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.85d-9)) then
tmp = 1.0d0
else if (y <= 1.16d-142) then
tmp = 1.0d0 + (x / (z * (y - 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.85e-9) {
tmp = 1.0;
} else if (y <= 1.16e-142) {
tmp = 1.0 + (x / (z * (y - t)));
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -2.85e-9: tmp = 1.0 elif y <= 1.16e-142: tmp = 1.0 + (x / (z * (y - t))) else: tmp = 1.0 return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -2.85e-9) tmp = 1.0; elseif (y <= 1.16e-142) tmp = Float64(1.0 + Float64(x / Float64(z * Float64(y - t)))); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= -2.85e-9) tmp = 1.0; elseif (y <= 1.16e-142) tmp = 1.0 + (x / (z * (y - t))); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -2.85e-9], 1.0, If[LessEqual[y, 1.16e-142], N[(1.0 + N[(x / N[(z * N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.85 \cdot 10^{-9}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 1.16 \cdot 10^{-142}:\\
\;\;\;\;1 + \frac{x}{z \cdot \left(y - t\right)}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -2.8499999999999999e-9 or 1.16e-142 < y Initial program 100.0%
Taylor expanded in x around 0 90.3%
if -2.8499999999999999e-9 < y < 1.16e-142Initial program 99.9%
Taylor expanded in z around inf 86.4%
+-commutative86.4%
*-commutative86.4%
Simplified86.4%
Final simplification88.9%
(FPCore (x y z t) :precision binary64 (if (<= y -1.55e-78) 1.0 (if (<= y 1.85e-107) (- 1.0 (/ x (* z t))) 1.0)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.55e-78) {
tmp = 1.0;
} else if (y <= 1.85e-107) {
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 <= (-1.55d-78)) then
tmp = 1.0d0
else if (y <= 1.85d-107) 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 <= -1.55e-78) {
tmp = 1.0;
} else if (y <= 1.85e-107) {
tmp = 1.0 - (x / (z * t));
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -1.55e-78: tmp = 1.0 elif y <= 1.85e-107: tmp = 1.0 - (x / (z * t)) else: tmp = 1.0 return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -1.55e-78) tmp = 1.0; elseif (y <= 1.85e-107) 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 <= -1.55e-78) tmp = 1.0; elseif (y <= 1.85e-107) tmp = 1.0 - (x / (z * t)); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -1.55e-78], 1.0, If[LessEqual[y, 1.85e-107], N[(1.0 - N[(x / N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.55 \cdot 10^{-78}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 1.85 \cdot 10^{-107}:\\
\;\;\;\;1 - \frac{x}{z \cdot t}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1.55000000000000009e-78 or 1.8500000000000001e-107 < y Initial program 100.0%
Taylor expanded in x around 0 89.2%
if -1.55000000000000009e-78 < y < 1.8500000000000001e-107Initial program 99.9%
Taylor expanded in y around 0 82.4%
Final simplification87.0%
(FPCore (x y z t) :precision binary64 (if (<= z -1.95e-280) 1.0 (+ 1.0 (/ x (* y t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.95e-280) {
tmp = 1.0;
} else {
tmp = 1.0 + (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 (z <= (-1.95d-280)) then
tmp = 1.0d0
else
tmp = 1.0d0 + (x / (y * t))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.95e-280) {
tmp = 1.0;
} else {
tmp = 1.0 + (x / (y * t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -1.95e-280: tmp = 1.0 else: tmp = 1.0 + (x / (y * t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -1.95e-280) tmp = 1.0; else tmp = Float64(1.0 + Float64(x / Float64(y * t))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -1.95e-280) tmp = 1.0; else tmp = 1.0 + (x / (y * t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -1.95e-280], 1.0, N[(1.0 + N[(x / N[(y * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.95 \cdot 10^{-280}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{x}{y \cdot t}\\
\end{array}
\end{array}
if z < -1.94999999999999999e-280Initial program 100.0%
Taylor expanded in x around 0 82.2%
if -1.94999999999999999e-280 < z Initial program 99.9%
Taylor expanded in z around 0 79.2%
associate-/r*76.9%
Simplified76.9%
Taylor expanded in t around inf 60.5%
Final simplification72.0%
(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 79.1%
herbie shell --seed 2024091
(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)))))