Average Error: 0.1 → 0.0
Time: 4.6s
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 r130681 = x;
        double r130682 = y;
        double r130683 = r130681 + r130682;
        double r130684 = r130683 + r130682;
        double r130685 = r130684 + r130681;
        double r130686 = z;
        double r130687 = r130685 + r130686;
        double r130688 = r130687 + r130681;
        return r130688;
}

double f(double x, double y, double z) {
        double r130689 = 3.0;
        double r130690 = x;
        double r130691 = y;
        double r130692 = 2.0;
        double r130693 = z;
        double r130694 = fma(r130691, r130692, r130693);
        double r130695 = fma(r130689, r130690, r130694);
        return r130695;
}

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