Average Error: 0.0 → 0.0
Time: 11.4s
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 r31640939 = 1.0;
        double r31640940 = x;
        double r31640941 = r31640939 - r31640940;
        double r31640942 = y;
        double r31640943 = r31640941 * r31640942;
        double r31640944 = z;
        double r31640945 = r31640940 * r31640944;
        double r31640946 = r31640943 + r31640945;
        return r31640946;
}

double f(double x, double y, double z) {
        double r31640947 = 1.0;
        double r31640948 = x;
        double r31640949 = r31640947 - r31640948;
        double r31640950 = y;
        double r31640951 = z;
        double r31640952 = r31640948 * r31640951;
        double r31640953 = fma(r31640949, r31640950, r31640952);
        return r31640953;
}

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