Average Error: 16.8 → 0.0
Time: 778.0ms
Precision: 64
\[x + \left(1 - x\right) \cdot \left(1 - y\right)\]
\[\mathsf{fma}\left(y, x - 1, 1\right)\]
x + \left(1 - x\right) \cdot \left(1 - y\right)
\mathsf{fma}\left(y, x - 1, 1\right)
double f(double x, double y) {
        double r593016 = x;
        double r593017 = 1.0;
        double r593018 = r593017 - r593016;
        double r593019 = y;
        double r593020 = r593017 - r593019;
        double r593021 = r593018 * r593020;
        double r593022 = r593016 + r593021;
        return r593022;
}

double f(double x, double y) {
        double r593023 = y;
        double r593024 = x;
        double r593025 = 1.0;
        double r593026 = r593024 - r593025;
        double r593027 = fma(r593023, r593026, r593025);
        return r593027;
}

Error

Bits error versus x

Bits error versus y

Target

Original16.8
Target0.0
Herbie0.0
\[y \cdot x - \left(y - 1\right)\]

Derivation

  1. Initial program 16.8

    \[x + \left(1 - x\right) \cdot \left(1 - y\right)\]
  2. Simplified16.8

    \[\leadsto \color{blue}{\mathsf{fma}\left(1 - y, 1 - x, x\right)}\]
  3. Taylor expanded around 0 0.0

    \[\leadsto \color{blue}{\left(x \cdot y + 1\right) - 1 \cdot y}\]
  4. Simplified0.0

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

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

Reproduce

herbie shell --seed 2020018 +o rules:numerics
(FPCore (x y)
  :name "Graphics.Rendering.Chart.Plot.Vectors:renderPlotVectors from Chart-1.5.3"
  :precision binary64

  :herbie-target
  (- (* y x) (- y 1))

  (+ x (* (- 1 x) (- 1 y))))