Average Error: 0.1 → 0.0
Time: 6.6s
Precision: 64
\[\left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right) + x\]
\[\mathsf{fma}\left(x, 3, \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(x, 3, \mathsf{fma}\left(2, y, z\right)\right)
double f(double x, double y, double z) {
        double r5420414 = x;
        double r5420415 = y;
        double r5420416 = r5420414 + r5420415;
        double r5420417 = r5420416 + r5420415;
        double r5420418 = r5420417 + r5420414;
        double r5420419 = z;
        double r5420420 = r5420418 + r5420419;
        double r5420421 = r5420420 + r5420414;
        return r5420421;
}

double f(double x, double y, double z) {
        double r5420422 = x;
        double r5420423 = 3.0;
        double r5420424 = 2.0;
        double r5420425 = y;
        double r5420426 = z;
        double r5420427 = fma(r5420424, r5420425, r5420426);
        double r5420428 = fma(r5420422, r5420423, r5420427);
        return r5420428;
}

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(2, y, \mathsf{fma}\left(3, x, z\right)\right)}\]
  3. Taylor expanded around 0 0.1

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

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

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

Reproduce

herbie shell --seed 2019169 +o rules:numerics
(FPCore (x y z)
  :name "Graphics.Rendering.Plot.Render.Plot.Legend:renderLegendInside from plot-0.2.3.4"
  (+ (+ (+ (+ (+ x y) y) x) z) x))