Average Error: 0.1 → 0.0
Time: 4.2s
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 r201025 = x;
        double r201026 = y;
        double r201027 = r201025 + r201026;
        double r201028 = r201027 + r201026;
        double r201029 = r201028 + r201025;
        double r201030 = z;
        double r201031 = r201029 + r201030;
        double r201032 = r201031 + r201025;
        return r201032;
}

double f(double x, double y, double z) {
        double r201033 = 3.0;
        double r201034 = x;
        double r201035 = y;
        double r201036 = 2.0;
        double r201037 = z;
        double r201038 = fma(r201035, r201036, r201037);
        double r201039 = fma(r201033, r201034, r201038);
        return r201039;
}

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