Average Error: 0.1 → 0.0
Time: 11.5s
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 r66919 = x;
        double r66920 = y;
        double r66921 = r66919 + r66920;
        double r66922 = r66921 + r66920;
        double r66923 = r66922 + r66919;
        double r66924 = z;
        double r66925 = r66923 + r66924;
        double r66926 = r66925 + r66919;
        return r66926;
}

double f(double x, double y, double z) {
        double r66927 = 3.0;
        double r66928 = x;
        double r66929 = y;
        double r66930 = 2.0;
        double r66931 = z;
        double r66932 = fma(r66929, r66930, r66931);
        double r66933 = fma(r66927, r66928, r66932);
        return r66933;
}

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