Average Error: 0.1 → 0.0
Time: 4.4s
Precision: 64
\[\left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right) + x\]
\[\mathsf{fma}\left(x, 3, \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(x, 3, \mathsf{fma}\left(y, 2, z\right)\right)
double f(double x, double y, double z) {
        double r5627354 = x;
        double r5627355 = y;
        double r5627356 = r5627354 + r5627355;
        double r5627357 = r5627356 + r5627355;
        double r5627358 = r5627357 + r5627354;
        double r5627359 = z;
        double r5627360 = r5627358 + r5627359;
        double r5627361 = r5627360 + r5627354;
        return r5627361;
}

double f(double x, double y, double z) {
        double r5627362 = x;
        double r5627363 = 3.0;
        double r5627364 = y;
        double r5627365 = 2.0;
        double r5627366 = z;
        double r5627367 = fma(r5627364, r5627365, r5627366);
        double r5627368 = fma(r5627362, r5627363, r5627367);
        return r5627368;
}

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

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

Reproduce

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