Average Error: 0.0 → 0.0
Time: 2.3s
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 r6919 = x;
        double r6920 = y;
        double r6921 = r6919 + r6920;
        double r6922 = z;
        double r6923 = r6921 * r6922;
        return r6923;
}

double f(double x, double y, double z) {
        double r6924 = x;
        double r6925 = z;
        double r6926 = y;
        double r6927 = r6925 * r6926;
        double r6928 = fma(r6924, r6925, r6927);
        return r6928;
}

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 2020100 +o rules:numerics
(FPCore (x y z)
  :name "Text.Parsec.Token:makeTokenParser from parsec-3.1.9, B"
  :precision binary64
  (* (+ x y) z))