Average Error: 0.0 → 0.0
Time: 9.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 r593991 = 1.0;
        double r593992 = x;
        double r593993 = r593991 - r593992;
        double r593994 = y;
        double r593995 = r593993 * r593994;
        double r593996 = z;
        double r593997 = r593992 * r593996;
        double r593998 = r593995 + r593997;
        return r593998;
}

double f(double x, double y, double z) {
        double r593999 = z;
        double r594000 = x;
        double r594001 = 1.0;
        double r594002 = r594001 - r594000;
        double r594003 = y;
        double r594004 = r594002 * r594003;
        double r594005 = fma(r593999, r594000, r594004);
        return r594005;
}

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