Average Error: 0.0 → 0.0
Time: 9.2s
Precision: 64
\[x \cdot y + \left(1 - x\right) \cdot z\]
\[\mathsf{fma}\left(x, y, z \cdot \left(-x\right) + z \cdot 1\right)\]
x \cdot y + \left(1 - x\right) \cdot z
\mathsf{fma}\left(x, y, z \cdot \left(-x\right) + z \cdot 1\right)
double f(double x, double y, double z) {
        double r9049778 = x;
        double r9049779 = y;
        double r9049780 = r9049778 * r9049779;
        double r9049781 = 1.0;
        double r9049782 = r9049781 - r9049778;
        double r9049783 = z;
        double r9049784 = r9049782 * r9049783;
        double r9049785 = r9049780 + r9049784;
        return r9049785;
}

double f(double x, double y, double z) {
        double r9049786 = x;
        double r9049787 = y;
        double r9049788 = z;
        double r9049789 = -r9049786;
        double r9049790 = r9049788 * r9049789;
        double r9049791 = 1.0;
        double r9049792 = r9049788 * r9049791;
        double r9049793 = r9049790 + r9049792;
        double r9049794 = fma(r9049786, r9049787, r9049793);
        return r9049794;
}

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

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

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

Reproduce

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