Average Error: 0.1 → 0.0
Time: 9.1s
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 r5474859 = x;
        double r5474860 = y;
        double r5474861 = r5474859 + r5474860;
        double r5474862 = r5474861 + r5474860;
        double r5474863 = r5474862 + r5474859;
        double r5474864 = z;
        double r5474865 = r5474863 + r5474864;
        double r5474866 = r5474865 + r5474859;
        return r5474866;
}

double f(double x, double y, double z) {
        double r5474867 = 2.0;
        double r5474868 = y;
        double r5474869 = 3.0;
        double r5474870 = x;
        double r5474871 = z;
        double r5474872 = fma(r5474869, r5474870, r5474871);
        double r5474873 = fma(r5474867, r5474868, r5474872);
        return r5474873;
}

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