Average Error: 0.0 → 0.0
Time: 20.5s
Precision: 64
\[\left(1 - x\right) \cdot y + x \cdot z\]
\[\mathsf{fma}\left(y, 1, x \cdot \left(-y\right) + z \cdot x\right)\]
\left(1 - x\right) \cdot y + x \cdot z
\mathsf{fma}\left(y, 1, x \cdot \left(-y\right) + z \cdot x\right)
double f(double x, double y, double z) {
        double r30821315 = 1.0;
        double r30821316 = x;
        double r30821317 = r30821315 - r30821316;
        double r30821318 = y;
        double r30821319 = r30821317 * r30821318;
        double r30821320 = z;
        double r30821321 = r30821316 * r30821320;
        double r30821322 = r30821319 + r30821321;
        return r30821322;
}

double f(double x, double y, double z) {
        double r30821323 = y;
        double r30821324 = 1.0;
        double r30821325 = x;
        double r30821326 = -r30821323;
        double r30821327 = r30821325 * r30821326;
        double r30821328 = z;
        double r30821329 = r30821328 * r30821325;
        double r30821330 = r30821327 + r30821329;
        double r30821331 = fma(r30821323, r30821324, r30821330);
        return r30821331;
}

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(y, 1, x \cdot \left(z - y\right)\right)}\]
  3. Using strategy rm
  4. Applied sub-neg0.0

    \[\leadsto \mathsf{fma}\left(y, 1, x \cdot \color{blue}{\left(z + \left(-y\right)\right)}\right)\]
  5. Applied distribute-rgt-in0.0

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

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

Reproduce

herbie shell --seed 2019168 +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)))