Average Error: 0.1 → 0.0
Time: 7.1s
Precision: 64
\[\left(d1 \cdot 3 + d1 \cdot d2\right) + d1 \cdot d3\]
\[d3 \cdot d1 + (d1 \cdot 3 + \left(d1 \cdot d2\right))_*\]
double f(double d1, double d2, double d3) {
        double r24374377 = d1;
        double r24374378 = 3.0;
        double r24374379 = r24374377 * r24374378;
        double r24374380 = d2;
        double r24374381 = r24374377 * r24374380;
        double r24374382 = r24374379 + r24374381;
        double r24374383 = d3;
        double r24374384 = r24374377 * r24374383;
        double r24374385 = r24374382 + r24374384;
        return r24374385;
}

double f(double d1, double d2, double d3) {
        double r24374386 = d3;
        double r24374387 = d1;
        double r24374388 = r24374386 * r24374387;
        double r24374389 = 3.0;
        double r24374390 = d2;
        double r24374391 = r24374387 * r24374390;
        double r24374392 = fma(r24374387, r24374389, r24374391);
        double r24374393 = r24374388 + r24374392;
        return r24374393;
}

\left(d1 \cdot 3 + d1 \cdot d2\right) + d1 \cdot d3
d3 \cdot d1 + (d1 \cdot 3 + \left(d1 \cdot d2\right))_*

Error

Bits error versus d1

Bits error versus d2

Bits error versus d3

Target

Original0.1
Target0.1
Herbie0.0
\[d1 \cdot \left(\left(3 + d2\right) + d3\right)\]

Derivation

  1. Initial program 0.1

    \[\left(d1 \cdot 3 + d1 \cdot d2\right) + d1 \cdot d3\]
  2. Using strategy rm
  3. Applied fma-def0.0

    \[\leadsto \color{blue}{(d1 \cdot 3 + \left(d1 \cdot d2\right))_*} + d1 \cdot d3\]
  4. Final simplification0.0

    \[\leadsto d3 \cdot d1 + (d1 \cdot 3 + \left(d1 \cdot d2\right))_*\]

Reproduce

herbie shell --seed 2019102 +o rules:numerics
(FPCore (d1 d2 d3)
  :name "FastMath test3"

  :herbie-target
  (* d1 (+ (+ 3 d2) d3))

  (+ (+ (* d1 3) (* d1 d2)) (* d1 d3)))