Average Error: 0.1 → 0.0
Time: 7.0s
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 r10575581 = x;
        double r10575582 = y;
        double r10575583 = r10575581 + r10575582;
        double r10575584 = r10575583 + r10575582;
        double r10575585 = r10575584 + r10575581;
        double r10575586 = z;
        double r10575587 = r10575585 + r10575586;
        double r10575588 = r10575587 + r10575581;
        return r10575588;
}

double f(double x, double y, double z) {
        double r10575589 = x;
        double r10575590 = 3.0;
        double r10575591 = 2.0;
        double r10575592 = y;
        double r10575593 = z;
        double r10575594 = fma(r10575591, r10575592, r10575593);
        double r10575595 = fma(r10575589, r10575590, r10575594);
        return r10575595;
}

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 2019172 +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))