Average Error: 0.0 → 0.0
Time: 1.7s
Precision: 64
\[\left(x + y\right) \cdot z\]
\[\mathsf{fma}\left(x, z, z \cdot y\right)\]
\left(x + y\right) \cdot z
\mathsf{fma}\left(x, z, z \cdot y\right)
double f(double x, double y, double z) {
        double r1971 = x;
        double r1972 = y;
        double r1973 = r1971 + r1972;
        double r1974 = z;
        double r1975 = r1973 * r1974;
        return r1975;
}

double f(double x, double y, double z) {
        double r1976 = x;
        double r1977 = z;
        double r1978 = y;
        double r1979 = r1977 * r1978;
        double r1980 = fma(r1976, r1977, r1979);
        return r1980;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Derivation

  1. Initial program 0.0

    \[\left(x + y\right) \cdot z\]
  2. Taylor expanded around inf 0.0

    \[\leadsto \color{blue}{x \cdot z + z \cdot y}\]
  3. Simplified0.0

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

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

Reproduce

herbie shell --seed 2019352 +o rules:numerics
(FPCore (x y z)
  :name "Text.Parsec.Token:makeTokenParser from parsec-3.1.9, B"
  :precision binary64
  (* (+ x y) z))