
(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.6%
Final simplification99.6%
(FPCore (x y z t) :precision binary64 (if (<= y -4.3e-17) 1.0 (if (<= y 7.6e-143) (+ 1.0 (/ (/ x z) (- y t))) 1.0)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -4.3e-17) {
tmp = 1.0;
} else if (y <= 7.6e-143) {
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 <= (-4.3d-17)) then
tmp = 1.0d0
else if (y <= 7.6d-143) 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 <= -4.3e-17) {
tmp = 1.0;
} else if (y <= 7.6e-143) {
tmp = 1.0 + ((x / z) / (y - t));
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -4.3e-17: tmp = 1.0 elif y <= 7.6e-143: tmp = 1.0 + ((x / z) / (y - t)) else: tmp = 1.0 return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -4.3e-17) tmp = 1.0; elseif (y <= 7.6e-143) tmp = Float64(1.0 + Float64(Float64(x / 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 <= -4.3e-17) tmp = 1.0; elseif (y <= 7.6e-143) tmp = 1.0 + ((x / z) / (y - t)); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -4.3e-17], 1.0, If[LessEqual[y, 7.6e-143], N[(1.0 + N[(N[(x / z), $MachinePrecision] / N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.3 \cdot 10^{-17}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 7.6 \cdot 10^{-143}:\\
\;\;\;\;1 + \frac{\frac{x}{z}}{y - t}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -4.30000000000000023e-17 or 7.59999999999999962e-143 < y Initial program 99.9%
sub-neg99.9%
distribute-frac-neg99.9%
*-lft-identity99.9%
associate-/r*100.0%
associate-*r/100.0%
metadata-eval100.0%
times-frac100.0%
neg-mul-1100.0%
remove-double-neg100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in z around 0 93.4%
mul-1-neg93.4%
*-commutative93.4%
associate-/r*93.4%
distribute-neg-frac93.4%
distribute-frac-neg93.4%
Simplified93.4%
Taylor expanded in y around 0 69.3%
Taylor expanded in x around 0 91.4%
if -4.30000000000000023e-17 < y < 7.59999999999999962e-143Initial program 98.9%
sub-neg98.9%
distribute-frac-neg98.9%
*-lft-identity98.9%
associate-/r*95.8%
associate-*r/95.8%
metadata-eval95.8%
times-frac95.8%
neg-mul-195.8%
remove-double-neg95.8%
neg-mul-195.8%
sub-neg95.8%
+-commutative95.8%
distribute-neg-out95.8%
remove-double-neg95.8%
sub-neg95.8%
Simplified95.8%
Taylor expanded in z around inf 88.7%
Final simplification90.4%
(FPCore (x y z t) :precision binary64 (if (<= z -1.5e-74) (+ 1.0 (/ (/ x z) (- y t))) (if (<= z 3.1e-180) (- 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 <= -1.5e-74) {
tmp = 1.0 + ((x / z) / (y - t));
} else if (z <= 3.1e-180) {
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 <= (-1.5d-74)) then
tmp = 1.0d0 + ((x / z) / (y - t))
else if (z <= 3.1d-180) 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 <= -1.5e-74) {
tmp = 1.0 + ((x / z) / (y - t));
} else if (z <= 3.1e-180) {
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 <= -1.5e-74: tmp = 1.0 + ((x / z) / (y - t)) elif z <= 3.1e-180: 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 <= -1.5e-74) tmp = Float64(1.0 + Float64(Float64(x / z) / Float64(y - t))); elseif (z <= 3.1e-180) 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 <= -1.5e-74) tmp = 1.0 + ((x / z) / (y - t)); elseif (z <= 3.1e-180) 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, -1.5e-74], N[(1.0 + N[(N[(x / z), $MachinePrecision] / N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 3.1e-180], 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 -1.5 \cdot 10^{-74}:\\
\;\;\;\;1 + \frac{\frac{x}{z}}{y - t}\\
\mathbf{elif}\;z \leq 3.1 \cdot 10^{-180}:\\
\;\;\;\;1 - \frac{x}{y \cdot \left(y - t\right)}\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{x}{z \cdot t}\\
\end{array}
\end{array}
if z < -1.50000000000000003e-74Initial program 99.9%
sub-neg99.9%
distribute-frac-neg99.9%
*-lft-identity99.9%
associate-/r*98.9%
associate-*r/98.9%
metadata-eval98.9%
times-frac98.9%
neg-mul-198.9%
remove-double-neg98.9%
neg-mul-198.9%
sub-neg98.9%
+-commutative98.9%
distribute-neg-out98.9%
remove-double-neg98.9%
sub-neg98.9%
Simplified98.9%
Taylor expanded in z around inf 91.2%
if -1.50000000000000003e-74 < z < 3.0999999999999999e-180Initial program 98.4%
Taylor expanded in z around 0 90.0%
if 3.0999999999999999e-180 < z Initial program 100.0%
Taylor expanded in y around 0 77.7%
Final simplification85.4%
(FPCore (x y z t) :precision binary64 (if (<= y -1e-80) 1.0 (if (<= y 1.32e-114) (- 1.0 (/ x (* z t))) 1.0)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1e-80) {
tmp = 1.0;
} else if (y <= 1.32e-114) {
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 <= (-1d-80)) then
tmp = 1.0d0
else if (y <= 1.32d-114) 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 <= -1e-80) {
tmp = 1.0;
} else if (y <= 1.32e-114) {
tmp = 1.0 - (x / (z * t));
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -1e-80: tmp = 1.0 elif y <= 1.32e-114: tmp = 1.0 - (x / (z * t)) else: tmp = 1.0 return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -1e-80) tmp = 1.0; elseif (y <= 1.32e-114) 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 <= -1e-80) tmp = 1.0; elseif (y <= 1.32e-114) tmp = 1.0 - (x / (z * t)); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -1e-80], 1.0, If[LessEqual[y, 1.32e-114], N[(1.0 - N[(x / N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \cdot 10^{-80}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 1.32 \cdot 10^{-114}:\\
\;\;\;\;1 - \frac{x}{z \cdot t}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -9.99999999999999961e-81 or 1.31999999999999996e-114 < y Initial program 99.9%
sub-neg99.9%
distribute-frac-neg99.9%
*-lft-identity99.9%
associate-/r*99.4%
associate-*r/99.4%
metadata-eval99.4%
times-frac99.4%
neg-mul-199.4%
remove-double-neg99.4%
neg-mul-199.4%
sub-neg99.4%
+-commutative99.4%
distribute-neg-out99.4%
remove-double-neg99.4%
sub-neg99.4%
Simplified99.4%
Taylor expanded in z around 0 93.6%
mul-1-neg93.6%
*-commutative93.6%
associate-/r*93.1%
distribute-neg-frac93.1%
distribute-frac-neg93.1%
Simplified93.1%
Taylor expanded in y around 0 69.3%
Taylor expanded in x around 0 89.9%
if -9.99999999999999961e-81 < y < 1.31999999999999996e-114Initial program 98.9%
Taylor expanded in y around 0 83.0%
Final simplification87.5%
(FPCore (x y z t) :precision binary64 (if (<= y -1.35e-96) 1.0 (if (<= y 1.45e-114) (- 1.0 (/ (/ x t) z)) 1.0)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.35e-96) {
tmp = 1.0;
} else if (y <= 1.45e-114) {
tmp = 1.0 - ((x / t) / 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.35d-96)) then
tmp = 1.0d0
else if (y <= 1.45d-114) then
tmp = 1.0d0 - ((x / t) / 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.35e-96) {
tmp = 1.0;
} else if (y <= 1.45e-114) {
tmp = 1.0 - ((x / t) / z);
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -1.35e-96: tmp = 1.0 elif y <= 1.45e-114: tmp = 1.0 - ((x / t) / z) else: tmp = 1.0 return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -1.35e-96) tmp = 1.0; elseif (y <= 1.45e-114) tmp = Float64(1.0 - Float64(Float64(x / t) / z)); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= -1.35e-96) tmp = 1.0; elseif (y <= 1.45e-114) tmp = 1.0 - ((x / t) / z); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -1.35e-96], 1.0, If[LessEqual[y, 1.45e-114], N[(1.0 - N[(N[(x / t), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.35 \cdot 10^{-96}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 1.45 \cdot 10^{-114}:\\
\;\;\;\;1 - \frac{\frac{x}{t}}{z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1.35e-96 or 1.44999999999999998e-114 < y Initial program 99.9%
sub-neg99.9%
distribute-frac-neg99.9%
*-lft-identity99.9%
associate-/r*99.4%
associate-*r/99.4%
metadata-eval99.4%
times-frac99.4%
neg-mul-199.4%
remove-double-neg99.4%
neg-mul-199.4%
sub-neg99.4%
+-commutative99.4%
distribute-neg-out99.4%
remove-double-neg99.4%
sub-neg99.4%
Simplified99.4%
Taylor expanded in z around 0 93.6%
mul-1-neg93.6%
*-commutative93.6%
associate-/r*93.1%
distribute-neg-frac93.1%
distribute-frac-neg93.1%
Simplified93.1%
Taylor expanded in y around 0 69.3%
Taylor expanded in x around 0 89.9%
if -1.35e-96 < y < 1.44999999999999998e-114Initial program 98.9%
clear-num98.8%
associate-/r/98.8%
*-commutative98.8%
associate-/r*98.7%
Applied egg-rr98.7%
Taylor expanded in y around 0 83.0%
associate-*l/83.0%
*-un-lft-identity83.0%
associate-/r*83.7%
Applied egg-rr83.7%
Final simplification87.8%
(FPCore (x y z t) :precision binary64 (+ 1.0 (/ (/ x (- z y)) (- y t))))
double code(double x, double y, double z, double t) {
return 1.0 + ((x / (z - y)) / (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 / (z - y)) / (y - t))
end function
public static double code(double x, double y, double z, double t) {
return 1.0 + ((x / (z - y)) / (y - t));
}
def code(x, y, z, t): return 1.0 + ((x / (z - y)) / (y - t))
function code(x, y, z, t) return Float64(1.0 + Float64(Float64(x / Float64(z - y)) / Float64(y - t))) end
function tmp = code(x, y, z, t) tmp = 1.0 + ((x / (z - y)) / (y - t)); end
code[x_, y_, z_, t_] := N[(1.0 + N[(N[(x / N[(z - y), $MachinePrecision]), $MachinePrecision] / N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \frac{\frac{x}{z - y}}{y - t}
\end{array}
Initial program 99.6%
sub-neg99.6%
distribute-frac-neg99.6%
*-lft-identity99.6%
associate-/r*98.5%
associate-*r/98.5%
metadata-eval98.5%
times-frac98.5%
neg-mul-198.5%
remove-double-neg98.5%
neg-mul-198.5%
sub-neg98.5%
+-commutative98.5%
distribute-neg-out98.5%
remove-double-neg98.5%
sub-neg98.5%
Simplified98.5%
Final simplification98.5%
(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.6%
sub-neg99.6%
distribute-frac-neg99.6%
*-lft-identity99.6%
associate-/r*98.5%
associate-*r/98.5%
metadata-eval98.5%
times-frac98.5%
neg-mul-198.5%
remove-double-neg98.5%
neg-mul-198.5%
sub-neg98.5%
+-commutative98.5%
distribute-neg-out98.5%
remove-double-neg98.5%
sub-neg98.5%
Simplified98.5%
Taylor expanded in z around 0 74.0%
mul-1-neg74.0%
*-commutative74.0%
associate-/r*73.0%
distribute-neg-frac73.0%
distribute-frac-neg73.0%
Simplified73.0%
Taylor expanded in y around 0 57.0%
Taylor expanded in x around 0 75.9%
Final simplification75.9%
herbie shell --seed 2023268
(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)))))