
(FPCore (x y z t a b) :precision binary64 (+ (- (- x (* (- y 1.0) z)) (* (- t 1.0) a)) (* (- (+ y t) 2.0) b)))
double code(double x, double y, double z, double t, double a, double b) {
return ((x - ((y - 1.0) * z)) - ((t - 1.0) * a)) + (((y + t) - 2.0) * b);
}
real(8) function code(x, y, z, t, a, b)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((x - ((y - 1.0d0) * z)) - ((t - 1.0d0) * a)) + (((y + t) - 2.0d0) * b)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return ((x - ((y - 1.0) * z)) - ((t - 1.0) * a)) + (((y + t) - 2.0) * b);
}
def code(x, y, z, t, a, b): return ((x - ((y - 1.0) * z)) - ((t - 1.0) * a)) + (((y + t) - 2.0) * b)
function code(x, y, z, t, a, b) return Float64(Float64(Float64(x - Float64(Float64(y - 1.0) * z)) - Float64(Float64(t - 1.0) * a)) + Float64(Float64(Float64(y + t) - 2.0) * b)) end
function tmp = code(x, y, z, t, a, b) tmp = ((x - ((y - 1.0) * z)) - ((t - 1.0) * a)) + (((y + t) - 2.0) * b); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(x - N[(N[(y - 1.0), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision] - N[(N[(t - 1.0), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(y + t), $MachinePrecision] - 2.0), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x - \left(y - 1\right) \cdot z\right) - \left(t - 1\right) \cdot a\right) + \left(\left(y + t\right) - 2\right) \cdot b
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 19 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a b) :precision binary64 (+ (- (- x (* (- y 1.0) z)) (* (- t 1.0) a)) (* (- (+ y t) 2.0) b)))
double code(double x, double y, double z, double t, double a, double b) {
return ((x - ((y - 1.0) * z)) - ((t - 1.0) * a)) + (((y + t) - 2.0) * b);
}
real(8) function code(x, y, z, t, a, b)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((x - ((y - 1.0d0) * z)) - ((t - 1.0d0) * a)) + (((y + t) - 2.0d0) * b)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return ((x - ((y - 1.0) * z)) - ((t - 1.0) * a)) + (((y + t) - 2.0) * b);
}
def code(x, y, z, t, a, b): return ((x - ((y - 1.0) * z)) - ((t - 1.0) * a)) + (((y + t) - 2.0) * b)
function code(x, y, z, t, a, b) return Float64(Float64(Float64(x - Float64(Float64(y - 1.0) * z)) - Float64(Float64(t - 1.0) * a)) + Float64(Float64(Float64(y + t) - 2.0) * b)) end
function tmp = code(x, y, z, t, a, b) tmp = ((x - ((y - 1.0) * z)) - ((t - 1.0) * a)) + (((y + t) - 2.0) * b); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(x - N[(N[(y - 1.0), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision] - N[(N[(t - 1.0), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(y + t), $MachinePrecision] - 2.0), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x - \left(y - 1\right) \cdot z\right) - \left(t - 1\right) \cdot a\right) + \left(\left(y + t\right) - 2\right) \cdot b
\end{array}
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1
(+ (+ (+ x (* z (- 1.0 y))) (* a (- 1.0 t))) (* (- (+ y t) 2.0) b))))
(if (<= t_1 INFINITY) t_1 (+ a (fma z (- 1.0 y) (* t (- b a)))))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = ((x + (z * (1.0 - y))) + (a * (1.0 - t))) + (((y + t) - 2.0) * b);
double tmp;
if (t_1 <= ((double) INFINITY)) {
tmp = t_1;
} else {
tmp = a + fma(z, (1.0 - y), (t * (b - a)));
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(Float64(x + Float64(z * Float64(1.0 - y))) + Float64(a * Float64(1.0 - t))) + Float64(Float64(Float64(y + t) - 2.0) * b)) tmp = 0.0 if (t_1 <= Inf) tmp = t_1; else tmp = Float64(a + fma(z, Float64(1.0 - y), Float64(t * Float64(b - a)))); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(N[(x + N[(z * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(a * N[(1.0 - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(y + t), $MachinePrecision] - 2.0), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, Infinity], t$95$1, N[(a + N[(z * N[(1.0 - y), $MachinePrecision] + N[(t * N[(b - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(\left(x + z \cdot \left(1 - y\right)\right) + a \cdot \left(1 - t\right)\right) + \left(\left(y + t\right) - 2\right) \cdot b\\
\mathbf{if}\;t\_1 \leq \infty:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;a + \mathsf{fma}\left(z, 1 - y, t \cdot \left(b - a\right)\right)\\
\end{array}
\end{array}
if (+.f64 (-.f64 (-.f64 x (*.f64 (-.f64 y #s(literal 1 binary64)) z)) (*.f64 (-.f64 t #s(literal 1 binary64)) a)) (*.f64 (-.f64 (+.f64 y t) #s(literal 2 binary64)) b)) < +inf.0Initial program 100.0%
if +inf.0 < (+.f64 (-.f64 (-.f64 x (*.f64 (-.f64 y #s(literal 1 binary64)) z)) (*.f64 (-.f64 t #s(literal 1 binary64)) a)) (*.f64 (-.f64 (+.f64 y t) #s(literal 2 binary64)) b)) Initial program 0.0%
Taylor expanded in x around 0
Simplified50.0%
Taylor expanded in t around inf
lower-*.f64N/A
lower--.f6475.0
Simplified75.0%
Final simplification98.4%
(FPCore (x y z t a b)
:precision binary64
(if (<= b -6e+23)
(fma (+ y t) b (* b -2.0))
(if (<= b 1.65e+90)
(fma a (- 1.0 t) (fma z (- 1.0 y) x))
(if (<= b 1.5e+205)
(+ a (fma z (- 1.0 y) (* t (- b a))))
(* b (+ y (+ t -2.0)))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (b <= -6e+23) {
tmp = fma((y + t), b, (b * -2.0));
} else if (b <= 1.65e+90) {
tmp = fma(a, (1.0 - t), fma(z, (1.0 - y), x));
} else if (b <= 1.5e+205) {
tmp = a + fma(z, (1.0 - y), (t * (b - a)));
} else {
tmp = b * (y + (t + -2.0));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (b <= -6e+23) tmp = fma(Float64(y + t), b, Float64(b * -2.0)); elseif (b <= 1.65e+90) tmp = fma(a, Float64(1.0 - t), fma(z, Float64(1.0 - y), x)); elseif (b <= 1.5e+205) tmp = Float64(a + fma(z, Float64(1.0 - y), Float64(t * Float64(b - a)))); else tmp = Float64(b * Float64(y + Float64(t + -2.0))); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[b, -6e+23], N[(N[(y + t), $MachinePrecision] * b + N[(b * -2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.65e+90], N[(a * N[(1.0 - t), $MachinePrecision] + N[(z * N[(1.0 - y), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.5e+205], N[(a + N[(z * N[(1.0 - y), $MachinePrecision] + N[(t * N[(b - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(b * N[(y + N[(t + -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -6 \cdot 10^{+23}:\\
\;\;\;\;\mathsf{fma}\left(y + t, b, b \cdot -2\right)\\
\mathbf{elif}\;b \leq 1.65 \cdot 10^{+90}:\\
\;\;\;\;\mathsf{fma}\left(a, 1 - t, \mathsf{fma}\left(z, 1 - y, x\right)\right)\\
\mathbf{elif}\;b \leq 1.5 \cdot 10^{+205}:\\
\;\;\;\;a + \mathsf{fma}\left(z, 1 - y, t \cdot \left(b - a\right)\right)\\
\mathbf{else}:\\
\;\;\;\;b \cdot \left(y + \left(t + -2\right)\right)\\
\end{array}
\end{array}
if b < -6.0000000000000002e23Initial program 89.7%
Taylor expanded in b around inf
lower-*.f64N/A
+-commutativeN/A
associate-+r-N/A
lower-+.f64N/A
sub-negN/A
lower-+.f64N/A
metadata-eval66.7
Simplified66.7%
associate-+r+N/A
distribute-rgt-inN/A
lower-fma.f64N/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f6466.5
Applied egg-rr66.5%
if -6.0000000000000002e23 < b < 1.65000000000000004e90Initial program 98.6%
Taylor expanded in b around 0
associate--r+N/A
sub-negN/A
+-commutativeN/A
associate-+r-N/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
distribute-lft-inN/A
metadata-evalN/A
neg-mul-1N/A
sub-negN/A
lower--.f64N/A
sub-negN/A
+-commutativeN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
Simplified87.7%
if 1.65000000000000004e90 < b < 1.5e205Initial program 89.3%
Taylor expanded in x around 0
Simplified94.2%
Taylor expanded in t around inf
lower-*.f64N/A
lower--.f6459.4
Simplified59.4%
if 1.5e205 < b Initial program 86.8%
Taylor expanded in b around inf
lower-*.f64N/A
+-commutativeN/A
associate-+r-N/A
lower-+.f64N/A
sub-negN/A
lower-+.f64N/A
metadata-eval90.9
Simplified90.9%
herbie shell --seed 2024218
(FPCore (x y z t a b)
:name "Statistics.Distribution.Beta:$centropy from math-functions-0.1.5.2"
:precision binary64
(+ (- (- x (* (- y 1.0) z)) (* (- t 1.0) a)) (* (- (+ y t) 2.0) b)))