Average Error: 0.1 → 0.0
Time: 1.2s
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 r163636 = x;
        double r163637 = y;
        double r163638 = r163636 + r163637;
        double r163639 = r163638 + r163637;
        double r163640 = r163639 + r163636;
        double r163641 = z;
        double r163642 = r163640 + r163641;
        double r163643 = r163642 + r163636;
        return r163643;
}

double f(double x, double y, double z) {
        double r163644 = 3.0;
        double r163645 = x;
        double r163646 = 2.0;
        double r163647 = y;
        double r163648 = z;
        double r163649 = fma(r163646, r163647, r163648);
        double r163650 = fma(r163644, r163645, r163649);
        return r163650;
}

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