Average Error: 0.1 → 0.0
Time: 6.4s
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 r134192 = x;
        double r134193 = y;
        double r134194 = r134192 + r134193;
        double r134195 = r134194 + r134193;
        double r134196 = r134195 + r134192;
        double r134197 = z;
        double r134198 = r134196 + r134197;
        double r134199 = r134198 + r134192;
        return r134199;
}

double f(double x, double y, double z) {
        double r134200 = x;
        double r134201 = 3.0;
        double r134202 = 2.0;
        double r134203 = y;
        double r134204 = z;
        double r134205 = fma(r134202, r134203, r134204);
        double r134206 = fma(r134200, r134201, r134205);
        return r134206;
}

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

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

Reproduce

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