Average Error: 0.1 → 0.0
Time: 8.2s
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 r27256265 = d1;
        double r27256266 = 3.0;
        double r27256267 = r27256265 * r27256266;
        double r27256268 = d2;
        double r27256269 = r27256265 * r27256268;
        double r27256270 = r27256267 + r27256269;
        double r27256271 = d3;
        double r27256272 = r27256265 * r27256271;
        double r27256273 = r27256270 + r27256272;
        return r27256273;
}

double f(double d1, double d2, double d3) {
        double r27256274 = d3;
        double r27256275 = d1;
        double r27256276 = r27256274 * r27256275;
        double r27256277 = 3.0;
        double r27256278 = d2;
        double r27256279 = r27256275 * r27256278;
        double r27256280 = fma(r27256275, r27256277, r27256279);
        double r27256281 = r27256276 + r27256280;
        return r27256281;
}

\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 2019101 +o rules:numerics
(FPCore (d1 d2 d3)
  :name "FastMath test3"

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

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