Average Error: 0.0 → 0.0
Time: 2.7s
Precision: 64
\[\left(1 - x\right) \cdot y + x \cdot z\]
\[\mathsf{fma}\left(z, x, 1 \cdot \left(y - x \cdot y\right)\right)\]
\left(1 - x\right) \cdot y + x \cdot z
\mathsf{fma}\left(z, x, 1 \cdot \left(y - x \cdot y\right)\right)
double f(double x, double y, double z) {
        double r802422 = 1.0;
        double r802423 = x;
        double r802424 = r802422 - r802423;
        double r802425 = y;
        double r802426 = r802424 * r802425;
        double r802427 = z;
        double r802428 = r802423 * r802427;
        double r802429 = r802426 + r802428;
        return r802429;
}

double f(double x, double y, double z) {
        double r802430 = z;
        double r802431 = x;
        double r802432 = 1.0;
        double r802433 = y;
        double r802434 = r802431 * r802433;
        double r802435 = r802433 - r802434;
        double r802436 = r802432 * r802435;
        double r802437 = fma(r802430, r802431, r802436);
        return r802437;
}

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

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

    \[\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(z, x, 1 \cdot \left(y - x \cdot y\right)\right)}\]
  7. Final simplification0.0

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

Reproduce

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