| Alternative 1 | |
|---|---|
| Accuracy | 100.0% |
| Cost | 6720 |
\[\mathsf{fma}\left(x, y, y\right) - x
\]

(FPCore (x y) :precision binary64 (- (* (+ x 1.0) y) x))
(FPCore (x y) :precision binary64 (- (fma x y y) x))
double code(double x, double y) {
return ((x + 1.0) * y) - x;
}
double code(double x, double y) {
return fma(x, y, y) - x;
}
function code(x, y) return Float64(Float64(Float64(x + 1.0) * y) - x) end
function code(x, y) return Float64(fma(x, y, y) - x) end
code[x_, y_] := N[(N[(N[(x + 1.0), $MachinePrecision] * y), $MachinePrecision] - x), $MachinePrecision]
code[x_, y_] := N[(N[(x * y + y), $MachinePrecision] - x), $MachinePrecision]
\left(x + 1\right) \cdot y - x
\mathsf{fma}\left(x, y, y\right) - x
Herbie found 6 alternatives:
| Alternative | Accuracy | Speedup |
|---|
Initial program 100.0%
Simplified100.0%
[Start]100.0% | \[ \left(x + 1\right) \cdot y - x
\] |
|---|---|
*-commutative [=>]100.0% | \[ \color{blue}{y \cdot \left(x + 1\right)} - x
\] |
distribute-rgt-in [=>]100.0% | \[ \color{blue}{\left(x \cdot y + 1 \cdot y\right)} - x
\] |
fma-def [=>]100.0% | \[ \color{blue}{\mathsf{fma}\left(x, y, 1 \cdot y\right)} - x
\] |
*-lft-identity [=>]100.0% | \[ \mathsf{fma}\left(x, y, \color{blue}{y}\right) - x
\] |
Final simplification100.0%
| Alternative 1 | |
|---|---|
| Accuracy | 100.0% |
| Cost | 6720 |
| Alternative 2 | |
|---|---|
| Accuracy | 75.6% |
| Cost | 589 |
| Alternative 3 | |
|---|---|
| Accuracy | 98.7% |
| Cost | 585 |
| Alternative 4 | |
|---|---|
| Accuracy | 61.7% |
| Cost | 456 |
| Alternative 5 | |
|---|---|
| Accuracy | 100.0% |
| Cost | 448 |
| Alternative 6 | |
|---|---|
| Accuracy | 39.7% |
| Cost | 128 |
herbie shell --seed 2023272
(FPCore (x y)
:name "Data.Colour.SRGB:transferFunction from colour-2.3.3"
:precision binary64
(- (* (+ x 1.0) y) x))