Average Error: 0.1 → 0.0
Time: 3.7s
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 r118861 = x;
        double r118862 = y;
        double r118863 = r118861 + r118862;
        double r118864 = r118863 + r118862;
        double r118865 = r118864 + r118861;
        double r118866 = z;
        double r118867 = r118865 + r118866;
        double r118868 = r118867 + r118861;
        return r118868;
}

double f(double x, double y, double z) {
        double r118869 = x;
        double r118870 = 3.0;
        double r118871 = y;
        double r118872 = 2.0;
        double r118873 = z;
        double r118874 = fma(r118871, r118872, r118873);
        double r118875 = fma(r118869, r118870, r118874);
        return r118875;
}

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