
(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 98.8%
Final simplification98.8%
(FPCore (x y z t) :precision binary64 (if (<= y -4.5e-62) 1.0 (if (<= y 3.2e-100) (+ 1.0 (/ (/ x t) (- y z))) 1.0)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -4.5e-62) {
tmp = 1.0;
} else if (y <= 3.2e-100) {
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 <= (-4.5d-62)) then
tmp = 1.0d0
else if (y <= 3.2d-100) 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 <= -4.5e-62) {
tmp = 1.0;
} else if (y <= 3.2e-100) {
tmp = 1.0 + ((x / t) / (y - z));
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -4.5e-62: tmp = 1.0 elif y <= 3.2e-100: tmp = 1.0 + ((x / t) / (y - z)) else: tmp = 1.0 return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -4.5e-62) tmp = 1.0; elseif (y <= 3.2e-100) 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 <= -4.5e-62) tmp = 1.0; elseif (y <= 3.2e-100) tmp = 1.0 + ((x / t) / (y - z)); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -4.5e-62], 1.0, If[LessEqual[y, 3.2e-100], 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 -4.5 \cdot 10^{-62}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 3.2 \cdot 10^{-100}:\\
\;\;\;\;1 + \frac{\frac{x}{t}}{y - z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -4.50000000000000018e-62 or 3.20000000000000017e-100 < y Initial program 99.9%
Taylor expanded in x around 0 89.8%
if -4.50000000000000018e-62 < y < 3.20000000000000017e-100Initial program 96.8%
Taylor expanded in t around inf 81.2%
+-commutative81.2%
associate-/r*81.2%
Simplified81.2%
Final simplification86.6%
(FPCore (x y z t)
:precision binary64
(if (<= z -2.55e-115)
(+ 1.0 (/ (/ x z) (- y t)))
(if (<= z 2.95e-167)
(- 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 <= -2.55e-115) {
tmp = 1.0 + ((x / z) / (y - t));
} else if (z <= 2.95e-167) {
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 <= (-2.55d-115)) then
tmp = 1.0d0 + ((x / z) / (y - t))
else if (z <= 2.95d-167) 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 <= -2.55e-115) {
tmp = 1.0 + ((x / z) / (y - t));
} else if (z <= 2.95e-167) {
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 <= -2.55e-115: tmp = 1.0 + ((x / z) / (y - t)) elif z <= 2.95e-167: 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 <= -2.55e-115) tmp = Float64(1.0 + Float64(Float64(x / z) / Float64(y - t))); elseif (z <= 2.95e-167) tmp = Float64(1.0 - Float64(x / Float64(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 <= -2.55e-115) tmp = 1.0 + ((x / z) / (y - t)); elseif (z <= 2.95e-167) 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, -2.55e-115], N[(1.0 + N[(N[(x / z), $MachinePrecision] / N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2.95e-167], N[(1.0 - N[(x / N[(y * N[(y - t), $MachinePrecision]), $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 -2.55 \cdot 10^{-115}:\\
\;\;\;\;1 + \frac{\frac{x}{z}}{y - t}\\
\mathbf{elif}\;z \leq 2.95 \cdot 10^{-167}:\\
\;\;\;\;1 - \frac{x}{y \cdot \left(y - t\right)}\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{\frac{x}{t}}{y - z}\\
\end{array}
\end{array}
if z < -2.5499999999999999e-115Initial program 99.9%
Taylor expanded in z around inf 93.3%
+-commutative93.3%
associate-/r*92.2%
Simplified92.2%
if -2.5499999999999999e-115 < z < 2.95000000000000011e-167Initial program 96.6%
Taylor expanded in z around 0 88.4%
if 2.95000000000000011e-167 < z Initial program 99.0%
Taylor expanded in t around inf 79.7%
+-commutative79.7%
associate-/r*79.4%
Simplified79.4%
Final simplification86.0%
(FPCore (x y z t) :precision binary64 (if (<= t -3.7e-225) (+ 1.0 (/ (/ x z) (- y t))) (if (<= t 5e-84) (+ 1.0 (/ x (* y (- z y)))) (+ 1.0 (/ (/ x t) (- y z))))))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -3.7e-225) {
tmp = 1.0 + ((x / z) / (y - t));
} else if (t <= 5e-84) {
tmp = 1.0 + (x / (y * (z - y)));
} 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 (t <= (-3.7d-225)) then
tmp = 1.0d0 + ((x / z) / (y - t))
else if (t <= 5d-84) then
tmp = 1.0d0 + (x / (y * (z - y)))
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 (t <= -3.7e-225) {
tmp = 1.0 + ((x / z) / (y - t));
} else if (t <= 5e-84) {
tmp = 1.0 + (x / (y * (z - y)));
} else {
tmp = 1.0 + ((x / t) / (y - z));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= -3.7e-225: tmp = 1.0 + ((x / z) / (y - t)) elif t <= 5e-84: tmp = 1.0 + (x / (y * (z - y))) else: tmp = 1.0 + ((x / t) / (y - z)) return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= -3.7e-225) tmp = Float64(1.0 + Float64(Float64(x / z) / Float64(y - t))); elseif (t <= 5e-84) tmp = Float64(1.0 + Float64(x / Float64(y * Float64(z - y)))); 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 (t <= -3.7e-225) tmp = 1.0 + ((x / z) / (y - t)); elseif (t <= 5e-84) tmp = 1.0 + (x / (y * (z - y))); else tmp = 1.0 + ((x / t) / (y - z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, -3.7e-225], N[(1.0 + N[(N[(x / z), $MachinePrecision] / N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 5e-84], N[(1.0 + N[(x / N[(y * N[(z - y), $MachinePrecision]), $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}\;t \leq -3.7 \cdot 10^{-225}:\\
\;\;\;\;1 + \frac{\frac{x}{z}}{y - t}\\
\mathbf{elif}\;t \leq 5 \cdot 10^{-84}:\\
\;\;\;\;1 + \frac{x}{y \cdot \left(z - y\right)}\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{\frac{x}{t}}{y - z}\\
\end{array}
\end{array}
if t < -3.69999999999999988e-225Initial program 99.0%
Taylor expanded in z around inf 76.4%
+-commutative76.4%
associate-/r*76.4%
Simplified76.4%
if -3.69999999999999988e-225 < t < 5.0000000000000002e-84Initial program 98.4%
Taylor expanded in t around 0 86.0%
if 5.0000000000000002e-84 < t Initial program 98.8%
Taylor expanded in t around inf 93.3%
+-commutative93.3%
associate-/r*94.4%
Simplified94.4%
Final simplification84.7%
(FPCore (x y z t) :precision binary64 (if (<= t -2.2e-110) 1.0 (if (<= t 6.2e-212) (+ 1.0 (/ x (* y z))) 1.0)))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -2.2e-110) {
tmp = 1.0;
} else if (t <= 6.2e-212) {
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 <= (-2.2d-110)) then
tmp = 1.0d0
else if (t <= 6.2d-212) 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 <= -2.2e-110) {
tmp = 1.0;
} else if (t <= 6.2e-212) {
tmp = 1.0 + (x / (y * z));
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= -2.2e-110: tmp = 1.0 elif t <= 6.2e-212: tmp = 1.0 + (x / (y * z)) else: tmp = 1.0 return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= -2.2e-110) tmp = 1.0; elseif (t <= 6.2e-212) 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 <= -2.2e-110) tmp = 1.0; elseif (t <= 6.2e-212) tmp = 1.0 + (x / (y * z)); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, -2.2e-110], 1.0, If[LessEqual[t, 6.2e-212], N[(1.0 + N[(x / N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -2.2 \cdot 10^{-110}:\\
\;\;\;\;1\\
\mathbf{elif}\;t \leq 6.2 \cdot 10^{-212}:\\
\;\;\;\;1 + \frac{x}{y \cdot z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if t < -2.1999999999999999e-110 or 6.20000000000000011e-212 < t Initial program 99.4%
Taylor expanded in x around 0 79.5%
if -2.1999999999999999e-110 < t < 6.20000000000000011e-212Initial program 96.6%
Taylor expanded in z around inf 77.6%
+-commutative77.6%
associate-/r*79.3%
Simplified79.3%
Taylor expanded in y around inf 67.8%
*-commutative67.8%
Simplified67.8%
Final simplification76.8%
(FPCore (x y z t) :precision binary64 (if (<= y -6.8e-91) 1.0 (if (<= y 2.15e-100) (- 1.0 (/ x (* z t))) 1.0)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -6.8e-91) {
tmp = 1.0;
} else if (y <= 2.15e-100) {
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 <= (-6.8d-91)) then
tmp = 1.0d0
else if (y <= 2.15d-100) 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 <= -6.8e-91) {
tmp = 1.0;
} else if (y <= 2.15e-100) {
tmp = 1.0 - (x / (z * t));
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -6.8e-91: tmp = 1.0 elif y <= 2.15e-100: tmp = 1.0 - (x / (z * t)) else: tmp = 1.0 return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -6.8e-91) tmp = 1.0; elseif (y <= 2.15e-100) 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 <= -6.8e-91) tmp = 1.0; elseif (y <= 2.15e-100) tmp = 1.0 - (x / (z * t)); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -6.8e-91], 1.0, If[LessEqual[y, 2.15e-100], N[(1.0 - N[(x / N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.8 \cdot 10^{-91}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 2.15 \cdot 10^{-100}:\\
\;\;\;\;1 - \frac{x}{z \cdot t}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -6.80000000000000053e-91 or 2.14999999999999999e-100 < y Initial program 99.9%
Taylor expanded in x around 0 87.7%
if -6.80000000000000053e-91 < y < 2.14999999999999999e-100Initial program 96.4%
Taylor expanded in y around 0 78.0%
Final simplification84.5%
(FPCore (x y z t) :precision binary64 (if (<= t 1.4e-82) (+ 1.0 (/ (/ x z) (- y t))) (+ 1.0 (/ (/ x t) (- y z)))))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= 1.4e-82) {
tmp = 1.0 + ((x / z) / (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 (t <= 1.4d-82) then
tmp = 1.0d0 + ((x / z) / (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 (t <= 1.4e-82) {
tmp = 1.0 + ((x / z) / (y - t));
} else {
tmp = 1.0 + ((x / t) / (y - z));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= 1.4e-82: tmp = 1.0 + ((x / z) / (y - t)) else: tmp = 1.0 + ((x / t) / (y - z)) return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= 1.4e-82) tmp = Float64(1.0 + Float64(Float64(x / z) / 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 (t <= 1.4e-82) tmp = 1.0 + ((x / z) / (y - t)); else tmp = 1.0 + ((x / t) / (y - z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, 1.4e-82], N[(1.0 + N[(N[(x / z), $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}\;t \leq 1.4 \cdot 10^{-82}:\\
\;\;\;\;1 + \frac{\frac{x}{z}}{y - t}\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{\frac{x}{t}}{y - z}\\
\end{array}
\end{array}
if t < 1.40000000000000012e-82Initial program 98.8%
Taylor expanded in z around inf 77.3%
+-commutative77.3%
associate-/r*77.8%
Simplified77.8%
if 1.40000000000000012e-82 < t Initial program 98.8%
Taylor expanded in t around inf 93.3%
+-commutative93.3%
associate-/r*94.4%
Simplified94.4%
Final simplification83.3%
(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 98.8%
Taylor expanded in x around 0 73.9%
Final simplification73.9%
herbie shell --seed 2024055
(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)))))