Average Error: 0.1 → 0.1
Time: 1.8s
Precision: 64
\[x + \left(y \cdot z\right) \cdot z\]
\[\mathsf{fma}\left(y \cdot z, z, x\right)\]
x + \left(y \cdot z\right) \cdot z
\mathsf{fma}\left(y \cdot z, z, x\right)
double f(double x, double y, double z) {
        double r4486 = x;
        double r4487 = y;
        double r4488 = z;
        double r4489 = r4487 * r4488;
        double r4490 = r4489 * r4488;
        double r4491 = r4486 + r4490;
        return r4491;
}

double f(double x, double y, double z) {
        double r4492 = y;
        double r4493 = z;
        double r4494 = r4492 * r4493;
        double r4495 = x;
        double r4496 = fma(r4494, r4493, r4495);
        return r4496;
}

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. Using strategy rm
  3. Applied add-sqr-sqrt32.1

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

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

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

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

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

Reproduce

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