Average Error: 0.1 → 0.1
Time: 9.2s
Precision: 64
\[\left(x \cdot y + z\right) \cdot y + t\]
\[t + \mathsf{fma}\left(y, x, z\right) \cdot y\]
\left(x \cdot y + z\right) \cdot y + t
t + \mathsf{fma}\left(y, x, z\right) \cdot y
double f(double x, double y, double z, double t) {
        double r2152724 = x;
        double r2152725 = y;
        double r2152726 = r2152724 * r2152725;
        double r2152727 = z;
        double r2152728 = r2152726 + r2152727;
        double r2152729 = r2152728 * r2152725;
        double r2152730 = t;
        double r2152731 = r2152729 + r2152730;
        return r2152731;
}

double f(double x, double y, double z, double t) {
        double r2152732 = t;
        double r2152733 = y;
        double r2152734 = x;
        double r2152735 = z;
        double r2152736 = fma(r2152733, r2152734, r2152735);
        double r2152737 = r2152736 * r2152733;
        double r2152738 = r2152732 + r2152737;
        return r2152738;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Derivation

  1. Initial program 0.1

    \[\left(x \cdot y + z\right) \cdot y + t\]
  2. Simplified0.1

    \[\leadsto \color{blue}{\mathsf{fma}\left(y, \mathsf{fma}\left(y, x, z\right), t\right)}\]
  3. Using strategy rm
  4. Applied fma-udef0.1

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

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

Reproduce

herbie shell --seed 2019156 +o rules:numerics
(FPCore (x y z t)
  :name "Language.Haskell.HsColour.ColourHighlight:unbase from hscolour-1.23"
  (+ (* (+ (* x y) z) y) t))