?

Average Accuracy: 74.8% → 100.0%
Time: 4.3s
Precision: binary64
Cost: 6720

?

\[x + \left(1 - x\right) \cdot \left(1 - y\right) \]
\[\mathsf{fma}\left(x, y, 1\right) - y \]
(FPCore (x y) :precision binary64 (+ x (* (- 1.0 x) (- 1.0 y))))
(FPCore (x y) :precision binary64 (- (fma x y 1.0) y))
double code(double x, double y) {
	return x + ((1.0 - x) * (1.0 - y));
}
double code(double x, double y) {
	return fma(x, y, 1.0) - y;
}
function code(x, y)
	return Float64(x + Float64(Float64(1.0 - x) * Float64(1.0 - y)))
end
function code(x, y)
	return Float64(fma(x, y, 1.0) - y)
end
code[x_, y_] := N[(x + N[(N[(1.0 - x), $MachinePrecision] * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_] := N[(N[(x * y + 1.0), $MachinePrecision] - y), $MachinePrecision]
x + \left(1 - x\right) \cdot \left(1 - y\right)
\mathsf{fma}\left(x, y, 1\right) - y

Error?

Target

Original74.8%
Target100.0%
Herbie100.0%
\[y \cdot x - \left(y - 1\right) \]

Derivation?

  1. Initial program 74.8%

    \[x + \left(1 - x\right) \cdot \left(1 - y\right) \]
  2. Simplified100.0%

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, y, 1\right) - y} \]
    Proof

    [Start]74.8

    \[ x + \left(1 - x\right) \cdot \left(1 - y\right) \]

    *-commutative [=>]74.8

    \[ x + \color{blue}{\left(1 - y\right) \cdot \left(1 - x\right)} \]

    sub-neg [=>]74.8

    \[ x + \left(1 - y\right) \cdot \color{blue}{\left(1 + \left(-x\right)\right)} \]

    distribute-rgt-in [=>]74.8

    \[ x + \color{blue}{\left(1 \cdot \left(1 - y\right) + \left(-x\right) \cdot \left(1 - y\right)\right)} \]

    associate-+r+ [=>]74.8

    \[ \color{blue}{\left(x + 1 \cdot \left(1 - y\right)\right) + \left(-x\right) \cdot \left(1 - y\right)} \]

    +-commutative [=>]74.8

    \[ \color{blue}{\left(-x\right) \cdot \left(1 - y\right) + \left(x + 1 \cdot \left(1 - y\right)\right)} \]

    *-lft-identity [=>]74.8

    \[ \left(-x\right) \cdot \left(1 - y\right) + \left(x + \color{blue}{\left(1 - y\right)}\right) \]

    associate-+r+ [=>]86.6

    \[ \color{blue}{\left(\left(-x\right) \cdot \left(1 - y\right) + x\right) + \left(1 - y\right)} \]

    associate-+r- [=>]86.6

    \[ \color{blue}{\left(\left(\left(-x\right) \cdot \left(1 - y\right) + x\right) + 1\right) - y} \]
  3. Final simplification100.0%

    \[\leadsto \mathsf{fma}\left(x, y, 1\right) - y \]

Alternatives

Alternative 1
Accuracy70.5%
Cost720
\[\begin{array}{l} \mathbf{if}\;y \leq -4.9 \cdot 10^{+14}:\\ \;\;\;\;-y\\ \mathbf{elif}\;y \leq -1.66 \cdot 10^{-31}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;y \leq 5.5 \cdot 10^{-78}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 1.6 \cdot 10^{+40}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;-y\\ \end{array} \]
Alternative 2
Accuracy84.1%
Cost585
\[\begin{array}{l} \mathbf{if}\;y \leq -4 \cdot 10^{-35} \lor \neg \left(y \leq 6.4 \cdot 10^{-78}\right):\\ \;\;\;\;y \cdot \left(x + -1\right)\\ \mathbf{else}:\\ \;\;\;\;1 - y\\ \end{array} \]
Alternative 3
Accuracy84.1%
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -4.6 \cdot 10^{-35}:\\ \;\;\;\;x \cdot y - y\\ \mathbf{elif}\;y \leq 6.4 \cdot 10^{-78}:\\ \;\;\;\;1 - y\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(x + -1\right)\\ \end{array} \]
Alternative 4
Accuracy85.5%
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -1.85 \cdot 10^{+18}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;x \leq 4.2 \cdot 10^{+40}:\\ \;\;\;\;1 - y\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 5
Accuracy100.0%
Cost448
\[\left(1 + x \cdot y\right) - y \]
Alternative 6
Accuracy70.4%
Cost392
\[\begin{array}{l} \mathbf{if}\;y \leq -0.245:\\ \;\;\;\;-y\\ \mathbf{elif}\;y \leq 6.2 \cdot 10^{-10}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-y\\ \end{array} \]
Alternative 7
Accuracy43.8%
Cost64
\[1 \]

Error

Reproduce?

herbie shell --seed 2023137 
(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))))