Average Error: 0.0 → 0.0
Time: 27.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 r27352063 = 1.0;
        double r27352064 = x;
        double r27352065 = r27352063 - r27352064;
        double r27352066 = y;
        double r27352067 = r27352065 * r27352066;
        double r27352068 = z;
        double r27352069 = r27352064 * r27352068;
        double r27352070 = r27352067 + r27352069;
        return r27352070;
}

double f(double x, double y, double z) {
        double r27352071 = x;
        double r27352072 = z;
        double r27352073 = y;
        double r27352074 = r27352072 - r27352073;
        double r27352075 = 1.0;
        double r27352076 = r27352075 * r27352073;
        double r27352077 = fma(r27352071, r27352074, r27352076);
        return r27352077;
}

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, 1.0 \cdot y\right)}\]
  5. Final simplification0.0

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

Reproduce

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