Average Error: 0.1 → 0.0
Time: 4.5s
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 r5925187 = x;
        double r5925188 = y;
        double r5925189 = r5925187 + r5925188;
        double r5925190 = r5925189 + r5925188;
        double r5925191 = r5925190 + r5925187;
        double r5925192 = z;
        double r5925193 = r5925191 + r5925192;
        double r5925194 = r5925193 + r5925187;
        return r5925194;
}

double f(double x, double y, double z) {
        double r5925195 = x;
        double r5925196 = 3.0;
        double r5925197 = y;
        double r5925198 = 2.0;
        double r5925199 = z;
        double r5925200 = fma(r5925197, r5925198, r5925199);
        double r5925201 = fma(r5925195, r5925196, r5925200);
        return r5925201;
}

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