Average Error: 0.1 → 0.0
Time: 14.5s
Precision: 64
\[\left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right) + x\]
\[\mathsf{fma}\left(2, y, \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(2, y, \mathsf{fma}\left(3, x, z\right)\right)
double f(double x, double y, double z) {
        double r17827176 = x;
        double r17827177 = y;
        double r17827178 = r17827176 + r17827177;
        double r17827179 = r17827178 + r17827177;
        double r17827180 = r17827179 + r17827176;
        double r17827181 = z;
        double r17827182 = r17827180 + r17827181;
        double r17827183 = r17827182 + r17827176;
        return r17827183;
}

double f(double x, double y, double z) {
        double r17827184 = 2.0;
        double r17827185 = y;
        double r17827186 = 3.0;
        double r17827187 = x;
        double r17827188 = z;
        double r17827189 = fma(r17827186, r17827187, r17827188);
        double r17827190 = fma(r17827184, r17827185, r17827189);
        return r17827190;
}

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. Final simplification0.0

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

Reproduce

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