Average Error: 0.0 → 0.0
Time: 9.9s
Precision: 64
\[\left(x + y\right) \cdot z\]
\[\mathsf{fma}\left(z, y, x \cdot z\right)\]
\left(x + y\right) \cdot z
\mathsf{fma}\left(z, y, x \cdot z\right)
double f(double x, double y, double z) {
        double r1046493 = x;
        double r1046494 = y;
        double r1046495 = r1046493 + r1046494;
        double r1046496 = z;
        double r1046497 = r1046495 * r1046496;
        return r1046497;
}

double f(double x, double y, double z) {
        double r1046498 = z;
        double r1046499 = y;
        double r1046500 = x;
        double r1046501 = r1046500 * r1046498;
        double r1046502 = fma(r1046498, r1046499, r1046501);
        return r1046502;
}

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 add-sqr-sqrt32.1

    \[\leadsto \left(x + y\right) \cdot \color{blue}{\left(\sqrt{z} \cdot \sqrt{z}\right)}\]
  4. Applied associate-*r*32.1

    \[\leadsto \color{blue}{\left(\left(x + y\right) \cdot \sqrt{z}\right) \cdot \sqrt{z}}\]
  5. Taylor expanded around inf 0.0

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

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

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

Reproduce

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