Average Error: 0.1 → 0.0
Time: 11.1s
Precision: 64
\[x \cdot \left(\left(\left(\left(y + z\right) + z\right) + y\right) + t\right) + y \cdot 5\]
\[\mathsf{fma}\left(y, 5, x \cdot t + \left(\left(z + y\right) \cdot 2\right) \cdot x\right)\]
x \cdot \left(\left(\left(\left(y + z\right) + z\right) + y\right) + t\right) + y \cdot 5
\mathsf{fma}\left(y, 5, x \cdot t + \left(\left(z + y\right) \cdot 2\right) \cdot x\right)
double f(double x, double y, double z, double t) {
        double r114936 = x;
        double r114937 = y;
        double r114938 = z;
        double r114939 = r114937 + r114938;
        double r114940 = r114939 + r114938;
        double r114941 = r114940 + r114937;
        double r114942 = t;
        double r114943 = r114941 + r114942;
        double r114944 = r114936 * r114943;
        double r114945 = 5.0;
        double r114946 = r114937 * r114945;
        double r114947 = r114944 + r114946;
        return r114947;
}

double f(double x, double y, double z, double t) {
        double r114948 = y;
        double r114949 = 5.0;
        double r114950 = x;
        double r114951 = t;
        double r114952 = r114950 * r114951;
        double r114953 = z;
        double r114954 = r114953 + r114948;
        double r114955 = 2.0;
        double r114956 = r114954 * r114955;
        double r114957 = r114956 * r114950;
        double r114958 = r114952 + r114957;
        double r114959 = fma(r114948, r114949, r114958);
        return r114959;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Derivation

  1. Initial program 0.1

    \[x \cdot \left(\left(\left(\left(y + z\right) + z\right) + y\right) + t\right) + y \cdot 5\]
  2. Simplified0.0

    \[\leadsto \color{blue}{\mathsf{fma}\left(y, 5, x \cdot \mathsf{fma}\left(y + z, 2, t\right)\right)}\]
  3. Using strategy rm
  4. Applied fma-udef0.0

    \[\leadsto \mathsf{fma}\left(y, 5, x \cdot \color{blue}{\left(\left(y + z\right) \cdot 2 + t\right)}\right)\]
  5. Applied distribute-lft-in0.0

    \[\leadsto \mathsf{fma}\left(y, 5, \color{blue}{x \cdot \left(\left(y + z\right) \cdot 2\right) + x \cdot t}\right)\]
  6. Simplified0.0

    \[\leadsto \mathsf{fma}\left(y, 5, \color{blue}{x \cdot \left(\left(z + y\right) \cdot 2\right)} + x \cdot t\right)\]
  7. Simplified0.0

    \[\leadsto \mathsf{fma}\left(y, 5, x \cdot \left(\left(z + y\right) \cdot 2\right) + \color{blue}{t \cdot x}\right)\]
  8. Final simplification0.0

    \[\leadsto \mathsf{fma}\left(y, 5, x \cdot t + \left(\left(z + y\right) \cdot 2\right) \cdot x\right)\]

Reproduce

herbie shell --seed 2019179 +o rules:numerics
(FPCore (x y z t)
  :name "Graphics.Rendering.Plot.Render.Plot.Legend:renderLegendOutside from plot-0.2.3.4, B"
  (+ (* x (+ (+ (+ (+ y z) z) y) t)) (* y 5.0)))