
(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.2%
Final simplification99.2%
(FPCore (x y z t) :precision binary64 (if (or (<= y -2.3e-154) (not (<= y 1.52e-137))) (+ 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.3e-154) || !(y <= 1.52e-137)) {
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.3d-154)) .or. (.not. (y <= 1.52d-137))) 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.3e-154) || !(y <= 1.52e-137)) {
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.3e-154) or not (y <= 1.52e-137): 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.3e-154) || !(y <= 1.52e-137)) tmp = Float64(1.0 + Float64(x / Float64(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.3e-154) || ~((y <= 1.52e-137))) 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.3e-154], N[Not[LessEqual[y, 1.52e-137]], $MachinePrecision]], N[(1.0 + N[(x / N[(y * N[(t - y), $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 -2.3 \cdot 10^{-154} \lor \neg \left(y \leq 1.52 \cdot 10^{-137}\right):\\
\;\;\;\;1 + \frac{x}{y \cdot \left(t - y\right)}\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{x}{z \cdot t}\\
\end{array}
\end{array}
if y < -2.3e-154 or 1.5200000000000001e-137 < y Initial program 99.9%
Taylor expanded in z around 0 86.7%
if -2.3e-154 < y < 1.5200000000000001e-137Initial program 97.4%
Taylor expanded in y around 0 89.4%
Final simplification87.5%
(FPCore (x y z t)
:precision binary64
(if (<= z -3.1e-76)
(+ 1.0 (/ x (* z (- y t))))
(if (<= z 5.5e-199)
(+ 1.0 (/ x (* y (- t y))))
(+ 1.0 (/ x (* (- y z) t))))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -3.1e-76) {
tmp = 1.0 + (x / (z * (y - t)));
} else if (z <= 5.5e-199) {
tmp = 1.0 + (x / (y * (t - y)));
} else {
tmp = 1.0 + (x / ((y - 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 <= (-3.1d-76)) then
tmp = 1.0d0 + (x / (z * (y - t)))
else if (z <= 5.5d-199) then
tmp = 1.0d0 + (x / (y * (t - y)))
else
tmp = 1.0d0 + (x / ((y - z) * t))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -3.1e-76) {
tmp = 1.0 + (x / (z * (y - t)));
} else if (z <= 5.5e-199) {
tmp = 1.0 + (x / (y * (t - y)));
} else {
tmp = 1.0 + (x / ((y - z) * t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -3.1e-76: tmp = 1.0 + (x / (z * (y - t))) elif z <= 5.5e-199: tmp = 1.0 + (x / (y * (t - y))) else: tmp = 1.0 + (x / ((y - z) * t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -3.1e-76) tmp = Float64(1.0 + Float64(x / Float64(z * Float64(y - t)))); elseif (z <= 5.5e-199) tmp = Float64(1.0 + Float64(x / Float64(y * Float64(t - y)))); else tmp = Float64(1.0 + Float64(x / Float64(Float64(y - z) * t))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -3.1e-76) tmp = 1.0 + (x / (z * (y - t))); elseif (z <= 5.5e-199) tmp = 1.0 + (x / (y * (t - y))); else tmp = 1.0 + (x / ((y - z) * t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -3.1e-76], N[(1.0 + N[(x / N[(z * N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 5.5e-199], N[(1.0 + N[(x / N[(y * N[(t - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(x / N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.1 \cdot 10^{-76}:\\
\;\;\;\;1 + \frac{x}{z \cdot \left(y - t\right)}\\
\mathbf{elif}\;z \leq 5.5 \cdot 10^{-199}:\\
\;\;\;\;1 + \frac{x}{y \cdot \left(t - y\right)}\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{x}{\left(y - z\right) \cdot t}\\
\end{array}
\end{array}
if z < -3.0999999999999997e-76Initial program 99.9%
Taylor expanded in z around inf 94.5%
associate-*r/94.5%
neg-mul-194.5%
*-commutative94.5%
Simplified94.5%
if -3.0999999999999997e-76 < z < 5.5000000000000001e-199Initial program 97.4%
Taylor expanded in z around 0 94.9%
if 5.5000000000000001e-199 < z Initial program 100.0%
Taylor expanded in t around inf 76.4%
associate-*r/76.4%
neg-mul-176.4%
Simplified76.4%
Final simplification86.8%
(FPCore (x y z t)
:precision binary64
(if (<= t -130000.0)
(- 1.0 (/ x (* z t)))
(if (<= t 8.5e-22)
(+ 1.0 (/ x (* y (- z y))))
(+ 1.0 (/ x (* (- y z) t))))))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -130000.0) {
tmp = 1.0 - (x / (z * t));
} else if (t <= 8.5e-22) {
tmp = 1.0 + (x / (y * (z - y)));
} else {
tmp = 1.0 + (x / ((y - 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 (t <= (-130000.0d0)) then
tmp = 1.0d0 - (x / (z * t))
else if (t <= 8.5d-22) then
tmp = 1.0d0 + (x / (y * (z - y)))
else
tmp = 1.0d0 + (x / ((y - z) * t))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (t <= -130000.0) {
tmp = 1.0 - (x / (z * t));
} else if (t <= 8.5e-22) {
tmp = 1.0 + (x / (y * (z - y)));
} else {
tmp = 1.0 + (x / ((y - z) * t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= -130000.0: tmp = 1.0 - (x / (z * t)) elif t <= 8.5e-22: tmp = 1.0 + (x / (y * (z - y))) else: tmp = 1.0 + (x / ((y - z) * t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= -130000.0) tmp = Float64(1.0 - Float64(x / Float64(z * t))); elseif (t <= 8.5e-22) tmp = Float64(1.0 + Float64(x / Float64(y * Float64(z - y)))); else tmp = Float64(1.0 + Float64(x / Float64(Float64(y - z) * t))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= -130000.0) tmp = 1.0 - (x / (z * t)); elseif (t <= 8.5e-22) tmp = 1.0 + (x / (y * (z - y))); else tmp = 1.0 + (x / ((y - z) * t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, -130000.0], N[(1.0 - N[(x / N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 8.5e-22], N[(1.0 + N[(x / N[(y * N[(z - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(x / N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -130000:\\
\;\;\;\;1 - \frac{x}{z \cdot t}\\
\mathbf{elif}\;t \leq 8.5 \cdot 10^{-22}:\\
\;\;\;\;1 + \frac{x}{y \cdot \left(z - y\right)}\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{x}{\left(y - z\right) \cdot t}\\
\end{array}
\end{array}
if t < -1.3e5Initial program 100.0%
Taylor expanded in y around 0 75.6%
if -1.3e5 < t < 8.5000000000000001e-22Initial program 98.3%
Taylor expanded in t around 0 87.0%
if 8.5000000000000001e-22 < t Initial program 100.0%
Taylor expanded in t around inf 94.5%
associate-*r/94.5%
neg-mul-194.5%
Simplified94.5%
Final simplification86.0%
(FPCore (x y z t) :precision binary64 (if (<= y -6.6e-114) 1.0 (if (<= y 3.9e-128) (- 1.0 (/ x (* z t))) 1.0)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -6.6e-114) {
tmp = 1.0;
} else if (y <= 3.9e-128) {
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.6d-114)) then
tmp = 1.0d0
else if (y <= 3.9d-128) 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.6e-114) {
tmp = 1.0;
} else if (y <= 3.9e-128) {
tmp = 1.0 - (x / (z * t));
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -6.6e-114: tmp = 1.0 elif y <= 3.9e-128: tmp = 1.0 - (x / (z * t)) else: tmp = 1.0 return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -6.6e-114) tmp = 1.0; elseif (y <= 3.9e-128) 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.6e-114) tmp = 1.0; elseif (y <= 3.9e-128) tmp = 1.0 - (x / (z * t)); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -6.6e-114], 1.0, If[LessEqual[y, 3.9e-128], N[(1.0 - N[(x / N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.6 \cdot 10^{-114}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 3.9 \cdot 10^{-128}:\\
\;\;\;\;1 - \frac{x}{z \cdot t}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -6.60000000000000069e-114 or 3.89999999999999997e-128 < y Initial program 99.9%
Taylor expanded in t around inf 70.8%
associate-*r/70.8%
neg-mul-170.8%
Simplified70.8%
Taylor expanded in x around 0 82.0%
if -6.60000000000000069e-114 < y < 3.89999999999999997e-128Initial program 97.6%
Taylor expanded in y around 0 85.4%
Final simplification83.1%
(FPCore (x y z t) :precision binary64 (if (<= z -1.35e-98) 1.0 (if (<= z 4.5e-139) (+ 1.0 (/ x (* y t))) 1.0)))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.35e-98) {
tmp = 1.0;
} else if (z <= 4.5e-139) {
tmp = 1.0 + (x / (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 (z <= (-1.35d-98)) then
tmp = 1.0d0
else if (z <= 4.5d-139) then
tmp = 1.0d0 + (x / (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 (z <= -1.35e-98) {
tmp = 1.0;
} else if (z <= 4.5e-139) {
tmp = 1.0 + (x / (y * t));
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -1.35e-98: tmp = 1.0 elif z <= 4.5e-139: tmp = 1.0 + (x / (y * t)) else: tmp = 1.0 return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -1.35e-98) tmp = 1.0; elseif (z <= 4.5e-139) tmp = Float64(1.0 + Float64(x / Float64(y * t))); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -1.35e-98) tmp = 1.0; elseif (z <= 4.5e-139) tmp = 1.0 + (x / (y * t)); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -1.35e-98], 1.0, If[LessEqual[z, 4.5e-139], N[(1.0 + N[(x / N[(y * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.35 \cdot 10^{-98}:\\
\;\;\;\;1\\
\mathbf{elif}\;z \leq 4.5 \cdot 10^{-139}:\\
\;\;\;\;1 + \frac{x}{y \cdot t}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if z < -1.3499999999999999e-98 or 4.50000000000000023e-139 < z Initial program 99.9%
Taylor expanded in t around inf 76.4%
associate-*r/76.4%
neg-mul-176.4%
Simplified76.4%
Taylor expanded in x around 0 75.0%
if -1.3499999999999999e-98 < z < 4.50000000000000023e-139Initial program 97.6%
Taylor expanded in t around inf 77.7%
associate-*r/77.7%
neg-mul-177.7%
Simplified77.7%
Taylor expanded in y around inf 76.4%
+-commutative76.4%
Simplified76.4%
Final simplification75.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.2%
Taylor expanded in t around inf 76.8%
associate-*r/76.8%
neg-mul-176.8%
Simplified76.8%
Taylor expanded in x around 0 71.8%
herbie shell --seed 2024086
(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)))))