Average Error: 0.0 → 0.0
Time: 13.5s
Precision: 64
\[\left(1.0 - x\right) \cdot y + x \cdot z\]
\[\mathsf{fma}\left(x, z, \left(1.0 - x\right) \cdot y\right)\]
\left(1.0 - x\right) \cdot y + x \cdot z
\mathsf{fma}\left(x, z, \left(1.0 - x\right) \cdot y\right)
double f(double x, double y, double z) {
        double r35121753 = 1.0;
        double r35121754 = x;
        double r35121755 = r35121753 - r35121754;
        double r35121756 = y;
        double r35121757 = r35121755 * r35121756;
        double r35121758 = z;
        double r35121759 = r35121754 * r35121758;
        double r35121760 = r35121757 + r35121759;
        return r35121760;
}

double f(double x, double y, double z) {
        double r35121761 = x;
        double r35121762 = z;
        double r35121763 = 1.0;
        double r35121764 = r35121763 - r35121761;
        double r35121765 = y;
        double r35121766 = r35121764 * r35121765;
        double r35121767 = fma(r35121761, r35121762, r35121766);
        return r35121767;
}

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.0 - x\right) \cdot y + x \cdot z\]
  2. Taylor expanded around 0 0.0

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

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

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

Reproduce

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

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

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