Average Error: 0.0 → 0.0
Time: 11.2s
Precision: 64
\[x \cdot y + \left(1 - x\right) \cdot z\]
\[\mathsf{fma}\left(x, y, z \cdot \left(-x\right) + 1 \cdot z\right)\]
x \cdot y + \left(1 - x\right) \cdot z
\mathsf{fma}\left(x, y, z \cdot \left(-x\right) + 1 \cdot z\right)
double f(double x, double y, double z) {
        double r9403626 = x;
        double r9403627 = y;
        double r9403628 = r9403626 * r9403627;
        double r9403629 = 1.0;
        double r9403630 = r9403629 - r9403626;
        double r9403631 = z;
        double r9403632 = r9403630 * r9403631;
        double r9403633 = r9403628 + r9403632;
        return r9403633;
}

double f(double x, double y, double z) {
        double r9403634 = x;
        double r9403635 = y;
        double r9403636 = z;
        double r9403637 = -r9403634;
        double r9403638 = r9403636 * r9403637;
        double r9403639 = 1.0;
        double r9403640 = r9403639 * r9403636;
        double r9403641 = r9403638 + r9403640;
        double r9403642 = fma(r9403634, r9403635, r9403641);
        return r9403642;
}

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

    \[\leadsto \mathsf{fma}\left(x, y, z \cdot \left(-x\right) + 1 \cdot z\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)))