Average Error: 0.1 → 0.0
Time: 4.6s
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 r4861953 = x;
        double r4861954 = y;
        double r4861955 = r4861953 + r4861954;
        double r4861956 = r4861955 + r4861954;
        double r4861957 = r4861956 + r4861953;
        double r4861958 = z;
        double r4861959 = r4861957 + r4861958;
        double r4861960 = r4861959 + r4861953;
        return r4861960;
}

double f(double x, double y, double z) {
        double r4861961 = x;
        double r4861962 = 3.0;
        double r4861963 = y;
        double r4861964 = 2.0;
        double r4861965 = z;
        double r4861966 = fma(r4861963, r4861964, r4861965);
        double r4861967 = fma(r4861961, r4861962, r4861966);
        return r4861967;
}

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