Average Error: 0.1 → 0.0
Time: 4.1s
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 r77029 = x;
        double r77030 = y;
        double r77031 = r77029 + r77030;
        double r77032 = r77031 + r77030;
        double r77033 = r77032 + r77029;
        double r77034 = z;
        double r77035 = r77033 + r77034;
        double r77036 = r77035 + r77029;
        return r77036;
}

double f(double x, double y, double z) {
        double r77037 = x;
        double r77038 = 3.0;
        double r77039 = y;
        double r77040 = 2.0;
        double r77041 = z;
        double r77042 = fma(r77039, r77040, r77041);
        double r77043 = fma(r77037, r77038, r77042);
        return r77043;
}

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