Average Error: 0.0 → 0.0
Time: 2.4s
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 r7653 = x;
        double r7654 = y;
        double r7655 = r7653 + r7654;
        double r7656 = z;
        double r7657 = r7655 * r7656;
        return r7657;
}

double f(double x, double y, double z) {
        double r7658 = x;
        double r7659 = z;
        double r7660 = y;
        double r7661 = r7659 * r7660;
        double r7662 = fma(r7658, r7659, r7661);
        return r7662;
}

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