Average Error: 0.0 → 0.0
Time: 8.5s
Precision: 64
\[\left(1 - x\right) \cdot y + x \cdot z\]
\[\mathsf{fma}\left(z, x, \left(1 - x\right) \cdot y\right)\]
\left(1 - x\right) \cdot y + x \cdot z
\mathsf{fma}\left(z, x, \left(1 - x\right) \cdot y\right)
double f(double x, double y, double z) {
        double r460369 = 1.0;
        double r460370 = x;
        double r460371 = r460369 - r460370;
        double r460372 = y;
        double r460373 = r460371 * r460372;
        double r460374 = z;
        double r460375 = r460370 * r460374;
        double r460376 = r460373 + r460375;
        return r460376;
}

double f(double x, double y, double z) {
        double r460377 = z;
        double r460378 = x;
        double r460379 = 1.0;
        double r460380 = r460379 - r460378;
        double r460381 = y;
        double r460382 = r460380 * r460381;
        double r460383 = fma(r460377, r460378, r460382);
        return r460383;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original0.0
Target0.0
Herbie0.0
\[y - x \cdot \left(y - z\right)\]

Derivation

  1. Initial program 0.0

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(1 - x, y, x \cdot z\right)}\]
  3. Taylor expanded around 0 0.0

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

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

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

Reproduce

herbie shell --seed 2019303 +o rules:numerics
(FPCore (x y z)
  :name "Diagrams.Color.HSV:lerp  from diagrams-contrib-1.3.0.5"
  :precision binary64

  :herbie-target
  (- y (* x (- y z)))

  (+ (* (- 1 x) y) (* x z)))