Average Error: 0.1 → 0.1
Time: 15.4s
Precision: 64
\[x + \left(y \cdot z\right) \cdot z\]
\[\mathsf{fma}\left(z, z \cdot y, x\right)\]
x + \left(y \cdot z\right) \cdot z
\mathsf{fma}\left(z, z \cdot y, x\right)
double f(double x, double y, double z) {
        double r642415 = x;
        double r642416 = y;
        double r642417 = z;
        double r642418 = r642416 * r642417;
        double r642419 = r642418 * r642417;
        double r642420 = r642415 + r642419;
        return r642420;
}

double f(double x, double y, double z) {
        double r642421 = z;
        double r642422 = y;
        double r642423 = r642421 * r642422;
        double r642424 = x;
        double r642425 = fma(r642421, r642423, r642424);
        return r642425;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Derivation

  1. Initial program 0.1

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

    \[\leadsto x + \color{blue}{{z}^{2} \cdot y}\]
  3. Simplified5.8

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

    \[\leadsto \color{blue}{x + {z}^{2} \cdot y}\]
  5. Simplified0.1

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

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

Reproduce

herbie shell --seed 2019158 +o rules:numerics
(FPCore (x y z)
  :name "Statistics.Sample:robustSumVarWeighted from math-functions-0.1.5.2"
  (+ x (* (* y z) z)))