Average Error: 16.6 → 0.0
Time: 890.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 r631377 = x;
        double r631378 = 1.0;
        double r631379 = r631378 - r631377;
        double r631380 = y;
        double r631381 = r631378 - r631380;
        double r631382 = r631379 * r631381;
        double r631383 = r631377 + r631382;
        return r631383;
}

double f(double x, double y) {
        double r631384 = y;
        double r631385 = x;
        double r631386 = 1.0;
        double r631387 = r631385 - r631386;
        double r631388 = fma(r631384, r631387, r631386);
        return r631388;
}

Error

Bits error versus x

Bits error versus y

Target

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

Derivation

  1. Initial program 16.6

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

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