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(3, x, \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(3, x, \mathsf{fma}\left(y, 2, z\right)\right)
double f(double x, double y, double z) {
        double r162971 = x;
        double r162972 = y;
        double r162973 = r162971 + r162972;
        double r162974 = r162973 + r162972;
        double r162975 = r162974 + r162971;
        double r162976 = z;
        double r162977 = r162975 + r162976;
        double r162978 = r162977 + r162971;
        return r162978;
}

double f(double x, double y, double z) {
        double r162979 = 3.0;
        double r162980 = x;
        double r162981 = y;
        double r162982 = 2.0;
        double r162983 = z;
        double r162984 = fma(r162981, r162982, r162983);
        double r162985 = fma(r162979, r162980, r162984);
        return r162985;
}

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. Taylor expanded around 0 0.1

    \[\leadsto \color{blue}{3 \cdot x + \left(z + 2 \cdot y\right)}\]
  3. Simplified0.0

    \[\leadsto \color{blue}{\mathsf{fma}\left(3, x, \mathsf{fma}\left(y, 2, z\right)\right)}\]
  4. Final simplification0.0

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

Reproduce

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