Average Error: 15.5 → 0.0
Time: 792.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 r588572 = x;
        double r588573 = 1.0;
        double r588574 = r588573 - r588572;
        double r588575 = y;
        double r588576 = r588573 - r588575;
        double r588577 = r588574 * r588576;
        double r588578 = r588572 + r588577;
        return r588578;
}

double f(double x, double y) {
        double r588579 = y;
        double r588580 = x;
        double r588581 = 1.0;
        double r588582 = r588580 - r588581;
        double r588583 = fma(r588579, r588582, r588581);
        return r588583;
}

Error

Bits error versus x

Bits error versus y

Target

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

Derivation

  1. Initial program 15.5

    \[x + \left(1 - x\right) \cdot \left(1 - y\right)\]
  2. Simplified15.5

    \[\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 2020056 +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))))