| Alternative 1 | |
|---|---|
| Accuracy | 99.6% |
| Cost | 6784 |
\[\mathsf{fma}\left(-z, t, x \cdot y\right)
\]

(FPCore (x y z t) :precision binary64 (- (* x y) (* z t)))
(FPCore (x y z t) :precision binary64 (fma (- z) t (* x y)))
double code(double x, double y, double z, double t) {
return (x * y) - (z * t);
}
double code(double x, double y, double z, double t) {
return fma(-z, t, (x * y));
}
function code(x, y, z, t) return Float64(Float64(x * y) - Float64(z * t)) end
function code(x, y, z, t) return fma(Float64(-z), t, Float64(x * y)) end
code[x_, y_, z_, t_] := N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := N[((-z) * t + N[(x * y), $MachinePrecision]), $MachinePrecision]
x \cdot y - z \cdot t
\mathsf{fma}\left(-z, t, x \cdot y\right)
Herbie found 5 alternatives:
| Alternative | Accuracy | Speedup |
|---|
Initial program 100.0%
Applied egg-rr100.0%
[Start]100.0% | \[ x \cdot y - z \cdot t
\] |
|---|---|
sub-neg [=>]100.0% | \[ \color{blue}{x \cdot y + \left(-z \cdot t\right)}
\] |
distribute-rgt-neg-out [<=]100.0% | \[ x \cdot y + \color{blue}{z \cdot \left(-t\right)}
\] |
+-commutative [=>]100.0% | \[ \color{blue}{z \cdot \left(-t\right) + x \cdot y}
\] |
distribute-rgt-neg-out [=>]100.0% | \[ \color{blue}{\left(-z \cdot t\right)} + x \cdot y
\] |
distribute-lft-neg-in [=>]100.0% | \[ \color{blue}{\left(-z\right) \cdot t} + x \cdot y
\] |
fma-def [=>]100.0% | \[ \color{blue}{\mathsf{fma}\left(-z, t, x \cdot y\right)}
\] |
Final simplification100.0%
| Alternative 1 | |
|---|---|
| Accuracy | 99.6% |
| Cost | 6784 |
| Alternative 2 | |
|---|---|
| Accuracy | 99.6% |
| Cost | 6784 |
| Alternative 3 | |
|---|---|
| Accuracy | 66.6% |
| Cost | 521 |
| Alternative 4 | |
|---|---|
| Accuracy | 99.2% |
| Cost | 448 |
| Alternative 5 | |
|---|---|
| Accuracy | 52.7% |
| Cost | 192 |
herbie shell --seed 2023277
(FPCore (x y z t)
:name "Linear.V3:cross from linear-1.19.1.3"
:precision binary64
(- (* x y) (* z t)))