Average Error: 16.1 → 0.0
Time: 731.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 r620800 = x;
        double r620801 = 1.0;
        double r620802 = r620801 - r620800;
        double r620803 = y;
        double r620804 = r620801 - r620803;
        double r620805 = r620802 * r620804;
        double r620806 = r620800 + r620805;
        return r620806;
}

double f(double x, double y) {
        double r620807 = y;
        double r620808 = x;
        double r620809 = 1.0;
        double r620810 = r620808 - r620809;
        double r620811 = fma(r620807, r620810, r620809);
        return r620811;
}

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 2020020 +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))))