Average Error: 0.1 → 0.0
Time: 9.2s
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 r101338 = x;
        double r101339 = y;
        double r101340 = r101338 + r101339;
        double r101341 = r101340 + r101339;
        double r101342 = r101341 + r101338;
        double r101343 = z;
        double r101344 = r101342 + r101343;
        double r101345 = r101344 + r101338;
        return r101345;
}

double f(double x, double y, double z) {
        double r101346 = y;
        double r101347 = 2.0;
        double r101348 = 3.0;
        double r101349 = x;
        double r101350 = z;
        double r101351 = fma(r101348, r101349, r101350);
        double r101352 = fma(r101346, r101347, r101351);
        return r101352;
}

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 2019208 +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))