The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.
Herbie found 11 alternatives:
Alternative
Accuracy
Speedup
Accuracy vs Speed
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.
\[\left(x \cdot y + z \cdot t\right) + a \cdot b
\]
Simplified99.2%
\[\leadsto \color{blue}{\mathsf{fma}\left(x, y, \mathsf{fma}\left(z, t, a \cdot b\right)\right)}
\]
Step-by-step derivation
[Start]97.2%
\[ \left(x \cdot y + z \cdot t\right) + a \cdot b
\]
associate-+l+ [=>]97.2%
\[ \color{blue}{x \cdot y + \left(z \cdot t + a \cdot b\right)}
\]
fma-def [=>]98.4%
\[ \color{blue}{\mathsf{fma}\left(x, y, z \cdot t + a \cdot b\right)}
\]
fma-def [=>]99.2%
\[ \mathsf{fma}\left(x, y, \color{blue}{\mathsf{fma}\left(z, t, a \cdot b\right)}\right)
\]
Final simplification99.2%
\[\leadsto \mathsf{fma}\left(x, y, \mathsf{fma}\left(z, t, a \cdot b\right)\right)
\]
Alternatives
Alternative 1
Accuracy
98.6%
Cost
13248
\[\mathsf{fma}\left(x, y, \mathsf{fma}\left(z, t, a \cdot b\right)\right)
\]
Alternative 2
Accuracy
98.6%
Cost
7492
\[\begin{array}{l}
t_1 := a \cdot b + \left(z \cdot t + x \cdot y\right)\\
\mathbf{if}\;t_1 \leq \infty:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t, z, a \cdot b\right)\\
\end{array}
\]
Alternative 3
Accuracy
97.9%
Cost
6976
\[a \cdot b + \mathsf{fma}\left(x, y, z \cdot t\right)
\]
Alternative 4
Accuracy
98.0%
Cost
6976
\[\mathsf{fma}\left(z, t, a \cdot b\right) + x \cdot y
\]
Alternative 5
Accuracy
83.2%
Cost
968
\[\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -3.8 \cdot 10^{+103}:\\
\;\;\;\;a \cdot b + z \cdot t\\
\mathbf{elif}\;a \cdot b \leq 1.55 \cdot 10^{-83}:\\
\;\;\;\;z \cdot t + x \cdot y\\
\mathbf{else}:\\
\;\;\;\;a \cdot b + x \cdot y\\
\end{array}
\]
Alternative 6
Accuracy
78.4%
Cost
713
\[\begin{array}{l}
\mathbf{if}\;z \leq -1.35 \cdot 10^{+127} \lor \neg \left(z \leq 4.1 \cdot 10^{-19}\right):\\
\;\;\;\;a \cdot b + z \cdot t\\
\mathbf{else}:\\
\;\;\;\;a \cdot b + x \cdot y\\
\end{array}
\]