Average Error: 0.1 → 0.0
Time: 8.4s
Precision: 64
\[\left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right) + x\]
\[\mathsf{fma}\left(x, 3, \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(x, 3, \mathsf{fma}\left(2, y, z\right)\right)
double f(double x, double y, double z) {
        double r5858896 = x;
        double r5858897 = y;
        double r5858898 = r5858896 + r5858897;
        double r5858899 = r5858898 + r5858897;
        double r5858900 = r5858899 + r5858896;
        double r5858901 = z;
        double r5858902 = r5858900 + r5858901;
        double r5858903 = r5858902 + r5858896;
        return r5858903;
}

double f(double x, double y, double z) {
        double r5858904 = x;
        double r5858905 = 3.0;
        double r5858906 = 2.0;
        double r5858907 = y;
        double r5858908 = z;
        double r5858909 = fma(r5858906, r5858907, r5858908);
        double r5858910 = fma(r5858904, r5858905, r5858909);
        return r5858910;
}

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(y, 2, \mathsf{fma}\left(x, 3, z\right)\right)}\]
  3. Using strategy rm
  4. Applied fma-udef0.1

    \[\leadsto \mathsf{fma}\left(y, 2, \color{blue}{x \cdot 3 + z}\right)\]
  5. Taylor expanded around 0 0.1

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

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

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

Reproduce

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