Average Error: 0.1 → 0.0
Time: 16.4s
Precision: 64
\[\left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right) + x\]
\[\mathsf{fma}\left(2, y, \mathsf{fma}\left(3, x, z\right)\right)\]
\left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right) + x
\mathsf{fma}\left(2, y, \mathsf{fma}\left(3, x, z\right)\right)
double f(double x, double y, double z) {
        double r4003014 = x;
        double r4003015 = y;
        double r4003016 = r4003014 + r4003015;
        double r4003017 = r4003016 + r4003015;
        double r4003018 = r4003017 + r4003014;
        double r4003019 = z;
        double r4003020 = r4003018 + r4003019;
        double r4003021 = r4003020 + r4003014;
        return r4003021;
}

double f(double x, double y, double z) {
        double r4003022 = 2.0;
        double r4003023 = y;
        double r4003024 = 3.0;
        double r4003025 = x;
        double r4003026 = z;
        double r4003027 = fma(r4003024, r4003025, r4003026);
        double r4003028 = fma(r4003022, r4003023, r4003027);
        return r4003028;
}

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. Final simplification0.0

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

Reproduce

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