| Alternative 1 | |
|---|---|
| Accuracy | 100.0% |
| Cost | 6976 |
\[a \cdot b + \mathsf{fma}\left(x, y, z \cdot t\right)
\]
(FPCore (x y z t a b) :precision binary64 (+ (+ (* x y) (* z t)) (* a b)))
(FPCore (x y z t a b) :precision binary64 (+ (fma z t (* y x)) (* a b)))
double code(double x, double y, double z, double t, double a, double b) {
return ((x * y) + (z * t)) + (a * b);
}
double code(double x, double y, double z, double t, double a, double b) {
return fma(z, t, (y * x)) + (a * b);
}
function code(x, y, z, t, a, b) return Float64(Float64(Float64(x * y) + Float64(z * t)) + Float64(a * b)) end
function code(x, y, z, t, a, b) return Float64(fma(z, t, Float64(y * x)) + Float64(a * b)) end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_, b_] := N[(N[(z * t + N[(y * x), $MachinePrecision]), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision]
\left(x \cdot y + z \cdot t\right) + a \cdot b
\mathsf{fma}\left(z, t, y \cdot x\right) + a \cdot b
Initial program 100.0%
Simplified100.0%
[Start]100.0 | \[ \left(x \cdot y + z \cdot t\right) + a \cdot b
\] |
|---|---|
fma-def [=>]100.0 | \[ \color{blue}{\mathsf{fma}\left(x, y, z \cdot t\right)} + a \cdot b
\] |
Taylor expanded in x around 0 100.0%
Simplified100.0%
[Start]100.0 | \[ \left(y \cdot x + t \cdot z\right) + a \cdot b
\] |
|---|---|
+-commutative [=>]100.0 | \[ \color{blue}{\left(t \cdot z + y \cdot x\right)} + a \cdot b
\] |
*-commutative [<=]100.0 | \[ \left(\color{blue}{z \cdot t} + y \cdot x\right) + a \cdot b
\] |
*-commutative [=>]100.0 | \[ \left(z \cdot t + \color{blue}{x \cdot y}\right) + a \cdot b
\] |
fma-def [=>]100.0 | \[ \color{blue}{\mathsf{fma}\left(z, t, x \cdot y\right)} + a \cdot b
\] |
*-commutative [<=]100.0 | \[ \mathsf{fma}\left(z, t, \color{blue}{y \cdot x}\right) + a \cdot b
\] |
Final simplification100.0%
| Alternative 1 | |
|---|---|
| Accuracy | 100.0% |
| Cost | 6976 |
| Alternative 2 | |
|---|---|
| Accuracy | 52.2% |
| Cost | 1232 |
| Alternative 3 | |
|---|---|
| Accuracy | 74.9% |
| Cost | 713 |
| Alternative 4 | |
|---|---|
| Accuracy | 51.6% |
| Cost | 712 |
| Alternative 5 | |
|---|---|
| Accuracy | 66.8% |
| Cost | 712 |
| Alternative 6 | |
|---|---|
| Accuracy | 100.0% |
| Cost | 704 |
| Alternative 7 | |
|---|---|
| Accuracy | 35.0% |
| Cost | 192 |
herbie shell --seed 2023129
(FPCore (x y z t a b)
:name "Linear.V3:$cdot from linear-1.19.1.3, B"
:precision binary64
(+ (+ (* x y) (* z t)) (* a b)))