| Alternative 1 | |
|---|---|
| Error | 0.0 |
| Cost | 6976 |
\[\mathsf{fma}\left(x, y, t \cdot z\right) + a \cdot b
\]
(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 a b (* t z))))
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(a, b, (t * z)));
}
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(a, b, Float64(t * z))) 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[(a * b + N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(x \cdot y + z \cdot t\right) + a \cdot b
\mathsf{fma}\left(x, y, \mathsf{fma}\left(a, b, t \cdot z\right)\right)
Initial program 0.0
Simplified0.0
[Start]0.0 | \[ \left(x \cdot y + z \cdot t\right) + a \cdot b
\] |
|---|---|
associate-+l+ [=>]0.0 | \[ \color{blue}{x \cdot y + \left(z \cdot t + a \cdot b\right)}
\] |
fma-def [=>]0.0 | \[ \color{blue}{\mathsf{fma}\left(x, y, z \cdot t + a \cdot b\right)}
\] |
fma-def [=>]0.0 | \[ \mathsf{fma}\left(x, y, \color{blue}{\mathsf{fma}\left(z, t, a \cdot b\right)}\right)
\] |
Taylor expanded in z around 0 0.0
Simplified0.0
[Start]0.0 | \[ \mathsf{fma}\left(x, y, a \cdot b + t \cdot z\right)
\] |
|---|---|
*-commutative [=>]0.0 | \[ \mathsf{fma}\left(x, y, a \cdot b + \color{blue}{z \cdot t}\right)
\] |
fma-def [=>]0.0 | \[ \mathsf{fma}\left(x, y, \color{blue}{\mathsf{fma}\left(a, b, z \cdot t\right)}\right)
\] |
*-commutative [<=]0.0 | \[ \mathsf{fma}\left(x, y, \mathsf{fma}\left(a, b, \color{blue}{t \cdot z}\right)\right)
\] |
Final simplification0.0
| Alternative 1 | |
|---|---|
| Error | 0.0 |
| Cost | 6976 |
| Alternative 2 | |
|---|---|
| Error | 31.9 |
| Cost | 2272 |
| Alternative 3 | |
|---|---|
| Error | 20.0 |
| Cost | 1243 |
| Alternative 4 | |
|---|---|
| Error | 16.4 |
| Cost | 1240 |
| Alternative 5 | |
|---|---|
| Error | 9.6 |
| Cost | 969 |
| Alternative 6 | |
|---|---|
| Error | 31.6 |
| Cost | 712 |
| Alternative 7 | |
|---|---|
| Error | 0.0 |
| Cost | 704 |
| Alternative 8 | |
|---|---|
| Error | 41.6 |
| Cost | 192 |
herbie shell --seed 2023055
(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)))