Average Error: 0.1 → 0.0
Time: 16.4s
Precision: 64
\[\left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right) + x\]
\[\mathsf{fma}\left(2, y, \mathsf{fma}\left(3, x, z\right)\right)\]
\left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right) + x
\mathsf{fma}\left(2, y, \mathsf{fma}\left(3, x, z\right)\right)
double f(double x, double y, double z) {
        double r7666307 = x;
        double r7666308 = y;
        double r7666309 = r7666307 + r7666308;
        double r7666310 = r7666309 + r7666308;
        double r7666311 = r7666310 + r7666307;
        double r7666312 = z;
        double r7666313 = r7666311 + r7666312;
        double r7666314 = r7666313 + r7666307;
        return r7666314;
}

double f(double x, double y, double z) {
        double r7666315 = 2.0;
        double r7666316 = y;
        double r7666317 = 3.0;
        double r7666318 = x;
        double r7666319 = z;
        double r7666320 = fma(r7666317, r7666318, r7666319);
        double r7666321 = fma(r7666315, r7666316, r7666320);
        return r7666321;
}

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

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

Reproduce

herbie shell --seed 2019164 +o rules:numerics
(FPCore (x y z)
  :name "Graphics.Rendering.Plot.Render.Plot.Legend:renderLegendInside from plot-0.2.3.4"
  (+ (+ (+ (+ (+ x y) y) x) z) x))