Average Error: 0.0 → 0.0
Time: 6.0s
Precision: 64
\[\left(1.0 - x\right) \cdot y + x \cdot z\]
\[\mathsf{fma}\left(x, z - y, 1.0 \cdot y\right)\]
\left(1.0 - x\right) \cdot y + x \cdot z
\mathsf{fma}\left(x, z - y, 1.0 \cdot y\right)
double f(double x, double y, double z) {
        double r37113449 = 1.0;
        double r37113450 = x;
        double r37113451 = r37113449 - r37113450;
        double r37113452 = y;
        double r37113453 = r37113451 * r37113452;
        double r37113454 = z;
        double r37113455 = r37113450 * r37113454;
        double r37113456 = r37113453 + r37113455;
        return r37113456;
}

double f(double x, double y, double z) {
        double r37113457 = x;
        double r37113458 = z;
        double r37113459 = y;
        double r37113460 = r37113458 - r37113459;
        double r37113461 = 1.0;
        double r37113462 = r37113461 * r37113459;
        double r37113463 = fma(r37113457, r37113460, r37113462);
        return r37113463;
}

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

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

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

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

Reproduce

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