Average Error: 0.0 → 0.0
Time: 11.3s
Precision: 64
\[\left(1.0 - x\right) \cdot y + x \cdot z\]
\[\mathsf{fma}\left(y, 1.0, x \cdot \left(-y\right) + x \cdot z\right)\]
\left(1.0 - x\right) \cdot y + x \cdot z
\mathsf{fma}\left(y, 1.0, x \cdot \left(-y\right) + x \cdot z\right)
double f(double x, double y, double z) {
        double r32604501 = 1.0;
        double r32604502 = x;
        double r32604503 = r32604501 - r32604502;
        double r32604504 = y;
        double r32604505 = r32604503 * r32604504;
        double r32604506 = z;
        double r32604507 = r32604502 * r32604506;
        double r32604508 = r32604505 + r32604507;
        return r32604508;
}

double f(double x, double y, double z) {
        double r32604509 = y;
        double r32604510 = 1.0;
        double r32604511 = x;
        double r32604512 = -r32604509;
        double r32604513 = r32604511 * r32604512;
        double r32604514 = z;
        double r32604515 = r32604511 * r32604514;
        double r32604516 = r32604513 + r32604515;
        double r32604517 = fma(r32604509, r32604510, r32604516);
        return r32604517;
}

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. Simplified0.0

    \[\leadsto \color{blue}{\mathsf{fma}\left(y, 1.0, x \cdot \left(z - y\right)\right)}\]
  3. Using strategy rm
  4. Applied sub-neg0.0

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

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

    \[\leadsto \mathsf{fma}\left(y, 1.0, x \cdot \left(-y\right) + x \cdot z\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)))