Average Error: 0.1 → 0.0
Time: 9.1s
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 r114859 = x;
        double r114860 = y;
        double r114861 = r114859 + r114860;
        double r114862 = r114861 + r114860;
        double r114863 = r114862 + r114859;
        double r114864 = z;
        double r114865 = r114863 + r114864;
        double r114866 = r114865 + r114859;
        return r114866;
}

double f(double x, double y, double z) {
        double r114867 = 3.0;
        double r114868 = x;
        double r114869 = 2.0;
        double r114870 = y;
        double r114871 = z;
        double r114872 = fma(r114869, r114870, r114871);
        double r114873 = fma(r114867, r114868, r114872);
        return r114873;
}

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

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

Reproduce

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