Average Error: 0.0 → 0.0
Time: 9.8s
Precision: 64
\[x \cdot y + \left(1 - x\right) \cdot z\]
\[\mathsf{fma}\left(z, 1, \left(y - z\right) \cdot x\right)\]
x \cdot y + \left(1 - x\right) \cdot z
\mathsf{fma}\left(z, 1, \left(y - z\right) \cdot x\right)
double f(double x, double y, double z) {
        double r190092 = x;
        double r190093 = y;
        double r190094 = r190092 * r190093;
        double r190095 = 1.0;
        double r190096 = r190095 - r190092;
        double r190097 = z;
        double r190098 = r190096 * r190097;
        double r190099 = r190094 + r190098;
        return r190099;
}

double f(double x, double y, double z) {
        double r190100 = z;
        double r190101 = 1.0;
        double r190102 = y;
        double r190103 = r190102 - r190100;
        double r190104 = x;
        double r190105 = r190103 * r190104;
        double r190106 = fma(r190100, r190101, r190105);
        return r190106;
}

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 flip3--12.1

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

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

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

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

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

Reproduce

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