Average Error: 0.1 → 0.0
Time: 1.0s
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 r202412 = x;
        double r202413 = y;
        double r202414 = r202412 + r202413;
        double r202415 = r202414 + r202413;
        double r202416 = r202415 + r202412;
        double r202417 = z;
        double r202418 = r202416 + r202417;
        double r202419 = r202418 + r202412;
        return r202419;
}

double f(double x, double y, double z) {
        double r202420 = 3.0;
        double r202421 = x;
        double r202422 = 2.0;
        double r202423 = y;
        double r202424 = z;
        double r202425 = fma(r202422, r202423, r202424);
        double r202426 = fma(r202420, r202421, r202425);
        return r202426;
}

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