?

Average Error: 0.0 → 0.0
Time: 29.0s
Precision: binary64
Cost: 6720

?

\[\left(x + y\right) - x \cdot y \]
\[\mathsf{fma}\left(y, 1 - x, x\right) \]
(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)

Error?

Derivation?

  1. Initial program 0.0

    \[\left(x + y\right) - x \cdot y \]
  2. Simplified0.0

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

Alternatives

Alternative 1
Error18.3
Cost592
\[\begin{array}{l} \mathbf{if}\;x \leq -1.9 \cdot 10^{+83}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -7.9 \cdot 10^{+15}:\\ \;\;\;\;-y \cdot x\\ \mathbf{elif}\;x \leq -1.02 \cdot 10^{-5}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.6 \cdot 10^{-27}:\\ \;\;\;\;y\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 2
Error9.8
Cost584
\[\begin{array}{l} t_0 := y \cdot \left(1 - x\right)\\ \mathbf{if}\;y \leq -1.16 \cdot 10^{-31}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 2.1 \cdot 10^{-26}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error9.2
Cost584
\[\begin{array}{l} t_0 := \left(1 - y\right) \cdot x\\ \mathbf{if}\;x \leq -0.00074:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1.32 \cdot 10^{-27}:\\ \;\;\;\;y \cdot \left(1 - x\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error9.2
Cost584
\[\begin{array}{l} t_0 := \left(1 - y\right) \cdot x\\ \mathbf{if}\;x \leq -1.35 \cdot 10^{-5}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1.2 \cdot 10^{-27}:\\ \;\;\;\;y - y \cdot x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error0.0
Cost448
\[\left(x + y\right) - x \cdot y \]
Alternative 6
Error17.9
Cost328
\[\begin{array}{l} \mathbf{if}\;x \leq -1.02 \cdot 10^{-5}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.75 \cdot 10^{-27}:\\ \;\;\;\;y\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 7
Error35.8
Cost64
\[x \]

Error

Reproduce?

herbie shell --seed 2023033 
(FPCore (x y)
  :name "Data.Colour.RGBSpace.HSL:hsl from colour-2.3.3, A"
  :precision binary64
  (- (+ x y) (* x y)))