Average Error: 0.0 → 0.0
Time: 17.6s
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 r549059 = 1.0;
        double r549060 = x;
        double r549061 = r549059 - r549060;
        double r549062 = y;
        double r549063 = r549061 * r549062;
        double r549064 = z;
        double r549065 = r549060 * r549064;
        double r549066 = r549063 + r549065;
        return r549066;
}

double f(double x, double y, double z) {
        double r549067 = z;
        double r549068 = x;
        double r549069 = 1.0;
        double r549070 = r549069 - r549068;
        double r549071 = y;
        double r549072 = r549070 * r549071;
        double r549073 = fma(r549067, r549068, r549072);
        return r549073;
}

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