Average Error: 0.1 → 0.0
Time: 968.0ms
Precision: 64
\[\left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right) + x\]
\[\mathsf{fma}\left(3, x, \mathsf{fma}\left(2, y, 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(2, y, z\right)\right)
double f(double x, double y, double z) {
        double r180399 = x;
        double r180400 = y;
        double r180401 = r180399 + r180400;
        double r180402 = r180401 + r180400;
        double r180403 = r180402 + r180399;
        double r180404 = z;
        double r180405 = r180403 + r180404;
        double r180406 = r180405 + r180399;
        return r180406;
}

double f(double x, double y, double z) {
        double r180407 = 3.0;
        double r180408 = x;
        double r180409 = 2.0;
        double r180410 = y;
        double r180411 = z;
        double r180412 = fma(r180409, r180410, r180411);
        double r180413 = fma(r180407, r180408, r180412);
        return r180413;
}

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(2, y, z\right)\right)}\]
  3. Final simplification0.0

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

Reproduce

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