Average Error: 0.1 → 0.0
Time: 14.9s
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 r7406873 = x;
        double r7406874 = y;
        double r7406875 = r7406873 + r7406874;
        double r7406876 = r7406875 + r7406874;
        double r7406877 = r7406876 + r7406873;
        double r7406878 = z;
        double r7406879 = r7406877 + r7406878;
        double r7406880 = r7406879 + r7406873;
        return r7406880;
}

double f(double x, double y, double z) {
        double r7406881 = 2.0;
        double r7406882 = y;
        double r7406883 = 3.0;
        double r7406884 = x;
        double r7406885 = z;
        double r7406886 = fma(r7406883, r7406884, r7406885);
        double r7406887 = fma(r7406881, r7406882, r7406886);
        return r7406887;
}

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