Average Error: 17.0 → 0.0
Time: 931.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 r646095 = x;
        double r646096 = 1.0;
        double r646097 = r646096 - r646095;
        double r646098 = y;
        double r646099 = r646096 - r646098;
        double r646100 = r646097 * r646099;
        double r646101 = r646095 + r646100;
        return r646101;
}

double f(double x, double y) {
        double r646102 = y;
        double r646103 = x;
        double r646104 = 1.0;
        double r646105 = r646103 - r646104;
        double r646106 = fma(r646102, r646105, r646104);
        return r646106;
}

Error

Bits error versus x

Bits error versus y

Target

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

Derivation

  1. Initial program 17.0

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

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