
(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) (- 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}
Initial program 99.9%
Final simplification99.9%
(FPCore (x y z t) :precision binary64 (if (or (<= y -1.4e-30) (not (<= y 4.2e-94))) (- 1.0 (/ x (* y (- y z)))) (- 1.0 (/ x (* z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -1.4e-30) || !(y <= 4.2e-94)) {
tmp = 1.0 - (x / (y * (y - z)));
} 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 <= (-1.4d-30)) .or. (.not. (y <= 4.2d-94))) then
tmp = 1.0d0 - (x / (y * (y - z)))
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 <= -1.4e-30) || !(y <= 4.2e-94)) {
tmp = 1.0 - (x / (y * (y - z)));
} else {
tmp = 1.0 - (x / (z * t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -1.4e-30) or not (y <= 4.2e-94): tmp = 1.0 - (x / (y * (y - z))) else: tmp = 1.0 - (x / (z * t)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -1.4e-30) || !(y <= 4.2e-94)) tmp = Float64(1.0 - Float64(x / Float64(y * Float64(y - z)))); 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 <= -1.4e-30) || ~((y <= 4.2e-94))) tmp = 1.0 - (x / (y * (y - z))); else tmp = 1.0 - (x / (z * t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -1.4e-30], N[Not[LessEqual[y, 4.2e-94]], $MachinePrecision]], N[(1.0 - N[(x / N[(y * N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(x / N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.4 \cdot 10^{-30} \lor \neg \left(y \leq 4.2 \cdot 10^{-94}\right):\\
\;\;\;\;1 - \frac{x}{y \cdot \left(y - z\right)}\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{x}{z \cdot t}\\
\end{array}
\end{array}
if y < -1.39999999999999994e-30 or 4.2000000000000002e-94 < y Initial program 99.9%
Taylor expanded in t around 0 92.9%
if -1.39999999999999994e-30 < y < 4.2000000000000002e-94Initial program 99.9%
Taylor expanded in y around 0 87.7%
Final simplification91.0%
(FPCore (x y z t) :precision binary64 (if (or (<= z -2.5e-76) (not (<= z 1.7e-62))) (+ 1.0 (/ x (* z (- y t)))) (- 1.0 (/ x (* y (- y t))))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -2.5e-76) || !(z <= 1.7e-62)) {
tmp = 1.0 + (x / (z * (y - t)));
} else {
tmp = 1.0 - (x / (y * (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 <= (-2.5d-76)) .or. (.not. (z <= 1.7d-62))) then
tmp = 1.0d0 + (x / (z * (y - t)))
else
tmp = 1.0d0 - (x / (y * (y - t)))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -2.5e-76) || !(z <= 1.7e-62)) {
tmp = 1.0 + (x / (z * (y - t)));
} else {
tmp = 1.0 - (x / (y * (y - t)));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -2.5e-76) or not (z <= 1.7e-62): tmp = 1.0 + (x / (z * (y - t))) else: tmp = 1.0 - (x / (y * (y - t))) return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -2.5e-76) || !(z <= 1.7e-62)) tmp = Float64(1.0 + Float64(x / Float64(z * Float64(y - t)))); else tmp = Float64(1.0 - Float64(x / Float64(y * Float64(y - t)))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -2.5e-76) || ~((z <= 1.7e-62))) tmp = 1.0 + (x / (z * (y - t))); else tmp = 1.0 - (x / (y * (y - t))); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -2.5e-76], N[Not[LessEqual[z, 1.7e-62]], $MachinePrecision]], N[(1.0 + N[(x / N[(z * N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(x / N[(y * N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.5 \cdot 10^{-76} \lor \neg \left(z \leq 1.7 \cdot 10^{-62}\right):\\
\;\;\;\;1 + \frac{x}{z \cdot \left(y - t\right)}\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{x}{y \cdot \left(y - t\right)}\\
\end{array}
\end{array}
if z < -2.4999999999999999e-76 or 1.69999999999999994e-62 < z Initial program 99.9%
Taylor expanded in z around inf 97.6%
associate-*r/97.6%
neg-mul-197.6%
Simplified97.6%
if -2.4999999999999999e-76 < z < 1.69999999999999994e-62Initial program 99.9%
Taylor expanded in z around 0 89.9%
Final simplification95.0%
(FPCore (x y z t) :precision binary64 (if (<= y -4.2e-110) (- 1.0 (/ x (* y (- y t)))) (if (<= y 3.8e-94) (- 1.0 (/ x (* z t))) (- 1.0 (/ x (* y (- y z)))))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -4.2e-110) {
tmp = 1.0 - (x / (y * (y - t)));
} else if (y <= 3.8e-94) {
tmp = 1.0 - (x / (z * t));
} else {
tmp = 1.0 - (x / (y * (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 <= (-4.2d-110)) then
tmp = 1.0d0 - (x / (y * (y - t)))
else if (y <= 3.8d-94) then
tmp = 1.0d0 - (x / (z * t))
else
tmp = 1.0d0 - (x / (y * (y - z)))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -4.2e-110) {
tmp = 1.0 - (x / (y * (y - t)));
} else if (y <= 3.8e-94) {
tmp = 1.0 - (x / (z * t));
} else {
tmp = 1.0 - (x / (y * (y - z)));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -4.2e-110: tmp = 1.0 - (x / (y * (y - t))) elif y <= 3.8e-94: tmp = 1.0 - (x / (z * t)) else: tmp = 1.0 - (x / (y * (y - z))) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -4.2e-110) tmp = Float64(1.0 - Float64(x / Float64(y * Float64(y - t)))); elseif (y <= 3.8e-94) tmp = Float64(1.0 - Float64(x / Float64(z * t))); else tmp = Float64(1.0 - Float64(x / Float64(y * Float64(y - z)))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= -4.2e-110) tmp = 1.0 - (x / (y * (y - t))); elseif (y <= 3.8e-94) tmp = 1.0 - (x / (z * t)); else tmp = 1.0 - (x / (y * (y - z))); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -4.2e-110], N[(1.0 - N[(x / N[(y * N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.8e-94], N[(1.0 - N[(x / N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(x / N[(y * N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.2 \cdot 10^{-110}:\\
\;\;\;\;1 - \frac{x}{y \cdot \left(y - t\right)}\\
\mathbf{elif}\;y \leq 3.8 \cdot 10^{-94}:\\
\;\;\;\;1 - \frac{x}{z \cdot t}\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{x}{y \cdot \left(y - z\right)}\\
\end{array}
\end{array}
if y < -4.20000000000000004e-110Initial program 99.9%
Taylor expanded in z around 0 89.3%
if -4.20000000000000004e-110 < y < 3.79999999999999999e-94Initial program 99.9%
Taylor expanded in y around 0 88.3%
if 3.79999999999999999e-94 < y Initial program 99.9%
Taylor expanded in t around 0 88.6%
Final simplification88.8%
(FPCore (x y z t) :precision binary64 (if (or (<= y -1.15e-10) (not (<= y 4.4e-38))) (- 1.0 (/ x (* y t))) (- 1.0 (/ x (* z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -1.15e-10) || !(y <= 4.4e-38)) {
tmp = 1.0 - (x / (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 ((y <= (-1.15d-10)) .or. (.not. (y <= 4.4d-38))) then
tmp = 1.0d0 - (x / (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 ((y <= -1.15e-10) || !(y <= 4.4e-38)) {
tmp = 1.0 - (x / (y * t));
} else {
tmp = 1.0 - (x / (z * t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -1.15e-10) or not (y <= 4.4e-38): tmp = 1.0 - (x / (y * t)) else: tmp = 1.0 - (x / (z * t)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -1.15e-10) || !(y <= 4.4e-38)) tmp = Float64(1.0 - Float64(x / 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 ((y <= -1.15e-10) || ~((y <= 4.4e-38))) tmp = 1.0 - (x / (y * t)); else tmp = 1.0 - (x / (z * t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -1.15e-10], N[Not[LessEqual[y, 4.4e-38]], $MachinePrecision]], N[(1.0 - N[(x / N[(y * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(x / N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.15 \cdot 10^{-10} \lor \neg \left(y \leq 4.4 \cdot 10^{-38}\right):\\
\;\;\;\;1 - \frac{x}{y \cdot t}\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{x}{z \cdot t}\\
\end{array}
\end{array}
if y < -1.15000000000000004e-10 or 4.40000000000000015e-38 < y Initial program 100.0%
Taylor expanded in z around 0 95.4%
Taylor expanded in y around 0 76.9%
associate-*r/76.9%
neg-mul-176.9%
*-commutative76.9%
Simplified76.9%
expm1-log1p-u74.6%
expm1-udef74.6%
add-sqr-sqrt31.6%
sqrt-unprod62.7%
sqr-neg62.7%
sqrt-unprod42.8%
add-sqr-sqrt74.2%
*-commutative74.2%
associate-/r*74.2%
Applied egg-rr74.2%
expm1-def74.2%
expm1-log1p74.7%
associate-/r*74.7%
Simplified74.7%
if -1.15000000000000004e-10 < y < 4.40000000000000015e-38Initial program 99.9%
Taylor expanded in y around 0 82.6%
Final simplification78.1%
(FPCore (x y z t) :precision binary64 (if (or (<= y -6e-28) (not (<= y 2.2e-51))) (- 1.0 (/ x (* y y))) (- 1.0 (/ x (* z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -6e-28) || !(y <= 2.2e-51)) {
tmp = 1.0 - (x / (y * 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 <= (-6d-28)) .or. (.not. (y <= 2.2d-51))) then
tmp = 1.0d0 - (x / (y * 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 <= -6e-28) || !(y <= 2.2e-51)) {
tmp = 1.0 - (x / (y * y));
} else {
tmp = 1.0 - (x / (z * t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -6e-28) or not (y <= 2.2e-51): tmp = 1.0 - (x / (y * y)) else: tmp = 1.0 - (x / (z * t)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -6e-28) || !(y <= 2.2e-51)) tmp = Float64(1.0 - Float64(x / Float64(y * 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 <= -6e-28) || ~((y <= 2.2e-51))) tmp = 1.0 - (x / (y * y)); else tmp = 1.0 - (x / (z * t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -6e-28], N[Not[LessEqual[y, 2.2e-51]], $MachinePrecision]], N[(1.0 - N[(x / N[(y * 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 -6 \cdot 10^{-28} \lor \neg \left(y \leq 2.2 \cdot 10^{-51}\right):\\
\;\;\;\;1 - \frac{x}{y \cdot y}\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{x}{z \cdot t}\\
\end{array}
\end{array}
if y < -6.00000000000000005e-28 or 2.2e-51 < y Initial program 99.9%
Taylor expanded in y around inf 87.6%
unpow287.6%
Simplified87.6%
if -6.00000000000000005e-28 < y < 2.2e-51Initial program 99.9%
Taylor expanded in y around 0 85.8%
Final simplification86.9%
(FPCore (x y z t) :precision binary64 (- 1.0 (/ x (* z t))))
double code(double x, double y, double z, double t) {
return 1.0 - (x / (z * 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 / (z * t))
end function
public static double code(double x, double y, double z, double t) {
return 1.0 - (x / (z * t));
}
def code(x, y, z, t): return 1.0 - (x / (z * t))
function code(x, y, z, t) return Float64(1.0 - Float64(x / Float64(z * t))) end
function tmp = code(x, y, z, t) tmp = 1.0 - (x / (z * t)); end
code[x_, y_, z_, t_] := N[(1.0 - N[(x / N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 - \frac{x}{z \cdot t}
\end{array}
Initial program 99.9%
Taylor expanded in y around 0 65.1%
Final simplification65.1%
herbie shell --seed 2023224
(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)))))