Average Error: 0.0 → 0.0
Time: 12.2s
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 r479329 = 1.0;
        double r479330 = x;
        double r479331 = r479329 - r479330;
        double r479332 = y;
        double r479333 = r479331 * r479332;
        double r479334 = z;
        double r479335 = r479330 * r479334;
        double r479336 = r479333 + r479335;
        return r479336;
}

double f(double x, double y, double z) {
        double r479337 = z;
        double r479338 = x;
        double r479339 = 1.0;
        double r479340 = y;
        double r479341 = r479338 * r479340;
        double r479342 = r479340 - r479341;
        double r479343 = r479339 * r479342;
        double r479344 = fma(r479337, r479338, r479343);
        return r479344;
}

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.0

    \[\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(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 2019305 +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)))