Average Error: 0.0 → 0.0
Time: 6.7s
Precision: 64
\[\left(1.0 - x\right) \cdot y + x \cdot z\]
\[\mathsf{fma}\left(x, z, y \cdot \left(-x\right) + 1.0 \cdot y\right)\]
\left(1.0 - x\right) \cdot y + x \cdot z
\mathsf{fma}\left(x, z, y \cdot \left(-x\right) + 1.0 \cdot y\right)
double f(double x, double y, double z) {
        double r15172222 = 1.0;
        double r15172223 = x;
        double r15172224 = r15172222 - r15172223;
        double r15172225 = y;
        double r15172226 = r15172224 * r15172225;
        double r15172227 = z;
        double r15172228 = r15172223 * r15172227;
        double r15172229 = r15172226 + r15172228;
        return r15172229;
}

double f(double x, double y, double z) {
        double r15172230 = x;
        double r15172231 = z;
        double r15172232 = y;
        double r15172233 = -r15172230;
        double r15172234 = r15172232 * r15172233;
        double r15172235 = 1.0;
        double r15172236 = r15172235 * r15172232;
        double r15172237 = r15172234 + r15172236;
        double r15172238 = fma(r15172230, r15172231, r15172237);
        return r15172238;
}

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

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

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

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

Reproduce

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