Average Error: 0.0 → 0.0
Time: 12.1s
Precision: 64
\[\left(1.0 - x\right) \cdot y + x \cdot z\]
\[\mathsf{fma}\left(1.0 - x, y, x \cdot z\right)\]
\left(1.0 - x\right) \cdot y + x \cdot z
\mathsf{fma}\left(1.0 - x, y, x \cdot z\right)
double f(double x, double y, double z) {
        double r34343228 = 1.0;
        double r34343229 = x;
        double r34343230 = r34343228 - r34343229;
        double r34343231 = y;
        double r34343232 = r34343230 * r34343231;
        double r34343233 = z;
        double r34343234 = r34343229 * r34343233;
        double r34343235 = r34343232 + r34343234;
        return r34343235;
}

double f(double x, double y, double z) {
        double r34343236 = 1.0;
        double r34343237 = x;
        double r34343238 = r34343236 - r34343237;
        double r34343239 = y;
        double r34343240 = z;
        double r34343241 = r34343237 * r34343240;
        double r34343242 = fma(r34343238, r34343239, r34343241);
        return r34343242;
}

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. Taylor expanded around 0 0.0

    \[\leadsto \color{blue}{\left(1.0 \cdot y + x \cdot z\right) - x \cdot y}\]
  3. Simplified0.0

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, z, y \cdot \left(1.0 - x\right)\right)}\]
  4. Taylor expanded around 0 0.0

    \[\leadsto \color{blue}{\left(x \cdot z + 1.0 \cdot y\right) - x \cdot y}\]
  5. Simplified0.0

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

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

Reproduce

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