Average Error: 16.1 → 0.0
Time: 768.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 r608777 = x;
        double r608778 = 1.0;
        double r608779 = r608778 - r608777;
        double r608780 = y;
        double r608781 = r608778 - r608780;
        double r608782 = r608779 * r608781;
        double r608783 = r608777 + r608782;
        return r608783;
}

double f(double x, double y) {
        double r608784 = y;
        double r608785 = x;
        double r608786 = 1.0;
        double r608787 = r608785 - r608786;
        double r608788 = fma(r608784, r608787, r608786);
        return r608788;
}

Error

Bits error versus x

Bits error versus y

Target

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

Derivation

  1. Initial program 16.1

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

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