Average Error: 0.0 → 0.0
Time: 1.1s
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 r497 = x;
        double r498 = y;
        double r499 = r497 + r498;
        double r500 = z;
        double r501 = r499 * r500;
        return r501;
}

double f(double x, double y, double z) {
        double r502 = x;
        double r503 = z;
        double r504 = y;
        double r505 = r503 * r504;
        double r506 = fma(r502, r503, r505);
        return r506;
}

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. Using strategy rm
  3. Applied *-un-lft-identity0.0

    \[\leadsto \color{blue}{\left(1 \cdot \left(x + y\right)\right)} \cdot z\]
  4. Applied associate-*l*0.0

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

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

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

Reproduce

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