Average Error: 0.1 → 0.0
Time: 4.9s
Precision: 64
\[\left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right) + x\]
\[\mathsf{fma}\left(x, 3, \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(x, 3, \mathsf{fma}\left(y, 2, z\right)\right)
double f(double x, double y, double z) {
        double r6779145 = x;
        double r6779146 = y;
        double r6779147 = r6779145 + r6779146;
        double r6779148 = r6779147 + r6779146;
        double r6779149 = r6779148 + r6779145;
        double r6779150 = z;
        double r6779151 = r6779149 + r6779150;
        double r6779152 = r6779151 + r6779145;
        return r6779152;
}

double f(double x, double y, double z) {
        double r6779153 = x;
        double r6779154 = 3.0;
        double r6779155 = y;
        double r6779156 = 2.0;
        double r6779157 = z;
        double r6779158 = fma(r6779155, r6779156, r6779157);
        double r6779159 = fma(r6779153, r6779154, r6779158);
        return r6779159;
}

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

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

Reproduce

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