Average Error: 0.0 → 0.0
Time: 5.4s
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
Error21.4
Cost856
\[\begin{array}{l} \mathbf{if}\;x \leq -7.5 \cdot 10^{+179}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -3.9 \cdot 10^{+26}:\\ \;\;\;\;-y \cdot x\\ \mathbf{elif}\;x \leq -6 \cdot 10^{-47}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 10^{-120}:\\ \;\;\;\;y\\ \mathbf{elif}\;x \leq 2.1 \cdot 10^{-91}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 4.3 \cdot 10^{-10}:\\ \;\;\;\;y\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 2
Error10.6
Cost848
\[\begin{array}{l} t_0 := \left(1 - y\right) \cdot x\\ \mathbf{if}\;x \leq -5 \cdot 10^{-47}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 10^{-120}:\\ \;\;\;\;y\\ \mathbf{elif}\;x \leq 1.45 \cdot 10^{-91}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 4.6 \cdot 10^{-10}:\\ \;\;\;\;y \cdot \left(1 - x\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error19.8
Cost592
\[\begin{array}{l} \mathbf{if}\;x \leq -3.8 \cdot 10^{-48}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 10^{-120}:\\ \;\;\;\;y\\ \mathbf{elif}\;x \leq 1.55 \cdot 10^{-91}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 4.3 \cdot 10^{-10}:\\ \;\;\;\;y\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 4
Error9.6
Cost584
\[\begin{array}{l} t_0 := y \cdot \left(1 - x\right)\\ \mathbf{if}\;y \leq -1.75 \cdot 10^{-34}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 2.4 \cdot 10^{-7}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error0.0
Cost448
\[\left(x + y\right) - x \cdot y \]
Alternative 6
Error35.9
Cost64
\[x \]

Error

Reproduce

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