Average Error: 0.1 → 0.0
Time: 927.0ms
Precision: 64
\[\left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right) + x\]
\[\mathsf{fma}\left(3, x, \mathsf{fma}\left(2, y, 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(2, y, z\right)\right)
double f(double x, double y, double z) {
        double r122517 = x;
        double r122518 = y;
        double r122519 = r122517 + r122518;
        double r122520 = r122519 + r122518;
        double r122521 = r122520 + r122517;
        double r122522 = z;
        double r122523 = r122521 + r122522;
        double r122524 = r122523 + r122517;
        return r122524;
}

double f(double x, double y, double z) {
        double r122525 = 3.0;
        double r122526 = x;
        double r122527 = 2.0;
        double r122528 = y;
        double r122529 = z;
        double r122530 = fma(r122527, r122528, r122529);
        double r122531 = fma(r122525, r122526, r122530);
        return r122531;
}

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

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

Reproduce

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