Average Error: 0.1 → 0.0
Time: 4.7s
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 r93340 = x;
        double r93341 = y;
        double r93342 = r93340 + r93341;
        double r93343 = r93342 + r93341;
        double r93344 = r93343 + r93340;
        double r93345 = z;
        double r93346 = r93344 + r93345;
        double r93347 = r93346 + r93340;
        return r93347;
}

double f(double x, double y, double z) {
        double r93348 = 3.0;
        double r93349 = x;
        double r93350 = y;
        double r93351 = 2.0;
        double r93352 = z;
        double r93353 = fma(r93350, r93351, r93352);
        double r93354 = fma(r93348, r93349, r93353);
        return r93354;
}

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