Average Error: 0.0 → 0.0
Time: 12.3s
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 r175865 = x;
        double r175866 = y;
        double r175867 = r175865 * r175866;
        double r175868 = 1.0;
        double r175869 = r175868 - r175865;
        double r175870 = z;
        double r175871 = r175869 * r175870;
        double r175872 = r175867 + r175871;
        return r175872;
}

double f(double x, double y, double z) {
        double r175873 = x;
        double r175874 = y;
        double r175875 = 1.0;
        double r175876 = z;
        double r175877 = r175873 * r175876;
        double r175878 = r175876 - r175877;
        double r175879 = r175875 * r175878;
        double r175880 = fma(r175873, r175874, r175879);
        return r175880;
}

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)))