Average Error: 0.1 → 0.0
Time: 4.2s
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 r70215 = x;
        double r70216 = y;
        double r70217 = r70215 + r70216;
        double r70218 = r70217 + r70216;
        double r70219 = r70218 + r70215;
        double r70220 = z;
        double r70221 = r70219 + r70220;
        double r70222 = r70221 + r70215;
        return r70222;
}

double f(double x, double y, double z) {
        double r70223 = 3.0;
        double r70224 = x;
        double r70225 = y;
        double r70226 = 2.0;
        double r70227 = z;
        double r70228 = fma(r70225, r70226, r70227);
        double r70229 = fma(r70223, r70224, r70228);
        return r70229;
}

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