Average Error: 0.1 → 0.0
Time: 2.7s
Precision: 64
\[\left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right) + x\]
\[\mathsf{fma}\left(3, x, \mathsf{fma}\left(y, 2, z\right)\right)\]
\left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right) + x
\mathsf{fma}\left(3, x, \mathsf{fma}\left(y, 2, z\right)\right)
double f(double x, double y, double z) {
        double r111234 = x;
        double r111235 = y;
        double r111236 = r111234 + r111235;
        double r111237 = r111236 + r111235;
        double r111238 = r111237 + r111234;
        double r111239 = z;
        double r111240 = r111238 + r111239;
        double r111241 = r111240 + r111234;
        return r111241;
}

double f(double x, double y, double z) {
        double r111242 = 3.0;
        double r111243 = x;
        double r111244 = y;
        double r111245 = 2.0;
        double r111246 = z;
        double r111247 = fma(r111244, r111245, r111246);
        double r111248 = fma(r111242, r111243, r111247);
        return r111248;
}

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(3, x, \mathsf{fma}\left(y, 2, z\right)\right)}\]
  3. Final simplification0.0

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

Reproduce

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