| Alternative 1 | |
|---|---|
| Accuracy | 74.8% |
| Cost | 585 |
\[\begin{array}{l}
\mathbf{if}\;z \leq -1.66 \cdot 10^{-112} \lor \neg \left(z \leq 5.5 \cdot 10^{-83}\right):\\
\;\;\;\;z \cdot \left(1 - x\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}
\]
(FPCore (x y z) :precision binary64 (+ (* x y) (* (- 1.0 x) z)))
(FPCore (x y z) :precision binary64 (fma x (- y z) z))
double code(double x, double y, double z) {
return (x * y) + ((1.0 - x) * z);
}
double code(double x, double y, double z) {
return fma(x, (y - z), z);
}
function code(x, y, z) return Float64(Float64(x * y) + Float64(Float64(1.0 - x) * z)) end
function code(x, y, z) return fma(x, Float64(y - z), z) end
code[x_, y_, z_] := N[(N[(x * y), $MachinePrecision] + N[(N[(1.0 - x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := N[(x * N[(y - z), $MachinePrecision] + z), $MachinePrecision]
x \cdot y + \left(1 - x\right) \cdot z
\mathsf{fma}\left(x, y - z, z\right)
Initial program 100.0%
Simplified100.0%
[Start]100.0 | \[ x \cdot y + \left(1 - x\right) \cdot z
\] |
|---|---|
+-commutative [=>]100.0 | \[ \color{blue}{\left(1 - x\right) \cdot z + x \cdot y}
\] |
*-commutative [=>]100.0 | \[ \color{blue}{z \cdot \left(1 - x\right)} + x \cdot y
\] |
sub-neg [=>]100.0 | \[ z \cdot \color{blue}{\left(1 + \left(-x\right)\right)} + x \cdot y
\] |
distribute-rgt-in [=>]100.0 | \[ \color{blue}{\left(1 \cdot z + \left(-x\right) \cdot z\right)} + x \cdot y
\] |
associate-+l+ [=>]100.0 | \[ \color{blue}{1 \cdot z + \left(\left(-x\right) \cdot z + x \cdot y\right)}
\] |
*-lft-identity [=>]100.0 | \[ \color{blue}{z} + \left(\left(-x\right) \cdot z + x \cdot y\right)
\] |
+-commutative [=>]100.0 | \[ \color{blue}{\left(\left(-x\right) \cdot z + x \cdot y\right) + z}
\] |
*-commutative [=>]100.0 | \[ \left(\color{blue}{z \cdot \left(-x\right)} + x \cdot y\right) + z
\] |
neg-mul-1 [=>]100.0 | \[ \left(z \cdot \color{blue}{\left(-1 \cdot x\right)} + x \cdot y\right) + z
\] |
associate-*r* [=>]100.0 | \[ \left(\color{blue}{\left(z \cdot -1\right) \cdot x} + x \cdot y\right) + z
\] |
*-commutative [=>]100.0 | \[ \left(\left(z \cdot -1\right) \cdot x + \color{blue}{y \cdot x}\right) + z
\] |
distribute-rgt-out [=>]100.0 | \[ \color{blue}{x \cdot \left(z \cdot -1 + y\right)} + z
\] |
fma-def [=>]100.0 | \[ \color{blue}{\mathsf{fma}\left(x, z \cdot -1 + y, z\right)}
\] |
+-commutative [=>]100.0 | \[ \mathsf{fma}\left(x, \color{blue}{y + z \cdot -1}, z\right)
\] |
*-commutative [=>]100.0 | \[ \mathsf{fma}\left(x, y + \color{blue}{-1 \cdot z}, z\right)
\] |
metadata-eval [<=]100.0 | \[ \mathsf{fma}\left(x, y + \color{blue}{\left(-1\right)} \cdot z, z\right)
\] |
cancel-sign-sub-inv [<=]100.0 | \[ \mathsf{fma}\left(x, \color{blue}{y - 1 \cdot z}, z\right)
\] |
*-lft-identity [=>]100.0 | \[ \mathsf{fma}\left(x, y - \color{blue}{z}, z\right)
\] |
Final simplification100.0%
| Alternative 1 | |
|---|---|
| Accuracy | 74.8% |
| Cost | 585 |
| Alternative 2 | |
|---|---|
| Accuracy | 79.3% |
| Cost | 585 |
| Alternative 3 | |
|---|---|
| Accuracy | 98.6% |
| Cost | 585 |
| Alternative 4 | |
|---|---|
| Accuracy | 61.0% |
| Cost | 456 |
| Alternative 5 | |
|---|---|
| Accuracy | 100.0% |
| Cost | 448 |
| Alternative 6 | |
|---|---|
| Accuracy | 45.1% |
| Cost | 64 |
herbie shell --seed 2023135
(FPCore (x y z)
:name "Diagrams.Backend.Rasterific:$crender from diagrams-rasterific-1.3.1.3"
:precision binary64
(+ (* x y) (* (- 1.0 x) z)))