Average Error: 0.1 → 0.0
Time: 8.8s
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 r96965 = x;
        double r96966 = y;
        double r96967 = r96965 + r96966;
        double r96968 = r96967 + r96966;
        double r96969 = r96968 + r96965;
        double r96970 = z;
        double r96971 = r96969 + r96970;
        double r96972 = r96971 + r96965;
        return r96972;
}

double f(double x, double y, double z) {
        double r96973 = 3.0;
        double r96974 = x;
        double r96975 = y;
        double r96976 = 2.0;
        double r96977 = z;
        double r96978 = fma(r96975, r96976, r96977);
        double r96979 = fma(r96973, r96974, r96978);
        return r96979;
}

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