Average Error: 0.1 → 0.0
Time: 10.6s
Precision: 64
\[\left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right) + x\]
\[\mathsf{fma}\left(x, 3, \mathsf{fma}\left(2, y, z\right)\right)\]
\left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right) + x
\mathsf{fma}\left(x, 3, \mathsf{fma}\left(2, y, z\right)\right)
double f(double x, double y, double z) {
        double r162614 = x;
        double r162615 = y;
        double r162616 = r162614 + r162615;
        double r162617 = r162616 + r162615;
        double r162618 = r162617 + r162614;
        double r162619 = z;
        double r162620 = r162618 + r162619;
        double r162621 = r162620 + r162614;
        return r162621;
}

double f(double x, double y, double z) {
        double r162622 = x;
        double r162623 = 3.0;
        double r162624 = 2.0;
        double r162625 = y;
        double r162626 = z;
        double r162627 = fma(r162624, r162625, r162626);
        double r162628 = fma(r162622, r162623, r162627);
        return r162628;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Derivation

  1. Initial program 0.1

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

    \[\leadsto \color{blue}{3 \cdot x + \left(z + 2 \cdot y\right)}\]
  3. Simplified0.0

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

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

Reproduce

herbie shell --seed 2020047 +o rules:numerics
(FPCore (x y z)
  :name "Graphics.Rendering.Plot.Render.Plot.Legend:renderLegendInside from plot-0.2.3.4"
  :precision binary64
  (+ (+ (+ (+ (+ x y) y) x) z) x))