Average Error: 0.1 → 0.0
Time: 9.3s
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 r122031 = x;
        double r122032 = y;
        double r122033 = r122031 + r122032;
        double r122034 = r122033 + r122032;
        double r122035 = r122034 + r122031;
        double r122036 = z;
        double r122037 = r122035 + r122036;
        double r122038 = r122037 + r122031;
        return r122038;
}

double f(double x, double y, double z) {
        double r122039 = 3.0;
        double r122040 = x;
        double r122041 = y;
        double r122042 = 2.0;
        double r122043 = z;
        double r122044 = fma(r122041, r122042, r122043);
        double r122045 = fma(r122039, r122040, r122044);
        return r122045;
}

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