Average Error: 0.1 → 0.0
Time: 8.3s
Precision: 64
\[\left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right) + x\]
\[\mathsf{fma}\left(x, 3, \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(x, 3, \mathsf{fma}\left(y, 2, z\right)\right)
double f(double x, double y, double z) {
        double r94403 = x;
        double r94404 = y;
        double r94405 = r94403 + r94404;
        double r94406 = r94405 + r94404;
        double r94407 = r94406 + r94403;
        double r94408 = z;
        double r94409 = r94407 + r94408;
        double r94410 = r94409 + r94403;
        return r94410;
}

double f(double x, double y, double z) {
        double r94411 = x;
        double r94412 = 3.0;
        double r94413 = y;
        double r94414 = 2.0;
        double r94415 = z;
        double r94416 = fma(r94413, r94414, r94415);
        double r94417 = fma(r94411, r94412, r94416);
        return r94417;
}

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. Taylor expanded around 0 0.1

    \[\leadsto \color{blue}{3 \cdot x + \left(z + 2 \cdot y\right)}\]
  3. Simplified0.0

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, 3, \mathsf{fma}\left(y, 2, z\right)\right)}\]
  4. Final simplification0.0

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

Reproduce

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