Average Error: 0.1 → 0.0
Time: 2.4s
Precision: 64
\[\left(d1 \cdot 3 + d1 \cdot d2\right) + d1 \cdot d3\]
\[\mathsf{fma}\left(d1, 3 + d2, d1 \cdot d3\right)\]
\left(d1 \cdot 3 + d1 \cdot d2\right) + d1 \cdot d3
\mathsf{fma}\left(d1, 3 + d2, d1 \cdot d3\right)
double f(double d1, double d2, double d3) {
        double r206321 = d1;
        double r206322 = 3.0;
        double r206323 = r206321 * r206322;
        double r206324 = d2;
        double r206325 = r206321 * r206324;
        double r206326 = r206323 + r206325;
        double r206327 = d3;
        double r206328 = r206321 * r206327;
        double r206329 = r206326 + r206328;
        return r206329;
}

double f(double d1, double d2, double d3) {
        double r206330 = d1;
        double r206331 = 3.0;
        double r206332 = d2;
        double r206333 = r206331 + r206332;
        double r206334 = d3;
        double r206335 = r206330 * r206334;
        double r206336 = fma(r206330, r206333, r206335);
        return r206336;
}

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. Simplified0.0

    \[\leadsto \color{blue}{\mathsf{fma}\left(d1, 3 + d2, d1 \cdot d3\right)}\]
  3. Final simplification0.0

    \[\leadsto \mathsf{fma}\left(d1, 3 + d2, d1 \cdot d3\right)\]

Reproduce

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

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

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