Average Error: 0.0 → 0.0
Time: 1.5s
Precision: 64
\[x \cdot y + \left(1 - x\right) \cdot z\]
\[\mathsf{fma}\left(y, x, 1 \cdot \left(z - x \cdot z\right)\right)\]
x \cdot y + \left(1 - x\right) \cdot z
\mathsf{fma}\left(y, x, 1 \cdot \left(z - x \cdot z\right)\right)
double f(double x, double y, double z) {
        double r173945 = x;
        double r173946 = y;
        double r173947 = r173945 * r173946;
        double r173948 = 1.0;
        double r173949 = r173948 - r173945;
        double r173950 = z;
        double r173951 = r173949 * r173950;
        double r173952 = r173947 + r173951;
        return r173952;
}

double f(double x, double y, double z) {
        double r173953 = y;
        double r173954 = x;
        double r173955 = 1.0;
        double r173956 = z;
        double r173957 = r173954 * r173956;
        double r173958 = r173956 - r173957;
        double r173959 = r173955 * r173958;
        double r173960 = fma(r173953, r173954, r173959);
        return r173960;
}

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.6

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

    \[\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 \color{blue}{\left(1 \cdot z + x \cdot y\right) - 1 \cdot \left(x \cdot z\right)}\]
  7. Simplified0.0

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

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

Reproduce

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