| Alternative 1 | |
|---|---|
| Error | 8.2 |
| Cost | 584 |
\[\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;y \cdot \left(-x\right)\\
\mathbf{elif}\;y \leq 10^{-121}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(1 - x\right)\\
\end{array}
\]
(FPCore (x y) :precision binary64 (- (+ x y) (* x y)))
(FPCore (x y) :precision binary64 (fma y (- 1.0 x) x))
double code(double x, double y) {
return (x + y) - (x * y);
}
double code(double x, double y) {
return fma(y, (1.0 - x), x);
}
function code(x, y) return Float64(Float64(x + y) - Float64(x * y)) end
function code(x, y) return fma(y, Float64(1.0 - x), x) end
code[x_, y_] := N[(N[(x + y), $MachinePrecision] - N[(x * y), $MachinePrecision]), $MachinePrecision]
code[x_, y_] := N[(y * N[(1.0 - x), $MachinePrecision] + x), $MachinePrecision]
\left(x + y\right) - x \cdot y
\mathsf{fma}\left(y, 1 - x, x\right)
Initial program 0.0
Simplified0.0
[Start]0.0 | \[ \left(x + y\right) - x \cdot y
\] |
|---|---|
associate--l+ [=>]0.0 | \[ \color{blue}{x + \left(y - x \cdot y\right)}
\] |
+-commutative [=>]0.0 | \[ \color{blue}{\left(y - x \cdot y\right) + x}
\] |
cancel-sign-sub-inv [=>]0.0 | \[ \color{blue}{\left(y + \left(-x\right) \cdot y\right)} + x
\] |
distribute-rgt1-in [=>]0.0 | \[ \color{blue}{\left(\left(-x\right) + 1\right) \cdot y} + x
\] |
*-commutative [=>]0.0 | \[ \color{blue}{y \cdot \left(\left(-x\right) + 1\right)} + x
\] |
fma-def [=>]0.0 | \[ \color{blue}{\mathsf{fma}\left(y, \left(-x\right) + 1, x\right)}
\] |
+-commutative [=>]0.0 | \[ \mathsf{fma}\left(y, \color{blue}{1 + \left(-x\right)}, x\right)
\] |
unsub-neg [=>]0.0 | \[ \mathsf{fma}\left(y, \color{blue}{1 - x}, x\right)
\] |
Final simplification0.0
| Alternative 1 | |
|---|---|
| Error | 8.2 |
| Cost | 584 |
| Alternative 2 | |
|---|---|
| Error | 16.2 |
| Cost | 520 |
| Alternative 3 | |
|---|---|
| Error | 8.7 |
| Cost | 452 |
| Alternative 4 | |
|---|---|
| Error | 0.0 |
| Cost | 448 |
| Alternative 5 | |
|---|---|
| Error | 18.2 |
| Cost | 196 |
| Alternative 6 | |
|---|---|
| Error | 36.8 |
| Cost | 64 |
herbie shell --seed 2023027
(FPCore (x y)
:name "Data.Colour.RGBSpace.HSL:hsl from colour-2.3.3, A"
:precision binary64
(- (+ x y) (* x y)))