Average Error: 0.1 → 0.0
Time: 4.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(y, 2, 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(y, 2, z\right)\right)
double f(double x, double y, double z) {
        double r89317 = x;
        double r89318 = y;
        double r89319 = r89317 + r89318;
        double r89320 = r89319 + r89318;
        double r89321 = r89320 + r89317;
        double r89322 = z;
        double r89323 = r89321 + r89322;
        double r89324 = r89323 + r89317;
        return r89324;
}

double f(double x, double y, double z) {
        double r89325 = x;
        double r89326 = 3.0;
        double r89327 = y;
        double r89328 = 2.0;
        double r89329 = z;
        double r89330 = fma(r89327, r89328, r89329);
        double r89331 = fma(r89325, r89326, r89330);
        return r89331;
}

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

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

Reproduce

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