| Alternative 1 | |
|---|---|
| Accuracy | 100.0% |
| Cost | 6784 |
\[\mathsf{fma}\left(y + z, x, -z\right)
\]
(FPCore (x y z) :precision binary64 (+ (* x y) (* (- x 1.0) z)))
(FPCore (x y z) :precision binary64 (fma x y (* z (+ x -1.0))))
double code(double x, double y, double z) {
return (x * y) + ((x - 1.0) * z);
}
double code(double x, double y, double z) {
return fma(x, y, (z * (x + -1.0)));
}
function code(x, y, z) return Float64(Float64(x * y) + Float64(Float64(x - 1.0) * z)) end
function code(x, y, z) return fma(x, y, Float64(z * Float64(x + -1.0))) end
code[x_, y_, z_] := N[(N[(x * y), $MachinePrecision] + N[(N[(x - 1.0), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := N[(x * y + N[(z * N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
x \cdot y + \left(x - 1\right) \cdot z
\mathsf{fma}\left(x, y, z \cdot \left(x + -1\right)\right)
Initial program 100.0%
Simplified100.0%
[Start]100.0 | \[ x \cdot y + \left(x - 1\right) \cdot z
\] |
|---|---|
fma-def [=>]100.0 | \[ \color{blue}{\mathsf{fma}\left(x, y, \left(x - 1\right) \cdot z\right)}
\] |
*-commutative [=>]100.0 | \[ \mathsf{fma}\left(x, y, \color{blue}{z \cdot \left(x - 1\right)}\right)
\] |
sub-neg [=>]100.0 | \[ \mathsf{fma}\left(x, y, z \cdot \color{blue}{\left(x + \left(-1\right)\right)}\right)
\] |
distribute-rgt-in [=>]100.0 | \[ \mathsf{fma}\left(x, y, \color{blue}{x \cdot z + \left(-1\right) \cdot z}\right)
\] |
remove-double-neg [<=]100.0 | \[ \mathsf{fma}\left(x, y, \color{blue}{\left(-\left(-x\right)\right)} \cdot z + \left(-1\right) \cdot z\right)
\] |
distribute-rgt-out [=>]100.0 | \[ \mathsf{fma}\left(x, y, \color{blue}{z \cdot \left(\left(-\left(-x\right)\right) + \left(-1\right)\right)}\right)
\] |
distribute-neg-in [<=]100.0 | \[ \mathsf{fma}\left(x, y, z \cdot \color{blue}{\left(-\left(\left(-x\right) + 1\right)\right)}\right)
\] |
*-commutative [<=]100.0 | \[ \mathsf{fma}\left(x, y, \color{blue}{\left(-\left(\left(-x\right) + 1\right)\right) \cdot z}\right)
\] |
distribute-neg-in [=>]100.0 | \[ \mathsf{fma}\left(x, y, \color{blue}{\left(\left(-\left(-x\right)\right) + \left(-1\right)\right)} \cdot z\right)
\] |
remove-double-neg [=>]100.0 | \[ \mathsf{fma}\left(x, y, \left(\color{blue}{x} + \left(-1\right)\right) \cdot z\right)
\] |
metadata-eval [=>]100.0 | \[ \mathsf{fma}\left(x, y, \left(x + \color{blue}{-1}\right) \cdot z\right)
\] |
Final simplification100.0%
| Alternative 1 | |
|---|---|
| Accuracy | 100.0% |
| Cost | 6784 |
| Alternative 2 | |
|---|---|
| Accuracy | 61.8% |
| Cost | 720 |
| Alternative 3 | |
|---|---|
| Accuracy | 98.7% |
| Cost | 712 |
| Alternative 4 | |
|---|---|
| Accuracy | 79.4% |
| Cost | 585 |
| Alternative 5 | |
|---|---|
| Accuracy | 79.6% |
| Cost | 585 |
| Alternative 6 | |
|---|---|
| Accuracy | 98.7% |
| Cost | 585 |
| Alternative 7 | |
|---|---|
| Accuracy | 100.0% |
| Cost | 576 |
| Alternative 8 | |
|---|---|
| Accuracy | 62.0% |
| Cost | 456 |
| Alternative 9 | |
|---|---|
| Accuracy | 100.0% |
| Cost | 448 |
| Alternative 10 | |
|---|---|
| Accuracy | 46.3% |
| Cost | 128 |
herbie shell --seed 2023133
(FPCore (x y z)
:name "Graphics.Rendering.Chart.Drawing:drawTextsR from Chart-1.5.3"
:precision binary64
(+ (* x y) (* (- x 1.0) z)))