Average Error: 0.1 → 0.0
Time: 1.4s
Precision: 64
\[\left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right) + x\]
\[\mathsf{fma}\left(3, x, \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(3, x, \mathsf{fma}\left(y, 2, z\right)\right)
double f(double x, double y, double z) {
        double r23785 = x;
        double r23786 = y;
        double r23787 = r23785 + r23786;
        double r23788 = r23787 + r23786;
        double r23789 = r23788 + r23785;
        double r23790 = z;
        double r23791 = r23789 + r23790;
        double r23792 = r23791 + r23785;
        return r23792;
}

double f(double x, double y, double z) {
        double r23793 = 3.0;
        double r23794 = x;
        double r23795 = y;
        double r23796 = 2.0;
        double r23797 = z;
        double r23798 = fma(r23795, r23796, r23797);
        double r23799 = fma(r23793, r23794, r23798);
        return r23799;
}

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

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

Reproduce

herbie shell --seed 2020045 +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))