Average Error: 0.0 → 0.0
Time: 8.4s
Precision: 64
\[x \cdot y + \left(1 - x\right) \cdot z\]
\[\mathsf{fma}\left(x, y, \left(-x \cdot z\right) + z \cdot 1\right)\]
x \cdot y + \left(1 - x\right) \cdot z
\mathsf{fma}\left(x, y, \left(-x \cdot z\right) + z \cdot 1\right)
double f(double x, double y, double z) {
        double r219354 = x;
        double r219355 = y;
        double r219356 = r219354 * r219355;
        double r219357 = 1.0;
        double r219358 = r219357 - r219354;
        double r219359 = z;
        double r219360 = r219358 * r219359;
        double r219361 = r219356 + r219360;
        return r219361;
}

double f(double x, double y, double z) {
        double r219362 = x;
        double r219363 = y;
        double r219364 = z;
        double r219365 = r219362 * r219364;
        double r219366 = -r219365;
        double r219367 = 1.0;
        double r219368 = r219364 * r219367;
        double r219369 = r219366 + r219368;
        double r219370 = fma(r219362, r219363, r219369);
        return r219370;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Derivation

  1. Initial program 0.0

    \[x \cdot y + \left(1 - x\right) \cdot z\]
  2. Simplified0.0

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, y, z \cdot \left(1 - x\right)\right)}\]
  3. Using strategy rm
  4. Applied sub-neg0.0

    \[\leadsto \mathsf{fma}\left(x, y, z \cdot \color{blue}{\left(1 + \left(-x\right)\right)}\right)\]
  5. Applied distribute-rgt-in0.0

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

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

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

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

Reproduce

herbie shell --seed 2019174 +o rules:numerics
(FPCore (x y z)
  :name "Diagrams.Backend.Rasterific:$crender from diagrams-rasterific-1.3.1.3"
  (+ (* x y) (* (- 1.0 x) z)))