
(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 (<= y -1.05e-53)
1.0
(if (<= y 3.3e-104)
(- 1.0 (/ x (* z t)))
(if (<= y 4.2e-88) (/ x (* y (- t y))) 1.0))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.05e-53) {
tmp = 1.0;
} else if (y <= 3.3e-104) {
tmp = 1.0 - (x / (z * t));
} else if (y <= 4.2e-88) {
tmp = x / (y * (t - y));
} 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.05d-53)) then
tmp = 1.0d0
else if (y <= 3.3d-104) then
tmp = 1.0d0 - (x / (z * t))
else if (y <= 4.2d-88) then
tmp = x / (y * (t - y))
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.05e-53) {
tmp = 1.0;
} else if (y <= 3.3e-104) {
tmp = 1.0 - (x / (z * t));
} else if (y <= 4.2e-88) {
tmp = x / (y * (t - y));
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -1.05e-53: tmp = 1.0 elif y <= 3.3e-104: tmp = 1.0 - (x / (z * t)) elif y <= 4.2e-88: tmp = x / (y * (t - y)) else: tmp = 1.0 return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -1.05e-53) tmp = 1.0; elseif (y <= 3.3e-104) tmp = Float64(1.0 - Float64(x / Float64(z * t))); elseif (y <= 4.2e-88) tmp = Float64(x / Float64(y * Float64(t - y))); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= -1.05e-53) tmp = 1.0; elseif (y <= 3.3e-104) tmp = 1.0 - (x / (z * t)); elseif (y <= 4.2e-88) tmp = x / (y * (t - y)); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -1.05e-53], 1.0, If[LessEqual[y, 3.3e-104], N[(1.0 - N[(x / N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4.2e-88], N[(x / N[(y * N[(t - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.05 \cdot 10^{-53}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 3.3 \cdot 10^{-104}:\\
\;\;\;\;1 - \frac{x}{z \cdot t}\\
\mathbf{elif}\;y \leq 4.2 \cdot 10^{-88}:\\
\;\;\;\;\frac{x}{y \cdot \left(t - y\right)}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1.04999999999999989e-53 or 4.1999999999999999e-88 < y Initial program 99.9%
sub-negN/A
+-lowering-+.f64N/A
associate-/r*N/A
distribute-neg-frac2N/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
--lowering--.f64N/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
remove-double-negN/A
--lowering--.f64100.0%
Simplified100.0%
Taylor expanded in x around 0
Simplified89.6%
if -1.04999999999999989e-53 < y < 3.30000000000000002e-104Initial program 98.0%
Taylor expanded in y around 0
*-lowering-*.f6477.4%
Simplified77.4%
if 3.30000000000000002e-104 < y < 4.1999999999999999e-88Initial program 99.7%
sub-negN/A
+-lowering-+.f64N/A
associate-/r*N/A
distribute-neg-frac2N/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
--lowering--.f64N/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
remove-double-negN/A
--lowering--.f6499.7%
Simplified99.7%
Taylor expanded in x around inf
/-lowering-/.f64N/A
*-lowering-*.f64N/A
--lowering--.f64N/A
--lowering--.f6499.7%
Simplified99.7%
Taylor expanded in y around inf
Simplified99.7%
Final simplification85.0%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (+ 1.0 (/ (/ x y) (- t y)))))
(if (<= y -1.2e-53)
t_1
(if (<= y 5.7e-108) (+ 1.0 (/ (/ x (- y z)) t)) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = 1.0 + ((x / y) / (t - y));
double tmp;
if (y <= -1.2e-53) {
tmp = t_1;
} else if (y <= 5.7e-108) {
tmp = 1.0 + ((x / (y - z)) / t);
} else {
tmp = t_1;
}
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) :: t_1
real(8) :: tmp
t_1 = 1.0d0 + ((x / y) / (t - y))
if (y <= (-1.2d-53)) then
tmp = t_1
else if (y <= 5.7d-108) then
tmp = 1.0d0 + ((x / (y - z)) / t)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = 1.0 + ((x / y) / (t - y));
double tmp;
if (y <= -1.2e-53) {
tmp = t_1;
} else if (y <= 5.7e-108) {
tmp = 1.0 + ((x / (y - z)) / t);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = 1.0 + ((x / y) / (t - y)) tmp = 0 if y <= -1.2e-53: tmp = t_1 elif y <= 5.7e-108: tmp = 1.0 + ((x / (y - z)) / t) else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(1.0 + Float64(Float64(x / y) / Float64(t - y))) tmp = 0.0 if (y <= -1.2e-53) tmp = t_1; elseif (y <= 5.7e-108) tmp = Float64(1.0 + Float64(Float64(x / Float64(y - z)) / t)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = 1.0 + ((x / y) / (t - y)); tmp = 0.0; if (y <= -1.2e-53) tmp = t_1; elseif (y <= 5.7e-108) tmp = 1.0 + ((x / (y - z)) / t); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(1.0 + N[(N[(x / y), $MachinePrecision] / N[(t - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.2e-53], t$95$1, If[LessEqual[y, 5.7e-108], N[(1.0 + N[(N[(x / N[(y - z), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := 1 + \frac{\frac{x}{y}}{t - y}\\
\mathbf{if}\;y \leq -1.2 \cdot 10^{-53}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 5.7 \cdot 10^{-108}:\\
\;\;\;\;1 + \frac{\frac{x}{y - z}}{t}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -1.20000000000000004e-53 or 5.7e-108 < y Initial program 99.9%
sub-negN/A
+-lowering-+.f64N/A
associate-/r*N/A
distribute-neg-frac2N/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
--lowering--.f64N/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
remove-double-negN/A
--lowering--.f64100.0%
Simplified100.0%
Taylor expanded in y around inf
/-lowering-/.f6492.5%
Simplified92.5%
if -1.20000000000000004e-53 < y < 5.7e-108Initial program 98.0%
sub-negN/A
+-lowering-+.f64N/A
associate-/r*N/A
distribute-neg-frac2N/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
--lowering--.f64N/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
remove-double-negN/A
--lowering--.f6495.1%
Simplified95.1%
Taylor expanded in t around inf
Simplified86.2%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (+ 1.0 (/ (/ x y) (- t y))))) (if (<= y -1.1e-53) t_1 (if (<= y 2.45e-108) (- 1.0 (/ x (* z t))) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = 1.0 + ((x / y) / (t - y));
double tmp;
if (y <= -1.1e-53) {
tmp = t_1;
} else if (y <= 2.45e-108) {
tmp = 1.0 - (x / (z * t));
} else {
tmp = t_1;
}
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) :: t_1
real(8) :: tmp
t_1 = 1.0d0 + ((x / y) / (t - y))
if (y <= (-1.1d-53)) then
tmp = t_1
else if (y <= 2.45d-108) then
tmp = 1.0d0 - (x / (z * t))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = 1.0 + ((x / y) / (t - y));
double tmp;
if (y <= -1.1e-53) {
tmp = t_1;
} else if (y <= 2.45e-108) {
tmp = 1.0 - (x / (z * t));
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = 1.0 + ((x / y) / (t - y)) tmp = 0 if y <= -1.1e-53: tmp = t_1 elif y <= 2.45e-108: tmp = 1.0 - (x / (z * t)) else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(1.0 + Float64(Float64(x / y) / Float64(t - y))) tmp = 0.0 if (y <= -1.1e-53) tmp = t_1; elseif (y <= 2.45e-108) tmp = Float64(1.0 - Float64(x / Float64(z * t))); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = 1.0 + ((x / y) / (t - y)); tmp = 0.0; if (y <= -1.1e-53) tmp = t_1; elseif (y <= 2.45e-108) tmp = 1.0 - (x / (z * t)); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(1.0 + N[(N[(x / y), $MachinePrecision] / N[(t - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.1e-53], t$95$1, If[LessEqual[y, 2.45e-108], N[(1.0 - N[(x / N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := 1 + \frac{\frac{x}{y}}{t - y}\\
\mathbf{if}\;y \leq -1.1 \cdot 10^{-53}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 2.45 \cdot 10^{-108}:\\
\;\;\;\;1 - \frac{x}{z \cdot t}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -1.10000000000000009e-53 or 2.4499999999999999e-108 < y Initial program 99.9%
sub-negN/A
+-lowering-+.f64N/A
associate-/r*N/A
distribute-neg-frac2N/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
--lowering--.f64N/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
remove-double-negN/A
--lowering--.f64100.0%
Simplified100.0%
Taylor expanded in y around inf
/-lowering-/.f6492.5%
Simplified92.5%
if -1.10000000000000009e-53 < y < 2.4499999999999999e-108Initial program 98.0%
Taylor expanded in y around 0
*-lowering-*.f6477.2%
Simplified77.2%
Final simplification86.5%
(FPCore (x y z t) :precision binary64 (if (<= y -1e-53) 1.0 (if (<= y 2.55e-145) (- 1.0 (/ x (* z t))) 1.0)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1e-53) {
tmp = 1.0;
} else if (y <= 2.55e-145) {
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-53)) then
tmp = 1.0d0
else if (y <= 2.55d-145) 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-53) {
tmp = 1.0;
} else if (y <= 2.55e-145) {
tmp = 1.0 - (x / (z * t));
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -1e-53: tmp = 1.0 elif y <= 2.55e-145: tmp = 1.0 - (x / (z * t)) else: tmp = 1.0 return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -1e-53) tmp = 1.0; elseif (y <= 2.55e-145) 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-53) tmp = 1.0; elseif (y <= 2.55e-145) tmp = 1.0 - (x / (z * t)); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -1e-53], 1.0, If[LessEqual[y, 2.55e-145], 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^{-53}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 2.55 \cdot 10^{-145}:\\
\;\;\;\;1 - \frac{x}{z \cdot t}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1.00000000000000003e-53 or 2.54999999999999992e-145 < y Initial program 99.9%
sub-negN/A
+-lowering-+.f64N/A
associate-/r*N/A
distribute-neg-frac2N/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
--lowering--.f64N/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
remove-double-negN/A
--lowering--.f64100.0%
Simplified100.0%
Taylor expanded in x around 0
Simplified84.6%
if -1.00000000000000003e-53 < y < 2.54999999999999992e-145Initial program 97.9%
Taylor expanded in y around 0
*-lowering-*.f6480.6%
Simplified80.6%
Final simplification83.2%
(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(Float64(x / 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[(N[(x / N[(y - z), $MachinePrecision]), $MachinePrecision] / N[(t - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \frac{\frac{x}{y - z}}{t - y}
\end{array}
Initial program 99.2%
sub-negN/A
+-lowering-+.f64N/A
associate-/r*N/A
distribute-neg-frac2N/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
--lowering--.f64N/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
remove-double-negN/A
--lowering--.f6498.1%
Simplified98.1%
(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%
sub-negN/A
+-lowering-+.f64N/A
associate-/r*N/A
distribute-neg-frac2N/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
--lowering--.f64N/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
remove-double-negN/A
--lowering--.f6498.1%
Simplified98.1%
Taylor expanded in x around 0
Simplified74.0%
herbie shell --seed 2024191
(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)))))