Average Error: 0.1 → 0.0
Time: 4.9s
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 r95595 = x;
        double r95596 = y;
        double r95597 = r95595 + r95596;
        double r95598 = r95597 + r95596;
        double r95599 = r95598 + r95595;
        double r95600 = z;
        double r95601 = r95599 + r95600;
        double r95602 = r95601 + r95595;
        return r95602;
}

double f(double x, double y, double z) {
        double r95603 = 3.0;
        double r95604 = x;
        double r95605 = y;
        double r95606 = 2.0;
        double r95607 = z;
        double r95608 = fma(r95605, r95606, r95607);
        double r95609 = fma(r95603, r95604, r95608);
        return r95609;
}

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