| Alternative 1 | |
|---|---|
| Error | 0.03% |
| 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 x y (fma z t (* 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(x, y, fma(z, t, (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 fma(x, y, fma(z, t, 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[(x * y + N[(z * t + N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(x \cdot y + z \cdot t\right) + a \cdot b
\mathsf{fma}\left(x, y, \mathsf{fma}\left(z, t, a \cdot b\right)\right)
Initial program 0.03
Simplified0.02
[Start]0.03 | \[ \left(x \cdot y + z \cdot t\right) + a \cdot b
\] |
|---|---|
associate-+l+ [=>]0.03 | \[ \color{blue}{x \cdot y + \left(z \cdot t + a \cdot b\right)}
\] |
fma-def [=>]0.02 | \[ \color{blue}{\mathsf{fma}\left(x, y, z \cdot t + a \cdot b\right)}
\] |
fma-def [=>]0.02 | \[ \mathsf{fma}\left(x, y, \color{blue}{\mathsf{fma}\left(z, t, a \cdot b\right)}\right)
\] |
Final simplification0.02
| Alternative 1 | |
|---|---|
| Error | 0.03% |
| Cost | 6976 |
| Alternative 2 | |
|---|---|
| Error | 48.63% |
| Cost | 2012 |
| Alternative 3 | |
|---|---|
| Error | 16.05% |
| Cost | 1228 |
| Alternative 4 | |
|---|---|
| Error | 22.88% |
| Cost | 978 |
| Alternative 5 | |
|---|---|
| Error | 48.47% |
| Cost | 712 |
| Alternative 6 | |
|---|---|
| Error | 30.06% |
| Cost | 712 |
| Alternative 7 | |
|---|---|
| Error | 0.03% |
| Cost | 704 |
| Alternative 8 | |
|---|---|
| Error | 66.02% |
| Cost | 192 |
herbie shell --seed 2023102
(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)))