Average Error: 0.0 → 0.0
Time: 10.5s
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 r37540938 = 1.0;
        double r37540939 = x;
        double r37540940 = r37540938 - r37540939;
        double r37540941 = y;
        double r37540942 = r37540940 * r37540941;
        double r37540943 = z;
        double r37540944 = r37540939 * r37540943;
        double r37540945 = r37540942 + r37540944;
        return r37540945;
}

double f(double x, double y, double z) {
        double r37540946 = y;
        double r37540947 = 1.0;
        double r37540948 = x;
        double r37540949 = -r37540946;
        double r37540950 = r37540948 * r37540949;
        double r37540951 = z;
        double r37540952 = r37540948 * r37540951;
        double r37540953 = r37540950 + r37540952;
        double r37540954 = fma(r37540946, r37540947, r37540953);
        return r37540954;
}

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