Average Error: 0.0 → 0.0
Time: 8.1s
Precision: 64
\[\left(1 - x\right) \cdot y + x \cdot z\]
\[\mathsf{fma}\left(z, x, \left(1 - x\right) \cdot y\right)\]
\left(1 - x\right) \cdot y + x \cdot z
\mathsf{fma}\left(z, x, \left(1 - x\right) \cdot y\right)
double f(double x, double y, double z) {
        double r491783 = 1.0;
        double r491784 = x;
        double r491785 = r491783 - r491784;
        double r491786 = y;
        double r491787 = r491785 * r491786;
        double r491788 = z;
        double r491789 = r491784 * r491788;
        double r491790 = r491787 + r491789;
        return r491790;
}

double f(double x, double y, double z) {
        double r491791 = z;
        double r491792 = x;
        double r491793 = 1.0;
        double r491794 = r491793 - r491792;
        double r491795 = y;
        double r491796 = r491794 * r491795;
        double r491797 = fma(r491791, r491792, r491796);
        return r491797;
}

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 - x\right) \cdot y + x \cdot z\]
  2. Simplified0.0

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

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

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

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

Reproduce

herbie shell --seed 2019303 +o rules:numerics
(FPCore (x y z)
  :name "Diagrams.Color.HSV:lerp  from diagrams-contrib-1.3.0.5"
  :precision binary64

  :herbie-target
  (- y (* x (- y z)))

  (+ (* (- 1 x) y) (* x z)))