| Alternative 1 | |
|---|---|
| Error | 15.53% |
| Cost | 585 |
\[\begin{array}{l}
\mathbf{if}\;y \leq -360000000000 \lor \neg \left(y \leq 1.65 \cdot 10^{-43}\right):\\
\;\;\;\;y \cdot \left(x + -1\right)\\
\mathbf{else}:\\
\;\;\;\;1 - y\\
\end{array}
\]
(FPCore (x y) :precision binary64 (+ x (* (- 1.0 x) (- 1.0 y))))
(FPCore (x y) :precision binary64 (fma y (+ x -1.0) 1.0))
double code(double x, double y) {
return x + ((1.0 - x) * (1.0 - y));
}
double code(double x, double y) {
return fma(y, (x + -1.0), 1.0);
}
function code(x, y) return Float64(x + Float64(Float64(1.0 - x) * Float64(1.0 - y))) end
function code(x, y) return fma(y, Float64(x + -1.0), 1.0) end
code[x_, y_] := N[(x + N[(N[(1.0 - x), $MachinePrecision] * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_] := N[(y * N[(x + -1.0), $MachinePrecision] + 1.0), $MachinePrecision]
x + \left(1 - x\right) \cdot \left(1 - y\right)
\mathsf{fma}\left(y, x + -1, 1\right)
| Original | 24.85% |
|---|---|
| Target | 0.01% |
| Herbie | 0.01% |
Initial program 24.85
Simplified0.01
[Start]24.85 | \[ x + \left(1 - x\right) \cdot \left(1 - y\right)
\] |
|---|---|
+-commutative [=>]24.85 | \[ \color{blue}{\left(1 - x\right) \cdot \left(1 - y\right) + x}
\] |
sub-neg [=>]24.85 | \[ \left(1 - x\right) \cdot \color{blue}{\left(1 + \left(-y\right)\right)} + x
\] |
distribute-rgt-in [=>]24.84 | \[ \color{blue}{\left(1 \cdot \left(1 - x\right) + \left(-y\right) \cdot \left(1 - x\right)\right)} + x
\] |
+-commutative [=>]24.84 | \[ \color{blue}{\left(\left(-y\right) \cdot \left(1 - x\right) + 1 \cdot \left(1 - x\right)\right)} + x
\] |
sub-neg [=>]24.84 | \[ \left(\left(-y\right) \cdot \left(1 - x\right) + 1 \cdot \color{blue}{\left(1 + \left(-x\right)\right)}\right) + x
\] |
distribute-lft-in [=>]24.84 | \[ \left(\left(-y\right) \cdot \left(1 - x\right) + \color{blue}{\left(1 \cdot 1 + 1 \cdot \left(-x\right)\right)}\right) + x
\] |
metadata-eval [=>]24.84 | \[ \left(\left(-y\right) \cdot \left(1 - x\right) + \left(\color{blue}{1} + 1 \cdot \left(-x\right)\right)\right) + x
\] |
associate-+r+ [=>]24.84 | \[ \color{blue}{\left(\left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) + 1 \cdot \left(-x\right)\right)} + x
\] |
associate-+l+ [=>]0.01 | \[ \color{blue}{\left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) + \left(1 \cdot \left(-x\right) + x\right)}
\] |
neg-mul-1 [=>]0.01 | \[ \left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) + \left(1 \cdot \color{blue}{\left(-1 \cdot x\right)} + x\right)
\] |
associate-*r* [=>]0.01 | \[ \left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) + \left(\color{blue}{\left(1 \cdot -1\right) \cdot x} + x\right)
\] |
metadata-eval [=>]0.01 | \[ \left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) + \left(\color{blue}{-1} \cdot x + x\right)
\] |
distribute-lft1-in [=>]0.01 | \[ \left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) + \color{blue}{\left(-1 + 1\right) \cdot x}
\] |
metadata-eval [=>]0.01 | \[ \left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) + \color{blue}{0} \cdot x
\] |
metadata-eval [<=]0.01 | \[ \left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) + \color{blue}{\left(0 \cdot -1\right)} \cdot x
\] |
associate-*r* [<=]0.01 | \[ \left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) + \color{blue}{0 \cdot \left(-1 \cdot x\right)}
\] |
metadata-eval [<=]0.01 | \[ \left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) + 0 \cdot \left(\color{blue}{\left(1 \cdot -1\right)} \cdot x\right)
\] |
associate-*r* [<=]0.01 | \[ \left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) + 0 \cdot \color{blue}{\left(1 \cdot \left(-1 \cdot x\right)\right)}
\] |
neg-mul-1 [<=]0.01 | \[ \left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) + 0 \cdot \left(1 \cdot \color{blue}{\left(-x\right)}\right)
\] |
mul0-lft [=>]0.01 | \[ \left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) + \color{blue}{0}
\] |
Final simplification0.01
| Alternative 1 | |
|---|---|
| Error | 15.53% |
| Cost | 585 |
| Alternative 2 | |
|---|---|
| Error | 43.35% |
| Cost | 456 |
| Alternative 3 | |
|---|---|
| Error | 15.25% |
| Cost | 456 |
| Alternative 4 | |
|---|---|
| Error | 0.01% |
| Cost | 448 |
| Alternative 5 | |
|---|---|
| Error | 57.1% |
| Cost | 64 |
herbie shell --seed 2023090
(FPCore (x y)
:name "Graphics.Rendering.Chart.Plot.Vectors:renderPlotVectors from Chart-1.5.3"
:precision binary64
:herbie-target
(- (* y x) (- y 1.0))
(+ x (* (- 1.0 x) (- 1.0 y))))