Average Error: 0.0 → 0.0
Time: 1.9s
Precision: 64
\[\left(x + y\right) - x \cdot y\]
\[\mathsf{fma}\left(1 - x, y, x\right)\]
\left(x + y\right) - x \cdot y
\mathsf{fma}\left(1 - x, y, x\right)
double f(double x, double y) {
        double r294667 = x;
        double r294668 = y;
        double r294669 = r294667 + r294668;
        double r294670 = r294667 * r294668;
        double r294671 = r294669 - r294670;
        return r294671;
}

double f(double x, double y) {
        double r294672 = 1.0;
        double r294673 = x;
        double r294674 = r294672 - r294673;
        double r294675 = y;
        double r294676 = fma(r294674, r294675, r294673);
        return r294676;
}

Error

Bits error versus x

Bits error versus y

Derivation

  1. Initial program 0.0

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(1 - x, y, x\right)}\]
  3. Final simplification0.0

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

Reproduce

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