Average Error: 0.1 → 0.0
Time: 15.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 r6859061 = x;
        double r6859062 = y;
        double r6859063 = r6859061 + r6859062;
        double r6859064 = r6859063 + r6859062;
        double r6859065 = r6859064 + r6859061;
        double r6859066 = z;
        double r6859067 = r6859065 + r6859066;
        double r6859068 = r6859067 + r6859061;
        return r6859068;
}

double f(double x, double y, double z) {
        double r6859069 = 2.0;
        double r6859070 = y;
        double r6859071 = 3.0;
        double r6859072 = x;
        double r6859073 = z;
        double r6859074 = fma(r6859071, r6859072, r6859073);
        double r6859075 = fma(r6859069, r6859070, r6859074);
        return r6859075;
}

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