Average Error: 0.0 → 0.0
Time: 6.2s
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 r818762 = 1.0;
        double r818763 = x;
        double r818764 = r818762 - r818763;
        double r818765 = y;
        double r818766 = r818764 * r818765;
        double r818767 = z;
        double r818768 = r818763 * r818767;
        double r818769 = r818766 + r818768;
        return r818769;
}

double f(double x, double y, double z) {
        double r818770 = z;
        double r818771 = x;
        double r818772 = 1.0;
        double r818773 = r818772 - r818771;
        double r818774 = y;
        double r818775 = r818773 * r818774;
        double r818776 = fma(r818770, r818771, r818775);
        return r818776;
}

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