Average Error: 0.1 → 0.0
Time: 9.7s
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 r117896 = x;
        double r117897 = y;
        double r117898 = r117896 + r117897;
        double r117899 = r117898 + r117897;
        double r117900 = r117899 + r117896;
        double r117901 = z;
        double r117902 = r117900 + r117901;
        double r117903 = r117902 + r117896;
        return r117903;
}

double f(double x, double y, double z) {
        double r117904 = 3.0;
        double r117905 = x;
        double r117906 = y;
        double r117907 = 2.0;
        double r117908 = z;
        double r117909 = fma(r117906, r117907, r117908);
        double r117910 = fma(r117904, r117905, r117909);
        return r117910;
}

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(3, x, \mathsf{fma}\left(y, 2, z\right)\right)}\]
  3. Final simplification0.0

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

Reproduce

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