Average Error: 0.1 → 0.1
Time: 15.3s
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 r642796 = x;
        double r642797 = y;
        double r642798 = z;
        double r642799 = r642797 * r642798;
        double r642800 = r642799 * r642798;
        double r642801 = r642796 + r642800;
        return r642801;
}

double f(double x, double y, double z) {
        double r642802 = z;
        double r642803 = y;
        double r642804 = r642802 * r642803;
        double r642805 = x;
        double r642806 = fma(r642802, r642804, r642805);
        return r642806;
}

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 inf 5.8

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

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

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

Reproduce

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