Average Error: 0.1 → 0.0
Time: 3.0s
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 r2131274 = x;
        double r2131275 = y;
        double r2131276 = r2131274 + r2131275;
        double r2131277 = r2131276 + r2131275;
        double r2131278 = r2131277 + r2131274;
        double r2131279 = z;
        double r2131280 = r2131278 + r2131279;
        double r2131281 = r2131280 + r2131274;
        return r2131281;
}

double f(double x, double y, double z) {
        double r2131282 = x;
        double r2131283 = 3.0;
        double r2131284 = y;
        double r2131285 = 2.0;
        double r2131286 = z;
        double r2131287 = fma(r2131284, r2131285, r2131286);
        double r2131288 = fma(r2131282, r2131283, r2131287);
        return r2131288;
}

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

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

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

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

Reproduce

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