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

(FPCore (x y z t) :precision binary64 (+ (* x (+ (+ (+ (+ y z) z) y) t)) (* y 5.0)))
(FPCore (x y z t) :precision binary64 (fma y 5.0 (* x (fma (+ y z) 2.0 t))))
double code(double x, double y, double z, double t) {
return (x * ((((y + z) + z) + y) + t)) + (y * 5.0);
}
double code(double x, double y, double z, double t) {
return fma(y, 5.0, (x * fma((y + z), 2.0, t)));
}
function code(x, y, z, t) return Float64(Float64(x * Float64(Float64(Float64(Float64(y + z) + z) + y) + t)) + Float64(y * 5.0)) end
function code(x, y, z, t) return fma(y, 5.0, Float64(x * fma(Float64(y + z), 2.0, t))) end
code[x_, y_, z_, t_] := N[(N[(x * N[(N[(N[(N[(y + z), $MachinePrecision] + z), $MachinePrecision] + y), $MachinePrecision] + t), $MachinePrecision]), $MachinePrecision] + N[(y * 5.0), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := N[(y * 5.0 + N[(x * N[(N[(y + z), $MachinePrecision] * 2.0 + t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
x \cdot \left(\left(\left(\left(y + z\right) + z\right) + y\right) + t\right) + y \cdot 5
\mathsf{fma}\left(y, 5, x \cdot \mathsf{fma}\left(y + z, 2, t\right)\right)
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
Initial program 99.5%
Applied egg-rr100.0%
[Start]99.5% | \[ x \cdot \left(\left(\left(\left(y + z\right) + z\right) + y\right) + t\right) + y \cdot 5
\] |
|---|---|
+-commutative [=>]99.5% | \[ \color{blue}{y \cdot 5 + x \cdot \left(\left(\left(\left(y + z\right) + z\right) + y\right) + t\right)}
\] |
fma-def [=>]100.0% | \[ \color{blue}{\mathsf{fma}\left(y, 5, x \cdot \left(\left(\left(\left(y + z\right) + z\right) + y\right) + t\right)\right)}
\] |
distribute-rgt-in [=>]96.9% | \[ \mathsf{fma}\left(y, 5, \color{blue}{\left(\left(\left(y + z\right) + z\right) + y\right) \cdot x + t \cdot x}\right)
\] |
associate-+l+ [=>]96.9% | \[ \mathsf{fma}\left(y, 5, \color{blue}{\left(\left(y + z\right) + \left(z + y\right)\right)} \cdot x + t \cdot x\right)
\] |
+-commutative [<=]96.9% | \[ \mathsf{fma}\left(y, 5, \left(\left(y + z\right) + \color{blue}{\left(y + z\right)}\right) \cdot x + t \cdot x\right)
\] |
count-2 [=>]96.9% | \[ \mathsf{fma}\left(y, 5, \color{blue}{\left(2 \cdot \left(y + z\right)\right)} \cdot x + t \cdot x\right)
\] |
distribute-rgt-in [<=]100.0% | \[ \mathsf{fma}\left(y, 5, \color{blue}{x \cdot \left(2 \cdot \left(y + z\right) + t\right)}\right)
\] |
*-commutative [=>]100.0% | \[ \mathsf{fma}\left(y, 5, x \cdot \left(\color{blue}{\left(y + z\right) \cdot 2} + t\right)\right)
\] |
fma-def [=>]100.0% | \[ \mathsf{fma}\left(y, 5, x \cdot \color{blue}{\mathsf{fma}\left(y + z, 2, t\right)}\right)
\] |
Final simplification100.0%
| Alternative 1 | |
|---|---|
| Accuracy | 99.9% |
| Cost | 13376 |
| Alternative 2 | |
|---|---|
| Accuracy | 99.8% |
| Cost | 7104 |
| Alternative 3 | |
|---|---|
| Accuracy | 86.2% |
| Cost | 1100 |
| Alternative 4 | |
|---|---|
| Accuracy | 86.2% |
| Cost | 972 |
| Alternative 5 | |
|---|---|
| Accuracy | 99.8% |
| Cost | 960 |
| Alternative 6 | |
|---|---|
| Accuracy | 45.0% |
| Cost | 849 |
| Alternative 7 | |
|---|---|
| Accuracy | 70.8% |
| Cost | 845 |
| Alternative 8 | |
|---|---|
| Accuracy | 85.5% |
| Cost | 841 |
| Alternative 9 | |
|---|---|
| Accuracy | 61.4% |
| Cost | 713 |
| Alternative 10 | |
|---|---|
| Accuracy | 78.4% |
| Cost | 713 |
| Alternative 11 | |
|---|---|
| Accuracy | 61.4% |
| Cost | 712 |
| Alternative 12 | |
|---|---|
| Accuracy | 47.4% |
| Cost | 456 |
| Alternative 13 | |
|---|---|
| Accuracy | 30.1% |
| Cost | 192 |
herbie shell --seed 2023245
(FPCore (x y z t)
:name "Graphics.Rendering.Plot.Render.Plot.Legend:renderLegendOutside from plot-0.2.3.4, B"
:precision binary64
(+ (* x (+ (+ (+ (+ y z) z) y) t)) (* y 5.0)))