Average Error: 0.0 → 0.0
Time: 15.4s
Precision: 64
\[\left(1 - x\right) \cdot y + x \cdot z\]
\[\mathsf{fma}\left(x, z, 1 \cdot \mathsf{fma}\left(-y, x, y\right)\right)\]
\left(1 - x\right) \cdot y + x \cdot z
\mathsf{fma}\left(x, z, 1 \cdot \mathsf{fma}\left(-y, x, y\right)\right)
double f(double x, double y, double z) {
        double r450573 = 1.0;
        double r450574 = x;
        double r450575 = r450573 - r450574;
        double r450576 = y;
        double r450577 = r450575 * r450576;
        double r450578 = z;
        double r450579 = r450574 * r450578;
        double r450580 = r450577 + r450579;
        return r450580;
}

double f(double x, double y, double z) {
        double r450581 = x;
        double r450582 = z;
        double r450583 = 1.0;
        double r450584 = y;
        double r450585 = -r450584;
        double r450586 = fma(r450585, r450581, r450584);
        double r450587 = r450583 * r450586;
        double r450588 = fma(r450581, r450582, r450587);
        return r450588;
}

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. Using strategy rm
  3. Applied flip--7.9

    \[\leadsto \color{blue}{\frac{1 \cdot 1 - x \cdot x}{1 + x}} \cdot y + x \cdot z\]
  4. Applied associate-*l/9.9

    \[\leadsto \color{blue}{\frac{\left(1 \cdot 1 - x \cdot x\right) \cdot y}{1 + x}} + x \cdot z\]
  5. Taylor expanded around 0 0.0

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

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

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

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

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

Reproduce

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