Average Error: 0.0 → 0.0
Time: 22.2s
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 r24904039 = x;
        double r24904040 = y;
        double r24904041 = r24904039 * r24904040;
        double r24904042 = 1.0;
        double r24904043 = r24904042 - r24904039;
        double r24904044 = z;
        double r24904045 = r24904043 * r24904044;
        double r24904046 = r24904041 + r24904045;
        return r24904046;
}

double f(double x, double y, double z) {
        double r24904047 = x;
        double r24904048 = y;
        double r24904049 = 1.0;
        double r24904050 = z;
        double r24904051 = r24904047 * r24904050;
        double r24904052 = r24904050 - r24904051;
        double r24904053 = r24904049 * r24904052;
        double r24904054 = fma(r24904047, r24904048, r24904053);
        return r24904054;
}

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

    \[\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 \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 2019173 +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)))