Average Error: 0.1 → 0.0
Time: 940.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 r179131 = x;
        double r179132 = y;
        double r179133 = r179131 + r179132;
        double r179134 = r179133 + r179132;
        double r179135 = r179134 + r179131;
        double r179136 = z;
        double r179137 = r179135 + r179136;
        double r179138 = r179137 + r179131;
        return r179138;
}

double f(double x, double y, double z) {
        double r179139 = 3.0;
        double r179140 = x;
        double r179141 = 2.0;
        double r179142 = y;
        double r179143 = z;
        double r179144 = fma(r179141, r179142, r179143);
        double r179145 = fma(r179139, r179140, r179144);
        return r179145;
}

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