Average Error: 16.3 → 0.0
Time: 9.4s
Precision: 64
\[x + \left(1 - x\right) \cdot \left(1 - y\right)\]
\[\mathsf{fma}\left(x, y, 1\right) - 1 \cdot y\]
x + \left(1 - x\right) \cdot \left(1 - y\right)
\mathsf{fma}\left(x, y, 1\right) - 1 \cdot y
double f(double x, double y) {
        double r392711 = x;
        double r392712 = 1.0;
        double r392713 = r392712 - r392711;
        double r392714 = y;
        double r392715 = r392712 - r392714;
        double r392716 = r392713 * r392715;
        double r392717 = r392711 + r392716;
        return r392717;
}

double f(double x, double y) {
        double r392718 = x;
        double r392719 = y;
        double r392720 = 1.0;
        double r392721 = fma(r392718, r392719, r392720);
        double r392722 = r392720 * r392719;
        double r392723 = r392721 - r392722;
        return r392723;
}

Error

Bits error versus x

Bits error versus y

Target

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

Derivation

  1. Initial program 16.3

    \[x + \left(1 - x\right) \cdot \left(1 - y\right)\]
  2. Taylor expanded around 0 0.0

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

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

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

Reproduce

herbie shell --seed 2019235 +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))))