Average Error: 0.0 → 0.0
Time: 6.9s
Precision: 64
\[x \cdot y + \left(1 - x\right) \cdot z\]
\[\mathsf{fma}\left(x, y, \left(-z\right) \cdot x + z \cdot 1\right)\]
x \cdot y + \left(1 - x\right) \cdot z
\mathsf{fma}\left(x, y, \left(-z\right) \cdot x + z \cdot 1\right)
double f(double x, double y, double z) {
        double r163502 = x;
        double r163503 = y;
        double r163504 = r163502 * r163503;
        double r163505 = 1.0;
        double r163506 = r163505 - r163502;
        double r163507 = z;
        double r163508 = r163506 * r163507;
        double r163509 = r163504 + r163508;
        return r163509;
}

double f(double x, double y, double z) {
        double r163510 = x;
        double r163511 = y;
        double r163512 = z;
        double r163513 = -r163512;
        double r163514 = r163513 * r163510;
        double r163515 = 1.0;
        double r163516 = r163512 * r163515;
        double r163517 = r163514 + r163516;
        double r163518 = fma(r163510, r163511, r163517);
        return r163518;
}

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

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

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

Reproduce

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