Average Error: 0.1 → 0.0
Time: 988.0ms
Precision: 64
\[\left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right) + x\]
\[\mathsf{fma}\left(3, x, \mathsf{fma}\left(2, y, z\right)\right)\]
\left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right) + x
\mathsf{fma}\left(3, x, \mathsf{fma}\left(2, y, z\right)\right)
double f(double x, double y, double z) {
        double r137974 = x;
        double r137975 = y;
        double r137976 = r137974 + r137975;
        double r137977 = r137976 + r137975;
        double r137978 = r137977 + r137974;
        double r137979 = z;
        double r137980 = r137978 + r137979;
        double r137981 = r137980 + r137974;
        return r137981;
}

double f(double x, double y, double z) {
        double r137982 = 3.0;
        double r137983 = x;
        double r137984 = 2.0;
        double r137985 = y;
        double r137986 = z;
        double r137987 = fma(r137984, r137985, r137986);
        double r137988 = fma(r137982, r137983, r137987);
        return r137988;
}

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(3, x, \mathsf{fma}\left(2, y, z\right)\right)}\]
  3. Final simplification0.0

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

Reproduce

herbie shell --seed 2020001 +o rules:numerics
(FPCore (x y z)
  :name "Graphics.Rendering.Plot.Render.Plot.Legend:renderLegendInside from plot-0.2.3.4"
  :precision binary64
  (+ (+ (+ (+ (+ x y) y) x) z) x))