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

(FPCore (x y z t) :precision binary64 (+ (* (+ (* x y) z) y) t))
(FPCore (x y z t) :precision binary64 (fma (fma x y z) y t))
double code(double x, double y, double z, double t) {
return (((x * y) + z) * y) + t;
}
double code(double x, double y, double z, double t) {
return fma(fma(x, y, z), y, t);
}
function code(x, y, z, t) return Float64(Float64(Float64(Float64(x * y) + z) * y) + t) end
function code(x, y, z, t) return fma(fma(x, y, z), y, t) end
code[x_, y_, z_, t_] := N[(N[(N[(N[(x * y), $MachinePrecision] + z), $MachinePrecision] * y), $MachinePrecision] + t), $MachinePrecision]
code[x_, y_, z_, t_] := N[(N[(x * y + z), $MachinePrecision] * y + t), $MachinePrecision]
\left(x \cdot y + z\right) \cdot y + t
\mathsf{fma}\left(\mathsf{fma}\left(x, y, z\right), y, t\right)
Herbie found 6 alternatives:
| Alternative | Accuracy | Speedup |
|---|
Initial program 99.9%
Simplified100.0%
[Start]99.9% | \[ \left(x \cdot y + z\right) \cdot y + t
\] |
|---|---|
fma-def [=>]100.0% | \[ \color{blue}{\mathsf{fma}\left(x \cdot y + z, y, t\right)}
\] |
fma-def [=>]100.0% | \[ \mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(x, y, z\right)}, y, t\right)
\] |
Final simplification100.0%
| Alternative 1 | |
|---|---|
| Accuracy | 99.9% |
| Cost | 13120 |
| Alternative 2 | |
|---|---|
| Accuracy | 51.8% |
| Cost | 720 |
| Alternative 3 | |
|---|---|
| Accuracy | 87.0% |
| Cost | 713 |
| Alternative 4 | |
|---|---|
| Accuracy | 99.9% |
| Cost | 576 |
| Alternative 5 | |
|---|---|
| Accuracy | 66.4% |
| Cost | 320 |
| Alternative 6 | |
|---|---|
| Accuracy | 39.2% |
| Cost | 64 |
herbie shell --seed 2023263
(FPCore (x y z t)
:name "Language.Haskell.HsColour.ColourHighlight:unbase from hscolour-1.23"
:precision binary64
(+ (* (+ (* x y) z) y) t))