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

(FPCore (x y z) :precision binary64 (- x (* y z)))
(FPCore (x y z) :precision binary64 (fma y (- z) x))
double code(double x, double y, double z) {
return x - (y * z);
}
double code(double x, double y, double z) {
return fma(y, -z, x);
}
function code(x, y, z) return Float64(x - Float64(y * z)) end
function code(x, y, z) return fma(y, Float64(-z), x) end
code[x_, y_, z_] := N[(x - N[(y * z), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := N[(y * (-z) + x), $MachinePrecision]
x - y \cdot z
\mathsf{fma}\left(y, -z, x\right)
Herbie found 4 alternatives:
| Alternative | Accuracy | Speedup |
|---|
| Original | 100.0% |
|---|---|
| Target | 86.8% |
| Herbie | 100.0% |
Initial program 100.0%
Simplified100.0%
[Start]100.0% | \[ x - y \cdot z
\] |
|---|---|
sub-neg [=>]100.0% | \[ \color{blue}{x + \left(-y \cdot z\right)}
\] |
+-commutative [=>]100.0% | \[ \color{blue}{\left(-y \cdot z\right) + x}
\] |
distribute-rgt-neg-in [=>]100.0% | \[ \color{blue}{y \cdot \left(-z\right)} + x
\] |
fma-def [=>]100.0% | \[ \color{blue}{\mathsf{fma}\left(y, -z, x\right)}
\] |
Final simplification100.0%
| Alternative 1 | |
|---|---|
| Accuracy | 100.0% |
| Cost | 6656 |
| Alternative 2 | |
|---|---|
| Accuracy | 69.1% |
| Cost | 786 |
| Alternative 3 | |
|---|---|
| Accuracy | 100.0% |
| Cost | 320 |
| Alternative 4 | |
|---|---|
| Accuracy | 51.3% |
| Cost | 64 |
herbie shell --seed 2023243
(FPCore (x y z)
:name "Diagrams.Solve.Tridiagonal:solveTriDiagonal from diagrams-solve-0.1, C"
:precision binary64
:herbie-target
(/ (+ x (* y z)) (/ (+ x (* y z)) (- x (* y z))))
(- x (* y z)))