Average Error: 0.1 → 0.0
Time: 11.4s
Precision: 64
\[\left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right) + x\]
\[\mathsf{fma}\left(y, 2, \mathsf{fma}\left(3, x, z\right)\right)\]
\left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right) + x
\mathsf{fma}\left(y, 2, \mathsf{fma}\left(3, x, z\right)\right)
double f(double x, double y, double z) {
        double r164007 = x;
        double r164008 = y;
        double r164009 = r164007 + r164008;
        double r164010 = r164009 + r164008;
        double r164011 = r164010 + r164007;
        double r164012 = z;
        double r164013 = r164011 + r164012;
        double r164014 = r164013 + r164007;
        return r164014;
}

double f(double x, double y, double z) {
        double r164015 = y;
        double r164016 = 2.0;
        double r164017 = 3.0;
        double r164018 = x;
        double r164019 = z;
        double r164020 = fma(r164017, r164018, r164019);
        double r164021 = fma(r164015, r164016, r164020);
        return r164021;
}

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. Simplified0.0

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

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

Reproduce

herbie shell --seed 2020042 +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))