Average Error: 0.1 → 0.0
Time: 13.4s
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 r6605531 = x;
        double r6605532 = y;
        double r6605533 = r6605531 + r6605532;
        double r6605534 = r6605533 + r6605532;
        double r6605535 = r6605534 + r6605531;
        double r6605536 = z;
        double r6605537 = r6605535 + r6605536;
        double r6605538 = r6605537 + r6605531;
        return r6605538;
}

double f(double x, double y, double z) {
        double r6605539 = 3.0;
        double r6605540 = x;
        double r6605541 = y;
        double r6605542 = 2.0;
        double r6605543 = z;
        double r6605544 = fma(r6605541, r6605542, r6605543);
        double r6605545 = fma(r6605539, r6605540, r6605544);
        return r6605545;
}

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(3, x, \mathsf{fma}\left(y, 2, z\right)\right)}\]
  5. Final simplification0.0

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

Reproduce

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