Average Error: 0.1 → 0.0
Time: 4.3s
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 r109540 = x;
        double r109541 = y;
        double r109542 = r109540 + r109541;
        double r109543 = r109542 + r109541;
        double r109544 = r109543 + r109540;
        double r109545 = z;
        double r109546 = r109544 + r109545;
        double r109547 = r109546 + r109540;
        return r109547;
}

double f(double x, double y, double z) {
        double r109548 = 3.0;
        double r109549 = x;
        double r109550 = y;
        double r109551 = 2.0;
        double r109552 = z;
        double r109553 = fma(r109550, r109551, r109552);
        double r109554 = fma(r109548, r109549, r109553);
        return r109554;
}

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