Average Error: 0.0 → 0.0
Time: 12.0s
Precision: 64
\[x \cdot y + \left(1 - x\right) \cdot z\]
\[\mathsf{fma}\left(x, y, 1 \cdot \left(z - x \cdot z\right)\right)\]
x \cdot y + \left(1 - x\right) \cdot z
\mathsf{fma}\left(x, y, 1 \cdot \left(z - x \cdot z\right)\right)
double f(double x, double y, double z) {
        double r141564 = x;
        double r141565 = y;
        double r141566 = r141564 * r141565;
        double r141567 = 1.0;
        double r141568 = r141567 - r141564;
        double r141569 = z;
        double r141570 = r141568 * r141569;
        double r141571 = r141566 + r141570;
        return r141571;
}

double f(double x, double y, double z) {
        double r141572 = x;
        double r141573 = y;
        double r141574 = 1.0;
        double r141575 = z;
        double r141576 = r141572 * r141575;
        double r141577 = r141575 - r141576;
        double r141578 = r141574 * r141577;
        double r141579 = fma(r141572, r141573, r141578);
        return r141579;
}

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, \left(1 - x\right) \cdot z\right)}\]
  3. Using strategy rm
  4. Applied flip--7.9

    \[\leadsto \mathsf{fma}\left(x, y, \color{blue}{\frac{1 \cdot 1 - x \cdot x}{1 + x}} \cdot z\right)\]
  5. Applied associate-*l/10.0

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

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

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

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

Reproduce

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