| Alternative 1 | |
|---|---|
| Accuracy | 97.7% |
| Cost | 20160 |
\[\mathsf{fma}\left(y + \left(t + -2\right), b, \mathsf{fma}\left(a, 1 - t, \mathsf{fma}\left(z, 1 - y, x\right)\right)\right)
\]

(FPCore (x y z t a b) :precision binary64 (+ (- (- x (* (- y 1.0) z)) (* (- t 1.0) a)) (* (- (+ y t) 2.0) b)))
(FPCore (x y z t a b) :precision binary64 (fma (+ y (+ t -2.0)) b (fma a (- 1.0 t) (fma z (- 1.0 y) x))))
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);
}
double code(double x, double y, double z, double t, double a, double b) {
return fma((y + (t + -2.0)), b, fma(a, (1.0 - t), fma(z, (1.0 - y), x)));
}
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 code(x, y, z, t, a, b) return fma(Float64(y + Float64(t + -2.0)), b, fma(a, Float64(1.0 - t), fma(z, Float64(1.0 - y), x))) 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]
code[x_, y_, z_, t_, a_, b_] := N[(N[(y + N[(t + -2.0), $MachinePrecision]), $MachinePrecision] * b + N[(a * N[(1.0 - t), $MachinePrecision] + N[(z * N[(1.0 - y), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\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
\mathsf{fma}\left(y + \left(t + -2\right), b, \mathsf{fma}\left(a, 1 - t, \mathsf{fma}\left(z, 1 - y, x\right)\right)\right)
Herbie found 21 alternatives:
| Alternative | Accuracy | Speedup |
|---|
Initial program 97.3%
Simplified98.8%
[Start]97.3% | \[ \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
\] |
|---|---|
+-commutative [=>]97.3% | \[ \color{blue}{\left(\left(y + t\right) - 2\right) \cdot b + \left(\left(x - \left(y - 1\right) \cdot z\right) - \left(t - 1\right) \cdot a\right)}
\] |
fma-def [=>]98.0% | \[ \color{blue}{\mathsf{fma}\left(\left(y + t\right) - 2, b, \left(x - \left(y - 1\right) \cdot z\right) - \left(t - 1\right) \cdot a\right)}
\] |
sub-neg [=>]98.0% | \[ \mathsf{fma}\left(\color{blue}{\left(y + t\right) + \left(-2\right)}, b, \left(x - \left(y - 1\right) \cdot z\right) - \left(t - 1\right) \cdot a\right)
\] |
associate-+l+ [=>]98.0% | \[ \mathsf{fma}\left(\color{blue}{y + \left(t + \left(-2\right)\right)}, b, \left(x - \left(y - 1\right) \cdot z\right) - \left(t - 1\right) \cdot a\right)
\] |
metadata-eval [=>]98.0% | \[ \mathsf{fma}\left(y + \left(t + \color{blue}{-2}\right), b, \left(x - \left(y - 1\right) \cdot z\right) - \left(t - 1\right) \cdot a\right)
\] |
sub-neg [=>]98.0% | \[ \mathsf{fma}\left(y + \left(t + -2\right), b, \color{blue}{\left(x - \left(y - 1\right) \cdot z\right) + \left(-\left(t - 1\right) \cdot a\right)}\right)
\] |
+-commutative [=>]98.0% | \[ \mathsf{fma}\left(y + \left(t + -2\right), b, \color{blue}{\left(-\left(t - 1\right) \cdot a\right) + \left(x - \left(y - 1\right) \cdot z\right)}\right)
\] |
*-commutative [=>]98.0% | \[ \mathsf{fma}\left(y + \left(t + -2\right), b, \left(-\color{blue}{a \cdot \left(t - 1\right)}\right) + \left(x - \left(y - 1\right) \cdot z\right)\right)
\] |
distribute-rgt-neg-in [=>]98.0% | \[ \mathsf{fma}\left(y + \left(t + -2\right), b, \color{blue}{a \cdot \left(-\left(t - 1\right)\right)} + \left(x - \left(y - 1\right) \cdot z\right)\right)
\] |
fma-def [=>]98.8% | \[ \mathsf{fma}\left(y + \left(t + -2\right), b, \color{blue}{\mathsf{fma}\left(a, -\left(t - 1\right), x - \left(y - 1\right) \cdot z\right)}\right)
\] |
neg-sub0 [=>]98.8% | \[ \mathsf{fma}\left(y + \left(t + -2\right), b, \mathsf{fma}\left(a, \color{blue}{0 - \left(t - 1\right)}, x - \left(y - 1\right) \cdot z\right)\right)
\] |
associate--r- [=>]98.8% | \[ \mathsf{fma}\left(y + \left(t + -2\right), b, \mathsf{fma}\left(a, \color{blue}{\left(0 - t\right) + 1}, x - \left(y - 1\right) \cdot z\right)\right)
\] |
neg-sub0 [<=]98.8% | \[ \mathsf{fma}\left(y + \left(t + -2\right), b, \mathsf{fma}\left(a, \color{blue}{\left(-t\right)} + 1, x - \left(y - 1\right) \cdot z\right)\right)
\] |
+-commutative [=>]98.8% | \[ \mathsf{fma}\left(y + \left(t + -2\right), b, \mathsf{fma}\left(a, \color{blue}{1 + \left(-t\right)}, x - \left(y - 1\right) \cdot z\right)\right)
\] |
sub-neg [<=]98.8% | \[ \mathsf{fma}\left(y + \left(t + -2\right), b, \mathsf{fma}\left(a, \color{blue}{1 - t}, x - \left(y - 1\right) \cdot z\right)\right)
\] |
sub-neg [=>]98.8% | \[ \mathsf{fma}\left(y + \left(t + -2\right), b, \mathsf{fma}\left(a, 1 - t, \color{blue}{x + \left(-\left(y - 1\right) \cdot z\right)}\right)\right)
\] |
+-commutative [=>]98.8% | \[ \mathsf{fma}\left(y + \left(t + -2\right), b, \mathsf{fma}\left(a, 1 - t, \color{blue}{\left(-\left(y - 1\right) \cdot z\right) + x}\right)\right)
\] |
*-commutative [=>]98.8% | \[ \mathsf{fma}\left(y + \left(t + -2\right), b, \mathsf{fma}\left(a, 1 - t, \left(-\color{blue}{z \cdot \left(y - 1\right)}\right) + x\right)\right)
\] |
distribute-rgt-neg-in [=>]98.8% | \[ \mathsf{fma}\left(y + \left(t + -2\right), b, \mathsf{fma}\left(a, 1 - t, \color{blue}{z \cdot \left(-\left(y - 1\right)\right)} + x\right)\right)
\] |
fma-def [=>]98.8% | \[ \mathsf{fma}\left(y + \left(t + -2\right), b, \mathsf{fma}\left(a, 1 - t, \color{blue}{\mathsf{fma}\left(z, -\left(y - 1\right), x\right)}\right)\right)
\] |
Final simplification98.8%
| Alternative 1 | |
|---|---|
| Accuracy | 97.7% |
| Cost | 20160 |
| Alternative 2 | |
|---|---|
| Accuracy | 97.6% |
| Cost | 13888 |
| Alternative 3 | |
|---|---|
| Accuracy | 97.9% |
| Cost | 2756 |
| Alternative 4 | |
|---|---|
| Accuracy | 78.6% |
| Cost | 1492 |
| Alternative 5 | |
|---|---|
| Accuracy | 81.9% |
| Cost | 1360 |
| Alternative 6 | |
|---|---|
| Accuracy | 59.5% |
| Cost | 1240 |
| Alternative 7 | |
|---|---|
| Accuracy | 93.5% |
| Cost | 1225 |
| Alternative 8 | |
|---|---|
| Accuracy | 32.1% |
| Cost | 1180 |
| Alternative 9 | |
|---|---|
| Accuracy | 37.4% |
| Cost | 1112 |
| Alternative 10 | |
|---|---|
| Accuracy | 50.4% |
| Cost | 1112 |
| Alternative 11 | |
|---|---|
| Accuracy | 68.4% |
| Cost | 1104 |
| Alternative 12 | |
|---|---|
| Accuracy | 71.5% |
| Cost | 969 |
| Alternative 13 | |
|---|---|
| Accuracy | 54.2% |
| Cost | 848 |
| Alternative 14 | |
|---|---|
| Accuracy | 70.3% |
| Cost | 841 |
| Alternative 15 | |
|---|---|
| Accuracy | 23.9% |
| Cost | 720 |
| Alternative 16 | |
|---|---|
| Accuracy | 32.7% |
| Cost | 652 |
| Alternative 17 | |
|---|---|
| Accuracy | 25.8% |
| Cost | 588 |
| Alternative 18 | |
|---|---|
| Accuracy | 32.4% |
| Cost | 588 |
| Alternative 19 | |
|---|---|
| Accuracy | 20.2% |
| Cost | 460 |
| Alternative 20 | |
|---|---|
| Accuracy | 19.4% |
| Cost | 328 |
| Alternative 21 | |
|---|---|
| Accuracy | 11.0% |
| Cost | 64 |
herbie shell --seed 2023263
(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)))